Why does Mathematica give the wrong answer when integrating?
-
I integrate Integrate[Exp[I Cos[b - c]] Cos[b], {b, 0, 2 Pi}] Mathematica gives: 2 I Pi BesselJ[1, 1] Which is indepedent on $c$. However, the result is NOT independent on $c$. The numerical value of what Mathematica gives is 0. + 2.76492 I while NIntegrate[Exp[I Cos[b - 0.5]] Cos[b], {b, 0, 2 Pi}] Gives 1.16655*10^-10 + 2.42645 I Certainly not the same. If we multiply the value Mathematica gives with $\cos(0.5)$ the result is the same. What is wrong?
-
Answer:
Looks like a bug that ran off in the development version of Mathematica. In[1]:= Integrate[Exp[I Cos[b - c]] Cos[b], {b, 0, 2 Pi}]//InputForm Out[1]//InputForm= (2*I)*Pi*BesselJ[1, 1]*Cos[c] In[2]:= %/.c->.5 Out[2]= 0. + 2.42645 I
Jonas Teuwen at Mathematica Visit the source
Other answers
This bug appears to have been known for over a year now! https://groups.google.com/forum/?fromgroups#!searchin/comp.soft-sys.math.mathematica/integrate%2420bessel%2420function%2420bug%7Csort%3adate/comp.soft-sys.math.mathematica/ofJh_oRFAB4/TFcbpQsKw3MJ Edit To explain why I consider these bugs to be equivalent, I'll re-write the two integrals using the integration variable x. In the present question, we have $$I_1(c)=\int_0^{2\pi}\exp(i\cos(x-c))\cos x\,dx$$ On the other hand, the MathGroup post I linked here considers the integral $$I_2(c)=\int_{-\pi}^{\pi}\exp(i\cos(x-c))\exp(ix-ic)\,dx$$ where I specialized to the case giving the same Bessel argument in the result. Pulling out the constant factor, using the periodicity of the integrand and making a substitution of variables, one finds $$I_2(c)=e^{-ic}\left[I_1(c)+i\, I_1(c-\frac{\pi}{2})\right]$$ Therefore, if Wolfram fixed the bug in the calculation of $I_2$ but still gets an incorrect result for $I_1$, that fix was itself incorrect. This argument generalizes to integer Bessel indices other than 1 (which is what this question has). Finally, the question is whether it is a bug fix to return the integrals unevaluated. I would argue that because these are such ubiquitous integrals, Mathematica should definitely know what to do with them. But I may not have all the information as to why this bug is so hard to fix... I just wanted to briefly clarify my thinking in case anyone cares.
Jens
Related Q & A:
- In a job interview: What is the best answer when asked on weakness?Best solution by Yahoo! Answers
- How can I give the best answer in Yahoo answers?Best solution by Yahoo! Answers
- Why do people give each other hickeys?Best solution by Yahoo! Answers
- Why does perfume give me a headache?Best solution by Yahoo! Answers
- Why Can't I Choose 'Best Answer' Anymore?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.