Is there a way to force Maple to do this integral numerically? Analytically
it is hard to get correctly (can be easily solved though using residue
theorem; 2 i Pi *sum of residues).
So I tried it numerically, but Maple does not do it. (Maple 10.4)
>restart;
> f := x-> exp(cos(X)) * cos(x-sin(x)):
> evalf(Int(f(x),x=0..2*Pi));
May be there is a trick or an option I am overlooking?
btw, the answer is supposed to be (from Mathematica) the following: (5.2
version)
f[x_] := E^Cos[x]*Cos[x - Sin[x]];
NIntegrate[f[x], {x, 0, 2*Pi}]
6.28319
I would have thought that numerically Maple should be able to do it as well?
btw, Mathemtica gets the above integral wrong analytically, it gives zero,
and I was just curious to see if Maple can do it analytically or not. Maple
does not give a wrong answer analytically but returns the integral
unevaluated (which is better than giving the wrong answer).
I wonder if there a CAS that can do the above analytically? may be you can
try the above on your favorite CAS and see which one can do it. The winner
will be win a prize to be decided later.
thanks,
Nasser
> Hello;
>
> Is there a way to force Maple to do this integral numerically? Analytically
> it is hard to get correctly (can be easily solved though using residue
> theorem; 2 i Pi *sum of residues).
>
> So I tried it numerically, but Maple does not do it. (Maple 10.4)
>
>>restart;
>> f := x-> exp(cos(X)) * cos(x-sin(x)):
>> evalf(Int(f(x),x=0..2*Pi));
Try fixing the type (X --> x).
--
Joe Riel
x and X is not the same.
>restart;
f := x-> exp(cos(x)) * cos(x-sin(x));
f := x -> exp(cos(x)) cos(x - sin(x))
evalf(Int(f(x),x=0..2*Pi));
6.283185307
> "Nasser Abbasi" <n...@12000.org> writes:
>
>> Hello;
>>
>> Is there a way to force Maple to do this integral numerically? Analytically
>> it is hard to get correctly (can be easily solved though using residue
>> theorem; 2 i Pi *sum of residues).
>>
>> So I tried it numerically, but Maple does not do it. (Maple 10.4)
Expanding the expression allows Maple to get a symbolic answer:
int(expand(exp(cos(x)) * cos(x-sin(x))), x=0..2*Pi);
2*Pi
--
Joe Riel
Thanks Joe.
I tried the above trick also in Mathematica, and that made it solve it
analytically as well.
But there is a bug here in Matematica, I think I should make a bug report on
this. It gives zero without the expand, and 2Pi with the expand. This is
clearly wrong, usually Mathematica returns something unevaluated if it can't
do it, but not in this case:
Integrate[E^Cos[x] * Cos[ x - Sin[x] ], {x, 0, 2*Pi}]
0
Integrate[E^Cos[x] * TrigExpand[ Cos[ x - Sin[x] ] ], {x, 0, 2*Pi}]
2 Pi
and sorry everyone about the typo I had in the Maple code I posted, ofcourse
X and x are not the same, I knew Maple should be able to do this at least
numerically.
Nasser
It is a simple typo - note that maple distinguishes small from capital
letters (i.e. x is different variable than X and exp(cos(_X_) was your
problem).
here's a corrected code code snippet:
restart;
f := x-> exp(cos(x)) * cos(x-sin(x)):
int(f(x),x=0..2*Pi);
evalf(int(f(x),x=0..2*Pi));
It's interesting that TrigExpand helped in that case.
Mathematica will also give a result for the indefinite integral, but
unfortunately that result has needless jump discontinuities at odd
multiples of Pi. Using TrigExpand does not help the indefinite integral:
In[4]:= Integrate[E^Cos[x]*TrigExpand[Cos[x - Sin[x]]], x]
Out[4]= (1/2)*I*(E^(E^(I*x) - I*x) - E^(E^((-I)*x) + I*x) +
ExpIntegralEi[E^((-I)*x)] - ExpIntegralEi[E^(I*x)])
However, modifying that result by hand, adding
Pi*(Floor[(x + Pi)/(2*Pi)] + Ceiling[(x - Pi)/(2*Pi)]), we then get an
antiderivative which is valid over the whole real line:
Pi*(Floor[(x + Pi)/(2*Pi)] + Ceiling[(x - Pi)/(2*Pi)]) +
(1/2)*I*(E^(E^(I*x) - I*x) - E^(E^((-I)*x) + I*x) +
ExpIntegralEi[E^((-I)*x)] - ExpIntegralEi[E^(I*x)])
Will Maple also evaluate the indefinite integral? If so, does its result
also have needless jump discontinuities?
David W. Cantrell
>
> It's interesting that TrigExpand helped in that case.
>
> Mathematica will also give a result for the indefinite integral, but
> unfortunately that result has needless jump discontinuities at odd
> multiples of Pi. Using TrigExpand does not help the indefinite integral:
>
> In[4]:= Integrate[E^Cos[x]*TrigExpand[Cos[x - Sin[x]]], x]
>
> Out[4]= (1/2)*I*(E^(E^(I*x) - I*x) - E^(E^((-I)*x) + I*x) +
> ExpIntegralEi[E^((-I)*x)] - ExpIntegralEi[E^(I*x)])
>
> However, modifying that result by hand, adding
> Pi*(Floor[(x + Pi)/(2*Pi)] + Ceiling[(x - Pi)/(2*Pi)]), we then get an
> antiderivative which is valid over the whole real line:
>
> Pi*(Floor[(x + Pi)/(2*Pi)] + Ceiling[(x - Pi)/(2*Pi)]) +
> (1/2)*I*(E^(E^(I*x) - I*x) - E^(E^((-I)*x) + I*x) +
> ExpIntegralEi[E^((-I)*x)] - ExpIntegralEi[E^(I*x)])
>
> Will Maple also evaluate the indefinite integral? If so, does its result
> also have needless jump discontinuities?
>
> David W. Cantrell
"Will Maple also evaluate the indefinite integral? "
Not if you do not do an expand() in front (same as Mathematica)
restart;
int(exp(cos(x)*cos(x-sin(x))),x);
"echo above unevaluated"
But with expand() first, It seems the result below matchs your's
> int(expand(exp(cos(x)) * cos(x-sin(x))),x);
1/2 I exp(exp(x I)) exp(-I x) + 1/2 I Ei(1, -exp(x I)) - 1/2 I exp(x I)
exp(exp(-I x)) - 1/2 I Ei(1, -exp(-I x))
btw, I learned from a good source that next major release of Mathematica,
V6.0 has this fixed, and now it will solve the problem correctly without
having to do expand:
In[1]:= $Version
Out[1]= "6.0 for Microsoft Windows (32-bit) (October 10, 2006)"
In[2]:= Integrate[E^Cos[x]*Cos[x - Sin[x]], {x, 0, 2*Pi}]
Out[2]= 2 Pi
One more reason to look forward for Mathematica V6.0 :)
Nasser
Just a thought: Assuming that you are legally enrolled in a beta program
with Wolfram Research Inc., what you wrote above looks like a breach of
confidentiality as stated by the NDA (Non Disclosure Agreement) you must
have agreed to and signed, doesn't it?
Jean-Marc
In[1]:= Integrate[Exp[Cos[x]]*Cos[x-Sin[x]], {x,0,2*Pi}]
Out[1]= 2 Pi
In[2]:= NIntegrate[Exp[Cos[x]]*Cos[x-Sin[x]], {x,0,2*Pi}]
Out[2]= 6.28319
Bhuvanesh,
Wolfram Research.
equ = Exp[Cos[x]]*Cos[x - Sin[x]];
2*Pi - NIntegrate[equ, {x, 0, 2*Pi}]
1.3322676295501878*^-13
2*Pi - NIntegrate[equ, {x, 0, 2*Pi}, Method -> Trapezoidal]
0.
--
HTH :>)
Dana
Windows XP & Mma 5.2
"Bhuvanesh" <lalu_...@yahoo.com> wrote in message
news:11368157.1161105904...@nitrogen.mathforum.org...