In a message dated 1/15/02 4:40:14 AM, jhelfand at wam.umd.edu writes:
>I have a thing about Mathematica. Sometimes I have a real long
>expression that involves the integral of the sum of lots of cosines and
>sines of some variable let's say 't'. But having done some fancy maths
>on my own to reduce it and get into a simple integral from 0 to 2 Pi,
>and the sines and cosines all involve some integer multiple of t, the
>integration takes for ever, it basically hangs. Now, although the
>expression is long, and there are a lot of terms in it, it still just
>becomes a simple periodic integral from zero to 2 pi, and all the
>trigonometric terms involving t should just drop out. Kind of like what
>sometimes can happen if you are playing around with a Fourier series
>expansion (by the way, does Mathematica have a built in Fourier Series
>expansion? I mean something like Series[], but returns fourier
>coefficients?). Uptill now, I have been able to get by with something
>like using
>
>periodicIntegral={Cos[t] -> 0, Cos[2 t] -> 0, Cos[3 t] -> 0, Cos[4 t] ->
>0, Cos[5t] -> 0, Cos[6 t] -> 0, Cos[7 t] -> 0, Sin[t] -> 0, Sin[2 t] ->
>0, Sin[3 t] -> 0, Sin[4 t] -> 0, Sin[5t] -> 0, Sin[6 t] -> 0, Sin[7 t]
>-> 0};
>
>and then doing a replace on the expresion, multiplying the result by 2
>Pi. But now I am in a bind where no amount of TrigReduce, TrigExpand,
>TrigFactor, etc. will get this big ass expression into the desired form
>where the above is approriate (because there are other sines and cosines
>of other variables that get put into the terms and stand by
>themselves). Still, the expression should be easy to do for the
>computer, even I can go through and set these terms to zero, but it will
>just take me a long time. An example of what I am talking about, just
>try the following:
>
>In[687]:=
>Joe = a c Cos[t]/(g s) + b q Cos[2 t]/(c f) + c Cos[3 t]/(d a) +
> d f Cos[4 t]/(h a n) + e q Cos[5t]/(g a) + f l Cos[6 t]/(w r m) +
> g b Cos[7 t]/(o n x) + h Sin[t]/(b c) + i Sin[2 t]/(h e r) +
> j y Sin[3 t]/(l p) + d k Sin[4 t]/(j c) + l m a Sin[5 t]/(f s b h)
>+
> m p Sin[6 t]/(k j) + q n Sin[7 t]/(x c);
>
>In[688]:=
>Integrate[Joe, {t, 0, 2 Pi}]
>
>and you willl see it takes a long time to integrate. (It will
>eventually get done.) I know this is just zero, but why does it take so
>long for the computer to figure out? It is true that my expression is
>even longer than this one, so essentially it hangs, but basically it is
>the same problem. I do not what to be hunting through my equation from
>hell setting all the relevant trigonometric terms to zero when the
>computer should be able to do this. Well, sorry for the harangue but I
>greatly appreciate you reading down so far, really. If you have any
>suggestions or comments, point out I am an idiot there is some simple
>thing in Mathematica, please send it.
Needs["Calculus`FourierTransform`"];
FourierSeries[t, t, 3]
E^(2*I*Pi*t)*((1 - I*Pi)/(4*Pi^2) - (1 + I*Pi)/(4*Pi^2)) +
(-((1 - I*Pi)/(4*Pi^2)) + (1 + I*Pi)/(4*Pi^2))/
E^(2*I*Pi*t) + ((1 - 2*I*Pi)/(16*Pi^2) -
(1 + 2*I*Pi)/(16*Pi^2))/E^(4*I*Pi*t) +
E^(4*I*Pi*t)*(-((1 - 2*I*Pi)/(16*Pi^2)) +
(1 + 2*I*Pi)/(16*Pi^2)) + E^(6*I*Pi*t)*
((1 - 3*I*Pi)/(36*Pi^2) - (1 + 3*I*Pi)/(36*Pi^2)) +
(-((1 - 3*I*Pi)/(36*Pi^2)) + (1 + 3*I*Pi)/(36*Pi^2))/
E^(6*I*Pi*t)
% // ExpToTrig
Sin[2*Pi*t]/Pi - Sin[4*Pi*t]/(2*Pi) + Sin[6*Pi*t]/(3*Pi)
FourierTrigSeries[t, t, 3]
Sin[2*Pi*t]/Pi - Sin[4*Pi*t]/(2*Pi) + Sin[6*Pi*t]/(3*Pi)
Joe=a c Cos[t]/(g s)+b q Cos[2 t]/(c f)+
c Cos[3 t]/(d a)+d f Cos[4 t]/(h a n)+
e q Cos[5t]/(g a)+f l Cos[6 t]/(w r m)+
g b Cos[7 t]/(o n x)+h Sin[t]/(b c)+
i Sin[2 t]/(h e r)+j y Sin[3 t]/(l p)+
d k Sin[4 t]/(j c)+l m a Sin[5 t]/(f s b h)+
m p Sin[6 t]/(k j)+q n Sin[7 t]/(x c);
Head[Joe]
Plus
Integrate term-by-term and sum the results
Tr[Integrate[#, {t,0,2Pi}]& /@ (List @@ Joe)]//Timing
{0.08999999999999986*Second, 0}
Bob Hanlon
Chantilly, VA USA