Maple returns the same. That is not to say that sympy shouldn't try to
do better than maple here, but I think this is a hard problem. You
need to do the special case yourself.

Inn=integrate(f1*f1,(x,0,2*pi))
Imn=integrate(f1*f2,(x,0,2*pi))
I=Piecewise((Inn,Eq(m-n,0)),(Imn,True))
pprint(I)

⎧π  for m - n = 0
⎨
⎩0    otherwise

Cheers,
Julien

On Feb 22, 2:54 pm, Mamba <[email protected]> wrote:
> Hi,
>
> I am new in sympy. I would like to calculate the integration of
> cos(nx)*cos(mx) on the interval [0,2pi].
> I expected the following result : I=0 if n!=m and I!=0 if m=n but the
> result is only 0 without distinction between the values of m and n.
>
> I used that piece of code in ipython
>
> from sympy import  *
> x=Symbol('x')
> n=Symbol('n',integer=True)
> m=Symbol('m',integer=True)
> f1=cos(n*x)
> f2=cos(m*x)
> f3=f1*f2
> I=integrate(f3,(x,0,2*pi))
> pprint(I)
> 0
>
> Did I do something wrong ? What is the good way to obtain the correct
> answer ?
>
> Best Regards,
>
> Régis

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to