# How to simplify an expression with special functions to zero

The following is a well-known Bessel function identity:

$$J_{-n}(z)=(-1)^n J_n(z),\qquad n\in\mathbb Z$$

To check this, I used the following code and the result is as what I expected.

In[2]:= FullSimplify[(-1)^n*BesselJ[n, z] == BesselJ[-n, z], n ∈ Integers]
Out[2]= True


The problem is that Mathematica does not return zero when I try to simplify the following expression:

$$(-1)^n J_{n}(z)-J_{-n}(z),\qquad n\in\mathbb Z$$

I tried the following code, but the output is as complex as the input:

In[3]:= FullSimplify[(-1)^n*BesselJ[n, z] - BesselJ[-n, z], n ∈ Integers]
Out[3]= -BesselJ[-n, z] + (-1)^n BesselJ[n, z]    (*result I expected : 0*)


My goal is to command Mathematica to reduce the expression to zero, and I need some advice.

-
See also: Why FullSimplify doesn't work here? –  becko Nov 19 '13 at 14:53

FullSimplify[(-1)^n*BesselJ[n, z] - BesselJ[-n, z],  n ∈ Integers,
ComplexityFunction -> (StringLength @ ToString @ # &)]


Also:

ComplexityFunction -> (Count[#, _BesselJ | _Power, {-2}] &)
ComplexityFunction -> (Count[#, _?NumberQ, Infinity] &)

-
I daresay it is baffling that the usual approach of comparing LeafCount[]s doesn't work... –  Ｊ. Ｍ. May 15 '13 at 16:50
@J.M. ComplexityFunction -> (StringLength @ ToString @ # & could be useful at the code golf site –  belisarius May 15 '13 at 17:59
Actually, I don't know what (StringLength @ ToString @ # &) means. Nonetheless, I got some clues from looking at the other two options. The options you suggested are quite informative and could be utilized in many similar situations. –  Tom Wayne May 16 '13 at 8:41
@Tom, it simply treats the expression being applied to as a string, and counts the number of characters in said string. –  Ｊ. Ｍ. May 16 '13 at 11:19
@J.M. Now I got it. That's quite a compact form. –  Tom Wayne May 17 '13 at 14:02

A bit of cheating:

DifferenceRootReduce[(-1)^n BesselJ[n, z] - BesselJ[-n, z], n]
0


I must admit I'm not sure why FullSimplify[] fails on this, tho.

-
Very nice. $\phantom{}$ –  belisarius May 15 '13 at 15:50
That's a brilliant answer. Still, it's a mystery why FullSimplify doesn't work on this expression. –  Tom Wayne May 15 '13 at 16:10