# Problem with numerical evaluation of a Hankel identity

There an identity with the Hankel functions of both types (https://dlmf.nist.gov/10.11 eq. 10.11.4 or http://apps.nrbook.com/bateman/Vol2.pdf pg. 80 eq. 43):

$$\sin\left(\nu\pi\right){H^{(2)}_{\nu}}\left(ze^{m\pi i}\right)=e^{\nu\pi i}\,\sin\left(m\nu\pi\right){H^{(1)}_{\nu}}\left(z\right)+\sin\left((m+1)\nu\pi\right){H^{(2)}_{\nu}}\left(z\right)$$

Where $$m$$ is an integer, and $$\nu$$ and $$z$$ are complex.

I tried to check this identity numerically with Mathematica, and I am not getting the right result. The code is as simple as it gets (I use $$x$$ for $$\nu$$, the rest is as in the identity):

Sin[x*Pi]*HankelH2[x, z*E^(I*m*Pi)] /. {x -> 5.3, m -> 3, z -> 3.8}
(*0.831257 + 0.572696 I*)

Sin[m*Pi*x]*HankelH1[x, z]*E^(I*x*Pi) + Sin[(m + 1)*x*Pi]*HankelH2[x, z] /. {x -> 5.3, m -> 3, z -> 3.8}
(*0.239708 - 0.819552 I*)


I use all reals, but with any other numbers there is still no coincidence. I am doing something wrong? Is it a bug? I don't know what’s the problem. I am evaluating it with Mathematica 12 on Windows.

• I don't understand the m dependence on the RHS. If you replace m with Mod[m, 2] on the RHS, then the equation is satisfied. – Carl Woll Oct 31 at 19:12
• Yes, that is true, but the identity, unless I am reding something wrong, should be valid for m being any integer. Putting Mod[m, 2] on the RHS is basically saying that the identity is valid only for m=1 and m=0 which I knew was working, that is why I put the example with m = 3. In DLMF 10.11 eq. 10.11.5 they evaluate it explicitly for m=-1 (no modulo involved) and that is another value for which the identity does not work in Mathematica. – Ezequiel Nov 4 at 22:52
• Consider formula 10.11.1, which says that $J_n\left(z e^{m \pi i}\right) = e^{m n \pi i} J_n(z)$. Clearly the LHS is the same for all even or all odd values of m. Yet, the RHS clearly is not, unless $n$ is also an integer. – Carl Woll Nov 4 at 23:21
• Hmm, it is true. Then it is not an issue with the evaluation in Mathematica, it is a problem with how they express the identities in el DLMF. Thank you. – Ezequiel Nov 6 at 21:04

The discrepancy you observe is mostly due to the fact that Mathematica's choice of branch cuts for Log[] (and thus Power[] as well) results in the observation that in general,

$$\exp(i m \pi)^\nu\ne\exp(i m \nu \pi)$$

For instance, using formula 10.11.1 as an example (as suggested by Carl in a comment):

With[{m = 3, ν = 53/10, z = 38/10},
N[{BesselJ[ν, z Exp[m π I]],
Exp[m ν π I] BesselJ[ν, z], Exp[m π I]^ν BesselJ[ν, z]}, 20]]
{-0.048085703485436027071 - 0.066184292910491842025 I,
0.077804302612384776116 - 0.025280150370429181571 I,
-0.048085703485436027071 - 0.066184292910491842025 I}


Note that the first and third values agree with each other, but not with the second.

Thus, the formulae in the DLMF (and Abramowitz and Stegun, for that matter), need to be modified a bit. Using the second Hankel function as an example,

With[{m = 3, ν = 53/10, z = 38/10},
N[{HankelH2[ν, z Exp[m π I]],
Exp[m π I]^-ν (HankelH2[ν, z] +
(Exp[m π I]^(2 ν) - 1) (1 - I Cot[π ν]) BesselJ[ν, z])}, 20]]
{-1.02749002984593274604 - 0.70789057098138487388 I,
-1.02749002984593274604 - 0.70789057098138487388 I}