Re: What's wrong with this integral in mathematica?
- To: mathgroup at smc.vnet.net
- Subject: [mg60699] Re: What's wrong with this integral in mathematica?
- From: Peter Pein <petsie at dordos.net>
- Date: Sun, 25 Sep 2005 02:36:09 -0400 (EDT)
- References: <dh0fkt$qgp$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
kiki schrieb:
> Hi all,
>
> I am evaluating this integral:
>
> \!\(Integrate[\(\[ExponentialE]\^\(\[ImaginaryI]\ a\ z\)\ Sinh[z]\)\/\((b +
> \
> Cosh[z])\)\^2, {z, \(-?\), ?}, Assumptions \[Rule] \ {a > 0, b > 1}]\)
>
> After 1 hour running, it generates the following huge result: (after
> simplification)
>
> But even using my pencil and paper, do it manually, I should get much
> simpler result...
>
> Can anybody tell me what's wrong?
>
> ---------------------------------------------------
>
...
Hi kiki,
as I will demonstrate later, it seems to me that the result is correct
(verified only for one (a,b) pair).
But let's have a look, how we can get concise results in less time.
In[1]:=
$Assumptions = {{a, c} \[Element] Reals, Re[ia] == 0,
b > 1, a != 0, c != 0, t > 0};
(* We want short results - try what happens with: *)
SetOptions[Simplify, ComplexityFunction ->
(StringLength[ToString[TraditionalForm[#1]]]&)];
f0 = (E^(I*a*z)*Sinh[z])/(b + Cosh[z])^2;
fz = f0 /. {a -> ia/I, b -> Cosh[c]}
Out[4]=
(E^(ia*z)*Sinh[z])/(Cosh[c] + Cosh[z])^2
In[5]:=
(* Let us calculate a specific value, to see if transformations succeed *)
testval = NIntegrate[f0 /. {a -> 0.6, b -> 1.},
{z, -Infinity, Infinity}, PrecisionGoal -> MachinePrecision,
WorkingPrecision -> (6/5)*MachinePrecision, SingularityDepth -> 6,
MaxRecursion -> 6]//N//Chop
Out[5]= 0.7030982915694148*I
In[6]:=
(* give Mathematica a hint, how to substitute *)
ft=(fz Dt[z]/.z->Log[t])/.Dt[t]->1//Simplify
Out[6]=
(2*t^ia*(-1 + t^2))/(1 + t^2 + 2*t*Cosh[c])^2
In[7]:= (* still the same? *)
test2 = NIntegrate[ft /. {ia -> 0.6*I, c -> 0}, {t, 0, Infinity},
SingularityDepth -> 6, MaxRecursion -> 8,
WorkingPrecision -> (6/5)*MachinePrecision,
PrecisionGoal -> MachinePrecision]]]
Out[7]= 0.7030982915694148*I
In[8]:= testval === test2
Out[8]= True
In[9]:=(* that's fine! Now integrate : *)
{tim, it} = Timing[Integrate[ft, {t, 0, Infinity}]];
it
tim
Out[10]= 2*ia*Pi*Csc[ia*Pi]*Csch[c]*Sinh[c*ia]
Out[11]= 25.219*Second
In[12]:=(* this has been surprisingly fast compared to an hour :-))
To check the result, do the backsubs :*)
iz = FullSimplify[ExpandAll[it /. {ia -> I*a, c -> ArcCosh[b]}]]
Out[12]=
(2*I*a*Pi*Csch[a*Pi]*Sin[a*ArcCosh[b]])/Sqrt[-1 + b^2]
In[13]:= (* we can not simply substitute our test-b here -
take the Limit: *)
izb1 = Limit[iz, b -> 1]
Out[13]=
2*I*a^2*Pi*Csch[a*Pi]
In[14]:= testexact = Chop[N[izb1 /. a -> 3/5]]
Out[14]= 0.7030982915694148*I
In[15]:= testval === testexact
Out[15]= True
I'll omit the following line of input, to save space. Your impressive
huge result will be assigned to a variable "wow".
In[18]:= FullSimplify[Limit[wow /. a -> 3/5, b -> 1]]
Out[18]= (18/25)*I*Pi*Csch[(3*Pi)/5]
looks good
In[19]:= Chop[N[%]]
Out[19]= 0.7030982915694148*I
In[20]:= % === testval
Out[20]= True
Phew! This has been a long message to come to a short answer to your
question:
_most_likely_ nothing.
Peter
--
Peter Pein, Berlin
GnuPG Key ID: 0xA34C5A82
http://people.freenet.de/Peter_Berlin/