9

I am new to mathematica and I hope this is a simple problem. I have two identical functions that only differ by the variable names:

PolarInverseFT[f_, p_, u_, r_, t_] := 
 Integrate[
  p f Exp[-I 2 π r p Cos[u - t]], {p , 0, ∞}, {u, 0, 2 π} ]

PolarInverseFT2[f_, r_, t_, p_, u_] := 
 Integrate[
  r f Exp[-I 2 π  p r Cos[t - u]], {r, 0, ∞}, {t, 0, 2 π} ]

I would expect them to behave identically. However,

PolarInverseFT[λ^2/(λ^2 + 4 π^2 p^2), p, u, r, t]

returns the error

-I Sin[2 p π r #1] is not a valid variable

But

PolarInverseFT2[λ^2/(λ^2 + 4 π^2 r^2), r, t, p, u]

gives the correct answer. For other f_ both can return an answer without failing, but the answers differ!

Any help would be greatly appreciated.

Michael E2
  • 235,386
  • 17
  • 334
  • 747
  • Welcome to Mathematica.SE! I suggest the following:
    1. As you receive help, try to give it too, by answering questions in your area of expertise.
    2. Read the [faq]!
    3. When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge.

    Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!

    –  Mar 06 '15 at 11:20
  • You can format inline code and code blocks by selecting it and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. – Michael E2 Mar 06 '15 at 11:34
  • In general, why including your integration variables in the arguments ? – b.gates.you.know.what Mar 06 '15 at 13:02
  • @b.gatessucks that was my first thought as well. The integration variables appear in the first argument, so this makes sense ( the second and third arguments in each case must be passed in as undefined symbols ). That said, I obtain different results for the two cases, starting with a clean kernel each time. (not the same error though, the first case returns an unevaluated integral w/v9) – george2079 Mar 06 '15 at 15:05
  • @b.gatessucks True, but besides the point. I note that the integrals themselves (executed directly and not through the above definitions) exhibit the same strange behavior. – Sjoerd C. de Vries Mar 06 '15 at 15:22
  • @SjoerdC.deVries There was a question about something very similar, but I can't find it right now. The problem was caused by the lexicographical ordering of the symbol names, as strange as it may seem. Do you remember that question? – Dr. belisarius Mar 06 '15 at 16:28
  • @belisarius I remember two questions that were related, Daniel lichtblau commented there. – Sjoerd C. de Vries Mar 06 '15 at 17:33
  • confirmed the lexicographical ordering of the symbol names being subtracted for the Cos argument is the distinction here. Interestingly changing to Cos[u+t] fixes it. – george2079 Mar 06 '15 at 18:49
  • @george2079 It's more interesting if you also consider that FullForm@Cos[u - t] == FullForm@Cos[t - u] – Dr. belisarius Mar 06 '15 at 19:31
  • @belisarius: And gets even more interesting, if you reverse the integration parameters: All of a sudden, FT2 yields 0, while FT1 runs on and on and on (and then stops without any result, but some (other) General::ivar errors). – Jinxed Mar 07 '15 at 00:02
  • A simpler way to trigger the General::ivar messages: Integrate[Exp[-I Cos[u - t]], {u, 0, 2*Pi}]. The result from this Integrate is correct, but the messages shouldn't be there. – Szabolcs Apr 05 '15 at 19:03
  • I believe that you should remove p_ and u_ from the arguments to PolarInverseFT as they are used as limit variables for the integration. Similarly remove r_ and t_ from the arguments to PolarInverseFT2. I don't think this will fix your problem but I think the code is better. – Jack LaVigne Oct 02 '15 at 21:47

1 Answers1

1

not an answer, just a simpler demonstration of the issue ( version 9.01 )

Integrate[r (1/(1 + 4 Pi^2 r^2)) Exp[-I 2 Pi  r Cos[t - u]],
       {r, 0, Infinity}, {t, 0, 2 Pi}]

enter image description here

In the second case I've just copied the expression and changed t to z .. puzzling. It seems in the first case u has been assumed real and the second not.

george2079
  • 38,913
  • 1
  • 43
  • 110