# Sum of cosines

Discussion in 'Maple' started by I.N. Galidakis, Jan 28, 2010.

1. ### I.N. GalidakisGuest

I have a sum of cosines with different arguments and I need to combine them so I
can estimate the period. Can this be done with Maple 9?

I think this question has been asked before, but I cannot find it in Google.

For example, can I combine the following into the form cos(A+B+C+...+W)?

cos(9.519977738*t)+cos(4.146902303*t)+cos(18.84955592*t)+cos(2.094395103*t)+cos(
..3141592654e16*t)+cos(471.2388981*t)+cos(314.1592654*t)

Thanks,

I.N. Galidakis, Jan 28, 2010

2. ### ArchimedesGuest

This "works" in Maple 9.5, but if you increase Digits to a higher
value, it does not work(not a simpler version than what you started
with). Check the accuracy to make sure it is acceptable for your
needs. For values of `t` greater than what I plotted, you can not see
the difference.
This yields: cos(.3141592654e16*t)+6.

Archimedes, Jan 29, 2010

3. ### I.N. GalidakisGuest

Thanks. It works on Maple 9 I.N. Galidakis, Jan 29, 2010
4. ### Robert IsraelGuest

I assume these frequencies are not supposed to be exact, but rather are
approximations to rational multiples of Pi. That makes a big difference.

Interestingly, identify can handle all the frequencies except one that is
most obvious to the eye:
+cos(2.094395103*t)+cos(.3141592654e16*t)+cos(471.2388981*t)
+cos(314.1592654*t);

cos(100/33*Pi*t)+cos(33/25*Pi*t)+cos(6*Pi*t)+cos(2/3*Pi*t)
+cos(.3141592654e16*t)+cos(150*Pi*t)+cos(100*Pi*t)

So it looks like the periods of the different cosine terms are
33/50, 50/33, 1/3, 3, 1/500000000000000, 1/75 and 1/50. Put over
a common denominator 16500000000000000, the numerators are
10890000000000000, 25000000000000000, 5500000000000000, 49500000000000000,
33, 220000000000000, 330000000000000
which have least common multiple 27225000000000000000.
Thus the minimal period is 27225000000000000000/16500000000000000
= 1650.

Robert Israel, Jan 29, 2010
5. ### I.N. GalidakisGuest

Yes, that's what they are. Or rather, what they were, when I was trying to
figure out a minimum period of the phasor:

p(t)=sum(exp(2*Pi*i*N_j*t),j=1..7)

Unfortunately, it seems that any oscillator vibrating at N_j, vibrates also at
all the harmonics, so the phasor is really:

q(t)=sum(sum(exp(2*Pi*i*k*N_j*t),j=1..7),k=1..oo)

(which is, I think, 7 separate Fourier series added together)

Thanks,

I.N. Galidakis, Jan 29, 2010
6. ### I.N. GalidakisGuest

Robert,

It doesn't look like it's working. I get with Maple 9:
with N[j] loaded with the aforementioned values:

N:=33/50;
N:=50/33;
N:=1/3;
N:=3;
N:=5*10^14;
N:=75;
N:=50;

and then:

evalf(fs(0.2)),evalf(fs(0.2+1650));

3.438304986+1.671248677*I, 2.223885744+2.474913511*I

What am I doing wrong?

I.N. Galidakis, Jan 30, 2010
7. ### Axel VogtGuest

Just tested with Maple 9.52 and it works (even if using
only Digits=10). Have you tried after a restart?

Axel Vogt, Jan 30, 2010
8. ### I.N. GalidakisGuest

Looks like it's an accuracy issue. I increased Digits:=50 and it works. For some
reason it doesn't work with the default number of digits.

Thanks,

I.N. Galidakis, Jan 30, 2010
9. ### Axel VogtGuest

May the versions work a bit different. Might it be that later versions
for evalf( f(t) ) try a simplification first and take floats later?

If you use 2/10 instead of 0.2 then you should see, that both terms
are equal.

Axel Vogt, Jan 30, 2010
10. ### I.N. GalidakisGuest

Yes, it does! The problem seems to be that I had on my worksheet:

and this affects N as well. Then the arguments in the phasor are a bunch of
floats. If I use fractions instead, Maple puts fractions on the phasor and then
it works, if I also have 2/10 for 0.2.

The world of floating point is strange indeed! Try it with N:=1/0.66,
N:=1/N and see what you get on

evalf(fs(0.2)),evalf(fs(0.2+1650));

Thanks Alex,

I.N. Galidakis, Jan 30, 2010