Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have the following function:

f[0, 0] = 0
f[x_, y_] := Exp[-(x^2 + y^2)^(-1)]

How do I find its partial derivatives at any given point, including $(0,0)$? This doesn't work (obviously, I guess):

point={0,0}
D[f[x, y], x] /. x -> point[[1]] /. y -> point[[2]]
share|improve this question
1  
f[x_, y_] := Exp[-(x^2 + y^2)^(-1)] point = {1, 1}; D[f[x, y], x] /. {x -> point[[1]], y -> point[[2]]} This worked.. –  drN Sep 29 '12 at 23:27
add comment

2 Answers 2

up vote 6 down vote accepted

In case you have any problems, I recommend using the Derivative operator instead of D, since the latter works on expressions, while the former one can work on pure functions.

{Derivative[1, 0][f][x, y], Derivative[0, 1][f][x, y]} // TraditionalForm

enter image description here

The subtlety here is that one cannot use it to find partial derivatives of f at {0,0}, e.g.

Derivative[0, 1][f][0, 0]
Power::infy: Infinite expression 1/0 encountered. >>
Infinity::indet: Indeterminate expression E^ComplexInfinity encountered. >>
Power::infy: Infinite expression 1/0^2 encountered. >>

Indeterminate 

however, you can use Limit instead of Derivative:

Limit[ #, h -> 0] & /@ {( f[0 + h, 0] - f[0, 0] )/ h, ( f[0, 0 + h] - f[0, 0] )/ h}
{0, 0}

In general, it works as we would like:

Limit[ #, h -> 0] & /@ { (f[x + h, y] - f[x, y])/ h, (f[x, y + h] - f[x, y])/ h} ==
{ Derivative[1, 0][f][x, y], Derivative[0, 1][f][x, y] }
True

One can also take advantage of FoldList to follow computing several limits, e.g. :

FoldList[ Limit, (f[x + h, y] - f[x, y])/h, {h -> 0, y -> 0, x -> 0}] // TraditionalForm

enter image description here

We have shown that the partial derivative with respect to x is continuous at {0,0}. We can show much more; namely, that any derivative of any order vanishes at {0,0}. We find here the few first terms of a Taylor series expansion near {0,0} :

Limit[ Limit[ Normal @ Series[ f[x, y], {y, y0, 7}, {x, x0, 7}], x0 -> 0], y0 -> 0]
0

i.e. this function is not analytic at {0,0}, since the Taylor series expansion is identically 0, while the function f itself is not.

share|improve this answer
1  
Thanks, but formally, this is the limit of the derivative as the point tends to zero, not exactly the derivative at zero (though in this case they are equal). Do I have to resort to Limit and the definition of a derivative to do it in the general case? –  mbork Sep 29 '12 at 17:27
1  
You can find the Limit of the difference ratio directly. –  Artes Sep 29 '12 at 17:30
    
Exactly, I just thought there's another way. –  mbork Sep 29 '12 at 17:35
    
@mbork more exactly f is a smooth function everywhere but it is not analytic in {0,0}. –  Artes Sep 29 '12 at 17:38
add comment

For evaluating derivatives for numerical arguments, one (somewhat neglected) function for the purpose is SeriesCoefficient[]. Of course, this produces derivatives scaled by factorials, so you have to multiply by the appropriate factorial factors to get the actual value of the derivative. For instance,

Derivative[3, 5][Function[{x, y}, Exp[-1/(x^2 + y^2)]]][1, 1]
   117215/(256 Sqrt[E])

With[{p = 3, q = 5, x0 = 1, y0 = 1}, 
     p! q! SeriesCoefficient[Exp[-1/(x^2 + y^2)], {x, x0, p}, {y, y0, q}]]
   117215/(256 Sqrt[E])
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.