Re: Re: Why does this lead to an answer with complex numbers?
- To: mathgroup at smc.vnet.net
- Subject: [mg71535] Re: [mg71497] Re: Why does this lead to an answer with complex numbers?
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Wed, 22 Nov 2006 05:22:17 -0500 (EST)
- References: <ejosmm$n3k$1@smc.vnet.net> <ejrmr9$97b$1@smc.vnet.net> <ejs3fv$9ii$1@smc.vnet.net> <200611202312.SAA18423@smc.vnet.net>
On 21 Nov 2006, at 08:12, David W. Cantrell wrote: > Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com> wrote: >> aaronfude at gmail.com wrote: >>> Hi, >>> >>> Thanks for all the answers. They were all very useful, even though I >>> have done my best to confuse everyone by leaving a beta in there >>> which >>> had nothing to do with the problem. >>> >>> So I understand that the answer may be complex and the complex >>> part is >>> constant which is in a certain sense valid for a indefinite >>> integral. >>> But I very much need a real answer and I still can't quite extract. >>> Consider the following: >>> >>> \!\(\(\(\ \)\(Assuming[x > 0 && A > 0 && B > 0 && \ B < 1, \ >>> FullSimplify[Integrate[Log[\@\(A^2 + x\^2\) - B*x\ ], \ x]]]\) >>> \)\) >>> >>> The answer that I get is correct, but not very useful since it is >>> appears complex and I could find a way to determine the real >>> part. Do >>> you have any suggestions? > > For mine, see the end of this post. > >> Hi Aaron, >> >> What version of Mathematica do you use? With Mathematica 5.2 I do not >> get any complex numbers for your integral. > > Yes, you do. The mere fact that /I/ does not appear in the > expression does > not mean that it is necessarily real. While there may be some special > values of A, B, and x which cause Out[1] to be real, it is generally > complex. > >> In[1]:= >> Assuming[x > 0 && A > 0 && B > 0 && B < 1, >> FullSimplify[Integrate[Log[Sqrt[A^2 + x^2] - B*x], x]]] >> >> Out[1]= >> 1 2 2 2 >> --------------- (2 Sqrt[-1 + B ] x (-1 + Log[-B x + Sqrt[A + x ]]) + >> 2 >> 2 Sqrt[-1 + B ] >> >> 2 >> Sqrt[-1 + B ] x >> A (2 ArcTanh[---------------] - 4 Log[A] - 4 Log[B] + >> A >> >> 2 >> 2 2 >> 4 (-1 + B) (1 + B) (A Sqrt[-1 + B ] - x + B Sqrt[A >> + x ]) >> >> Log[-(----------------------------------------------------------)] + >> 2 2 >> A Sqrt[-1 + B ] + (-1 + B ) x >> >> 2 2 2 2 >> (-1 + B ) (A Sqrt[-1 + B ] + x + B Sqrt[A + x ]) >> Log[-------------------------------------------------])) >> 2 2 >> A Sqrt[-1 + B ] + x - B x >> >> In[2]:= >> FreeQ[%, I] >> >> Out[2]= >> True > [snip] > > My suggestion is that you get an antiderivative using some work > done by > hand. My result is > > x*(Log[Sqrt[A^2 + x^2] - B*x] - 1) + > A/Sqrt[1 - B^2]*(ArcCot[A*B/Sqrt[(1 - B^2)*(A^2 + x^2)]] + > ArcTan[Sqrt[1 - B^2]*x/A]) > > the correctness of which is easily checked using Mathematica: > > In[1]:= FullSimplify[D[x*(Log[Sqrt[A^2 + x^2] - B*x] - 1) + > A/Sqrt[1 - B^2]*(ArcCot[A*B/Sqrt[(1 - B^2)*(A^2 + x^2)]] + > ArcTan[Sqrt[1 - B^2]*x/A]), x], x > 0 && A > 0 && 0 < B < 1] > > Out[1]= Log[(-B)*x + Sqrt[A^2 + x^2]] > > Note that my antiderivative is not only real, but all its > subexpressions > are real. Can anyone get Mathematica to find such an antiderivative > directly? > > David > I do not think it is reasonable to expect a computer program to arrive at the same answer you managed to get by hand. As you know very well symbolic algebra programs work quite differently from human mathematicians and peronally I think it a complete waste of time to try to torture them into returning answers that you already managed to get by hand. Having said that, I think it is a reasonable aim to try to get a "real" antiderivative when you can be sure that one exists. In such a case you can proceed as follows: expr = ComplexExpand[Re[Integrate[Log[Sqrt[A^2 + x^2] - B*x], x]], TargetFunctions -> {Re, Im}]; I would not wish to even look at expr since I expect it to fairly unpleasant. However, it is certainly real for all real values of A, B, x. We can also make it reasonably simple without even using FullSimplify (which will take far too long for my patience): expr1 = Refine[expr, x > 0 && A > 0 && B > 0 && B < 1] (A*ArcTan[(Sqrt[1 - B^2]*x)/A]*(1 - B^2)^(3/2))/ (B^2 - 1)^2 + (A*ArcTan[((A*(1 - B^2)^(3/2)*(B^2 - 1)*x)/ ((1 - B^2)*A^2 + (B^2 - 1)^2*x^2) - (A*(1 - B^2)^(3/2)*(B*Sqrt[A^2 + x^2] - x))/ ((1 - B^2)*A^2 + (B^2 - 1)^2*x^2))/ ((A^2*(1 - B^2)^2)/((1 - B^2)*A^2 + (B^2 - 1)^2*x^2) + ((B^2 - 1)*x* (B*Sqrt[A^2 + x^2] - x)*(1 - B^2))/ ((1 - B^2)*A^2 + (B^2 - 1)^2*x^2))]* (1 - B^2)^(3/2))/(2*(B^2 - 1)^2) + (1/(2*(B^2 - 1)^2))* (A*ArcTan[((1 - B^2)*(B^2 - 1)*A^2)/((1 - B^2)*A^2 + (x - B^2*x)^2) + ((B^2 - 1)*(x - B^2*x)* (Sqrt[A^2 + x^2]*B + x))/((1 - B^2)*A^2 + (x - B^2*x)^2), (A*Sqrt[1 - B^2]*(B^2 - 1)* (x - B^2*x))/((1 - B^2)*A^2 + (x - B^2*x)^2) - (A*Sqrt[1 - B^2]*(B^2 - 1)*(Sqrt[A^2 + x^2]*B + x))/ ((1 - B^2)*A^2 + (x - B^2*x)^2)]* (1 - B^2)^(3/2)) - x + x*Log[Sqrt[A^2 + x^2] - B*x] O.K. it is not as simple as what you got by hand but it is certainly real. Moreover, if we are sure that the is a real anti-derivative than this must be it. And indeed: FullSimplify[D[expr1, x], x > 0 && A > 0 && B > 0 && B < 1] Log[Sqrt[A^2 + x^2] - B*x] Andrzej Kozlowski
- References:
- Re: Why does this lead to an answer with complex numbers?
- From: "David W. Cantrell" <DWCantrell@sigmaxi.net>
- Re: Why does this lead to an answer with complex numbers?