diff is not the problem here, subs is. For example, if you compare the 
expressions for diff(x, y) and diff(y, x), they are the same.  The problem is 
that you get terms like (2*x - 3*y**2)/(x**2 + y**2).  IMHO, subs({x:0, y:0}) 
should not even work here, because you get 0/0.  The problem is that once it 
replaces one term with 0, it cancels the other.

So I am not even convinced that doing subs in a certain order will always 
return a correct result.  

Ideally, you should be able to compute a as:

In [3]: a = (x**2*y - y**3*x)/(x**2 + y**2)

In [13]: a = Piecewise((a, And(Ne(x, 0), Ne(y, 0))), (0, False))

And when you take the derivative of a, it will recognize the singularity at 0, 
0 (or at least the fact that it is defined differently there), and will compute 
the limit for it and return another piecewise.  

But that does not work right now, partially because And does not work with 
Piecewise yet, and partially because 

b = Piecewise((a, Ne(x,0)), (a, Ne(y, 0)), (0, True))

Defines correctly, but b.diff(y) does not compute the limit:

In [37]: limit(a/y, y, 0)
Out[37]: 1

Aaron Meurer
On Apr 7, 2010, at 11:54 PM, chu-ching huang wrote:

> Hi,
> 
> I know this problem can be treated correctly as above. The example
> given here is just to say that using "diff" has to be more careful
> since
> 
> diff(f,x,y).subs([(x, a), (y,b)])
> 
> may be not equal to $lim_{(x,y)\to(a,b)} f(x,y)$.
> 
> Thanks,
> 
> cch
> 
> -- 
> 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.

Reply via email to