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.

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.

share|improve this question
    
See also: Why FullSimplify doesn't work here? –  becko Nov 19 '13 at 14:53

2 Answers 2

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

Also:

ComplexityFunction -> (Count[#, _BesselJ | _Power, {-2}] &)
ComplexityFunction -> (Count[#, _?NumberQ, Infinity] &)
share|improve this answer
3  
I daresay it is baffling that the usual approach of comparing LeafCount[]s doesn't work... –  J. M. 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
1  
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. –  J. M. 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.

share|improve this answer
    
Very nice. $\phantom{}$ –  belisarius May 15 '13 at 15:50
2  
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

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.