You can pass [(term, item), …] pairs (dict.items()) to subs to make them go in
order:
In [4]: f(x, y).subs([(x, z), (z, 0)])
Out[4]: f(0, y)
Aaron Meurer
On Apr 7, 2010, at 12:51 AM, Renato Coutinho wrote:
> Hi,
>
>> $f(x,y)=(x^3*y-y^3*x)/(x^2+y^2$
>> for $(x,y)\nq(0,0) and $f(0,0)=0$
>>
>> has second-order partial derivatives, $f_{x,y}(0,0)=-1$ and $f_{y,x}
>> (0,0)=1$. Note they are not equal. But if use directly
>>
>> diff(f,x,y).subs({x:0,y:0})
>
> diff() differentiates f and arrives at the expression
>
> In [7]: simplify(f.diff(x, y))
> Out[7]: (9*x**4*y**2 - 9*x**2*y**4 + x**6 - y**6)/(3*x**4*y**2 +
> 3*x**2*y**4 + x**6 + y**6)
>
> Now, the difference is the order of the subs argument. You can do:
>
> In [8]: Out[7].subs({x:0})
> Out[8]: -1
>
> In [9]: Out[7].subs({y:0})
> Out[9]: 1
>
> Since you pass a dict to subs(), you don't control the order in which
> the subs are made. For that, you can use a list or call subs() two
> times:
>
> In [10]: Out[7].subs([(y,0), (x,0)])
> Out[10]: 1
>
> In [11]: Out[7].subs({y:0}).subs({x:0})
> Out[11]: 1
>
> Or the other way:
>
> In [12]: Out[7].subs([(x,0), (y,0)])
> Out[26]: -1
>
> In [13]: Out[7].subs({x:0}).subs({y:0})
> Out[13]: -1
>
> Hope it helps.
>
> Renato
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.