# Symbolic derivatives of special functions yield incorrect results

When I evaluate with Mathematica this expression

D[ Abs[ Zeta[x + I y]], {x, 2}] + D[ Abs[ Zeta[x + I y]], {y, 2}]
0

the result is zero which is an error.
Could you explain what's wrong?

-
This is abug in mathematica! – Kevin67 Mar 30 '14 at 15:50
The result must be an Polynom with x and y. – Kevin67 Mar 30 '14 at 15:52
D[Abs[[x + I y]], {x, 2}] + D[Abs[[x + I y]], {y, 2}] – Kevin67 Mar 30 '14 at 16:35
this is also =0??? – Kevin67 Mar 30 '14 at 16:35

A workaround might be to express Abs in terms of Conjugate, so:

a = ComplexExpand[Abs[Zeta[x + I y]], TargetFunctions -> Conjugate]

$\sqrt{\zeta (x-i y) \zeta (x+i y)}$

FullSimplify[D[a, {x, 2}] + D[a, {y, 2}]]

$\frac{\zeta '(x-i y) \zeta '(x+i y)}{\sqrt{\zeta (x-i y) \zeta (x+i y)}}$

I don't know if this is the correct result, but it seems to agree with the results of ND (as shown in Michael's answer) for the few points I tested.

-
"I don't know if this is the correct result" - well, this at least is how I'd have done it. – J. M. Nov 19 '15 at 8:26

Mathematica treats Abs as if it were (complex) differentiable, which, unfortunately, is not the case. It returns Abs' when it is differentiated. That indicates that Mathematica does not know what to do with the input.

One problem with the OP's problem is that the Chain Rule does not apply to expressions of the form D[Abs[u[x,y]], x]. Another problem is that if one tries D[ComplexExpand @ Abs[Zeta[x,y]], x], then we end up with the derivatives of Re and Im, which do not exist.

I do not know a way around this except by going back to the definition to compute the partial derivatives. But even that has a problem.

Assuming[{Element[{x, y}, Reals]},
d2 = Limit[(DifferenceDelta[Abs[Zeta[x + I y]], {x, 2, h}] +
DifferenceDelta[Abs[Zeta[x + I y]], {y, 2, h}])/h^2,
h -> 0]
]
(*
(Re[Zeta[x + I y]]^2 (-Derivative[1][Zeta][x + I y]^2 +
2 Re[Zeta[x + I y]] Derivative[2][Zeta][x + I y]) +
Im[Zeta[x + I y]]^2 (Derivative[1][Zeta][x + I y]^2 +
2 Re[Zeta[x + I y]] Derivative[2][Zeta][x + I y]))/(Im[
Zeta[x + I y]]^2 + Re[Zeta[x + I y]]^2)^(3/2)
*)

d2 /. {x -> 2, y -> 1.}
(*
-0.191142 + 0.0496602 I
*)

Hmm...why is there an imaginary part??? Let's check:

Needs["NumericalCalculus`"];

ND[Abs[Zeta[x + I y]] /. y -> 1, {x, 2}, 2] +
ND[Abs[Zeta[x + I y]] /. x -> 2, {y, 2}, 1]
(*
0.197487
*)

Limit[(DifferenceDelta[Abs[Zeta[x + I y]], {x, 2, h}] +
DifferenceDelta[Abs[Zeta[x + I y]], {y, 2, h}])/h^2 /. {x -> 2.,
y -> 1.},
h -> 0]
(*
0.197487
*)

Oh, well...it seems that the symbolic limit is wrong. Perhaps someone will enlighten us.

-

Please see answer by @michael-e2 as it is much better. I'm using the chain rule, here, for arbitrary functions (which appears to be what Mathematica is doing), but this is not correct for |z| which is not complex differentiable.

Are you sure this is a bug?
Consider replacing Abs and Zeta with arbitrary functions foo and bar:

D[ foo[ bar[x + I y]], {x, 2}] + D[ foo[ bar[x + I y]], {y, 2}]

The first term and the last term differ only in sign. By the chain rule all the factors in the derivatives are the same except for the D[x + I y, x] or D[x + I y, y] factors which are either 1 or I. Taking the second derivative, this becomes a factor of 1 in the x derivative case and -1 in the y derivative case.

-
f=x+iy ,|f|=x^2+y^2 – Kevin67 Mar 30 '14 at 16:34
I'm not sure what you're trying to say, but Abs[z] for complex z is the modulus of z. If z = x + i y, then Abs[z] will be computed as Sqrt[x^2 + y^2]. – Christopher Cole Mar 30 '14 at 16:50
when you differentiate sqrt (x^2+y^2) there is no i – Kevin67 Mar 30 '14 at 17:05
Yes, but that's not what you're differentiating. You are differentiating Abs[Zeta[x + I y]]. If you want to know what the derivatives are with respect to x or y, you need to use the chain rule, and that will bring in factor i. – Christopher Cole Mar 30 '14 at 17:33
d^2/dx^2 |zeta(x)|+d^2/dy^2|zeta(x)| with your Argumentation this must be Zero wich is not – Kevin67 Mar 30 '14 at 17:45