Why this
d2bdy2 = b_i.diff(y_i, 2) exec("pprint({{'{0}': {0}}})".format("d2bdy2"))
is not equivalent to
def assign_and_pprint(Name, Expr): exec("{Name} = {Expr}".format(Name=Name, Expr=Expr)) exec("pprint({{'{Name}': {Name}}})".format(Name=Name)) assign_and_pprint("d2bdy2", b_i.diff(y_i, 2))
Compelete example:
#!/usr/bin/python2.7 from sympy import * def assign_and_pprint(Name, Expr): exec("{Name} = {Expr}".format(Name=Name, Expr=Expr)) exec("pprint({{'{Name}': {Name}}})".format(Name=Name)) var(""" b_i y_i nu """, positive=True) b_i = 2**(S(2)/3) / (nu**(S(4)/3) * (y_i - 1)**(S(8)/3)) d2bdy2 = b_i.diff(y_i, 2) exec("pprint({{'{0}': {0}}})".format("d2bdy2")) assign_and_pprint("d2bdy2", b_i.diff(y_i, 2))
Which gives:
⎧ 2/3 ⎫ ⎪ 88⋅2 ⎪ ⎨d2bdy2: ───────────────────⎬ ⎪ 4/3 14/3⎪ ⎩ 9⋅ν ⋅(yᵢ - 1) ⎭ ⎧ -1.33333333333333 -4.66666666666667⎫ ⎨d2bdy2: 15.5212547303557⋅ν ⋅(yᵢ - 1) ⎬ ⎩ ⎭
exec("{Name} = sympify({Expr})".format(Name=Name, Expr=Expr))
gives the same, and
exec(sympify("{Name} = {Expr}".format(Name=Name, Expr=sympify(Expr))))
gives an error...
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/D5O51p6OPXE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+un...@googlegroups.com.