Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

a hard integral for CAS systems to solve analytically?

1 view
Skip to first unread message

Nasser Abbasi

unread,
Oct 14, 2006, 5:34:08 PM10/14/06
to
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));

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


Joe Riel

unread,
Oct 14, 2006, 6:25:09 PM10/14/06
to
"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)
>
>>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

Roman

unread,
Oct 14, 2006, 6:32:49 PM10/14/06
to

Nasser Abbasi schrieb:

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

Joe Riel

unread,
Oct 14, 2006, 6:38:41 PM10/14/06
to
Joe Riel <jo...@k-online.com> writes:

> "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

Nasser Abbasi

unread,
Oct 15, 2006, 12:52:22 AM10/15/06
to

"Joe Riel" <jo...@k-online.com> wrote in message
news:87zmby5...@k-online.com...

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

kilian heckrodt

unread,
Oct 16, 2006, 11:42:37 AM10/16/06
to
Nasser Abbasi wrote:
> 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));
>
> May be there is a trick or an option I am overlooking?
>

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));

David W. Cantrell

unread,
Oct 16, 2006, 1:02:06 PM10/16/06
to

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

Nasser Abbasi

unread,
Oct 16, 2006, 5:55:42 PM10/16/06
to

"David W. Cantrell" <DWCan...@sigmaxi.net> wrote in message
news:20061016130249.149$1...@newsreader.com...

>
> 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


Jean-Marc Gulliet

unread,
Oct 17, 2006, 12:04:44 PM10/17/06
to
Nasser Abbasi wrote:
> 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

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

Bhuvanesh

unread,
Oct 17, 2006, 1:24:34 PM10/17/06
to
This works fine in our development version of Mathematica. It's actually been correct for many months now.

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.

Dana DeLouis

unread,
Nov 27, 2006, 11:59:25 AM11/27/06
to
Just another idea to try and improve the error from 2 Pi.

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...

0 new messages