# Integral funkiness

Posted 10 years ago
4015 Views
|
5 Replies
|
12 Total Likes
|
 I have a rather curious problem. I'm trying to solve this integral:step1 = Integrate[  Cos[q + ((k2 - k2 Cos[\[Theta]]) \[Rho] Cos[\[Phi]] -        k2 Sin[\[Theta]] \[Rho] Sin[\[Phi]])] \[Rho], {\[Phi], 0,    2 \[Pi]},   Assumptions -> {k2 > 0 && \[Theta] \[Element] Reals && \[Rho] > 0}]The answer it gives me for that is2 \[Pi] \[Rho] Cos[q]This seems to be independent of Theta. However, if I plug in a value for Theta before doing the integral. For example Theta = Pi / 2 gives:2 \[Pi] \[Rho] BesselJ[0, Sqrt[2] k2 \[Rho]] Cos[q]And Theta = Pi gives2 \[Pi] \[Rho] BesselJ[0, 2 k2 \[Rho]] Cos[q]Obviously, the result does depend on Theta then, even though the initial answer has no theta dependence. Is this a bug I stumbled upon in Mathematica 8.0.1.0 for Linux or am I missing something fundamental here?
5 Replies
Sort By:
Posted 10 years ago
 Thanks! That's a very neat approach. I think you made a minor mistake at the end though. I've gone through the steps you mentioned, but the series one gets isIn[13]:= Sum[(-1)^o q^(2 o)/(2 o)!, {o, 0, \[Infinity]}]Out[13]= Cos[q]There is an extra factor of (-1)^o there and the series starts from o=0 instead of o=1. With those modifications it works. So in the end one instead getsCos[q] ConditionalExpression[ 2 ? ? BesselJ[0, Sqrt[(k2 - x)^2 + y^2] ?], Sqrt[(k2 - x)^2 + y^2] ? Reals], which is definitely the answer I was looking for.I had obtained that answer through a different approach, which I feel is simply a workaround for the bug, but to wit:The original formula wasCos[q + ((k2 - k2 Cos[?]) ? Cos[?] - k2 Sin[?] ? Sin[?])] ?, which I had rewritten in the formCos[q + \[Gamma]1 Cos[\[Phi]] - \[Gamma]2 Sin[\[Phi]] \[Rho]= Cos[q + \Sqrt[\[Gamma]1^2 + \[Gamma]2^2] Cos[\[Phi] + \[Beta]]], where the new angle ? is defined asCos[\[Beta]] = \[Gamma]1/Sqrt[\[Gamma]1^2 + \[Gamma]2^2]Sin[\[Beta]] = \[Gamma]2/Sqrt[\[Gamma]1^2 + \[Gamma]2^2]Doing so allowed Mathematica to solve the integral, giving the same answer as your method produced.
Posted 10 years ago
 Okay, you figured it out; last night I found it strange to generate Cosh during integration of Cos. Just for the logs In[40]:= Clear[fN, fA] fN[q_, k2_, \[Theta]_, \[Rho]_] :=   NIntegrate[   Cos[q + ((k2 - k2 Cos[\[Theta]]) \[Rho] Cos[\[Phi]] -         k2 Sin[\[Theta]] \[Rho] Sin[\[Phi]])] \[Rho], {\[Phi], 0,     2 \[Pi]}] fA[q_, k2_, \[Theta]_, \[Rho]_] :=   2 \[Pi] \[Rho] Cos[q] BesselJ[0,      Sqrt[(k2 -         k2 Cos[\[Theta]])^2 + (k2 Sin[\[Theta]])^2] \[Rho]] /; \(-\[Pi] + \[Theta])/(2 \[Pi]) \[NotElement] IntegersIn[55]:= Clear[ted]ted = Transpose[   RotateLeft[    Join[RandomReal[{-1, 5}, {3,        30}], {RandomReal[{-\[Pi] + 1/1000, \[Pi] - 1/1000}, 30]}]]];In[67]:= Chop[(fA @@@ ted) - (fN @@@ ted)]Out[67]= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Posted 10 years ago
 Hi there,this you can possibly solve: First of all, one sets q = 0, k2 Cos[?]= x, k2 Sin[?] = ybecause the q is a strong obstacle and the ?-terms are unimportant for the integral. The simplified integral(* q = 0, k2 Cos[\[Theta]] \[Rule] x, k2 Sin[\[Theta]]\[Rule] y *)Integrate[ Cos[((k2 - x) \[Rho] Cos[\[Phi]] - y \[Rho] Sin[\[Phi]])] \[Rho], {\[Phi], 0, 2 \[Pi]}, Assumptions -> {k2 > 0 && \[Theta] \[Element] Reals && \[Rho] > 0}]ConditionalExpression[ 2 \[Pi] \[Rho] BesselJ[0, Sqrt[(k2 - x)^2 + y^2] \[Rho]], Sqrt[(k2 - x)^2 + y^2] \[Element] Reals]The conditional meansIn[8]:= Reduce[(k2 - k2 Cos[\[Theta]])^2 + (k2 Sin[\[Theta]])^2 >= 0, \[Theta], Reals]Out[8]= (C[1] \[Element]     Integers && \[Theta] == \[Pi] +      2 \[Pi] C[1]) || (-\[Pi] + \[Theta])/(2 \[Pi]) \[NotElement] Integersand one findsIn[7]:= SIntegrate[Sin[((k2 - x) \[Rho] Cos[\[Phi]] - y \[Rho] Sin[\[Phi]])] \[Rho], {\[Phi], 0, 2 \[Pi]}, Assumptions -> {k2 > 0 && \[Theta] \[Element] Reals && \[Rho] > 0}]Out[7]= 0Why this is interesting? If you develop the orginal integral into a seris in q and integrateIntegrate[Series[  Cos[q + ((k2 - k2 Cos[\[Theta]]) \[Rho] Cos[\[Phi]] -        k2 Sin[\[Theta]] \[Rho] Sin[\[Phi]])] \[Rho], {q, 0,    12}], {\[Phi], 0, 2 \[Pi]}]you are left with only the both integrals shown above, one is zero, so the result is(Cosh[q]- 1) ConditionalExpression[ 2 \[Pi] \[Rho] BesselJ[0, Sqrt[(k2 - x)^2 + y^2] \[Rho]], Sqrt[(k2 - x)^2 + y^2] \[Element] Reals]x and y do depend on \ because ofIn[13]:= Sum[q^(2 o)/(2 o)!, {o, 1, Infinity}]Out[13]= -1 + Cosh[q]Best regardsUdo.
Posted 10 years ago
 Ah, thanks. Good to see that I'm not going crazy.
Posted 10 years ago
 This may be an issue with your version of Mathematica - I was able to reproduce your first result in Mathematica 8.0.1, but was not able to reproduce the result in 8.0.4 or 9.0.1.  Those later versions returned the input unevaluated after a lengthy calculation.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments