# Why summation of sine function doesn't give the expected result?

Having function v(x,a) - velocity for simple harmonic movement - as described below: If I do the summation like this: The result is 31.97. I would expect it as 32 instead. Why I still get the approximated result? If I keep increasing the a parameter the summation becomes more and more away from 32.

Edit:

I realized I didn't give too much context of what I am trying to achieve, so here it is:

I am trying to simulate a simple harmonic movement (a platform going up and down, repeatedly), so I thought would be a good idea to use sine/cosine functions to go about this.

So my constraint for a graph of Position x Frames (time) would look like this:  As you can see, the maximum amplitude point of this wave is between 32 and -32.

But I simply cannot assign the position directly (limitations of the program I am using), instead, I have to set the velocity. The velocity is always 60x the position. That means if I assign 1 to the velocity during 1 frame, the displacement will be 1/60 = 0.01666666666666667. 60 is the number of frames per second.

So the first function v(x, a) was my first attempt to make sure, after N cycles the maximum displacement would be always 32. So I don't know what function I should use to have a result displacement (summation) of 32.

I hope I made my question a bit more clear, thanks for relentless help.

• Why would you expect it to be $32$? – Matt Samuel Nov 8 '19 at 12:35
• On the other hand, we can be quite sure that $\sum_{n=1}^{30}\frac{\nu(n,2)}{60}=32\frac{\pi}{60}\sum_{k=1}^{30}\sin\frac{n\pi }{30}$ is a multiple of $\pi$ by the algebraic number $\frac{32}{60}\sum_{n=1}^{30}\sin\frac{n\pi}{30}$, and therefore it is not $32$. – Gae. S. Nov 8 '19 at 12:38
• Have a look at my edit. – Claude Leibovici Nov 10 '19 at 4:32

You are facing the sum of sines where the angles are in arithmetic progression. If you apply the formula, you will notice that $$\frac{32\pi}{60}\sum_{k=1}^{30}\sin\left(\frac{n\pi }{30}\right)=\frac{8\pi}{15} \cot \left(\frac{\pi }{60}\right)$$ We do not know the values of the trigonometric function for such an angle.

Since te argument is small, let us use the usual Taylor series $$\cot(x)=\frac{1}{x}-\frac{x}{3}-\frac{x^3}{45}-\frac{2 x^5}{945}+O\left(x^7\right)$$ Replacing $$x$$ by $$\frac{\pi }{60}$$ will lead to $$32-\frac{2 \pi ^2}{675}-\frac{\pi ^4}{18225000}-\frac{\pi ^6}{688905000000}$$

Edit

Considering that we look for

$$S(a)=\frac{4}{15} \pi a\sum_{x=1}^{30}\sin \left(\frac{\pi a x}{60}\right)=\frac{2}{15} \pi a \left(\cot \left(\frac{\pi a}{120}\right)-\cos \left(\frac{61 \pi a}{120}\right) \csc \left(\frac{\pi a}{120}\right)\right)$$ and that we want the result to be as close as possible to $$32$$,we can minimize $$\Phi(a)=|S(a)-32|$$ which leads to $$a_{opt}=1.96703696\qquad \text{and} \qquad S(a_{opt})=31.99292724$$

• Great, if I need to find a value for "a" that result in a sum result of 32, how would I go about it? – raphaklaus Nov 8 '19 at 14:56
• @raphaklaus. Could you provide the exact summation for the general case ? Is it always from $1$ to $30$ ? Is the result always divided by $60$ ? – Claude Leibovici Nov 8 '19 at 15:11
• Sorry, I didn't give the context. I am simulating a simple harmonic movement with this function. The first function I tried to calculate the velocity in a way that the maximum position will be always 32, but found out that it was not right. I divide by 60 in the summation because it is the number of frames per second. Every result of the velocity divided by 60 is the amount of displacement in the Y axis is going to happen per frame. – raphaklaus Nov 9 '19 at 9:19
• @raphaklaus. You did not answer my question. – Claude Leibovici Nov 9 '19 at 9:22
• 1 to 30 because 30 represents the Period (T). Always divided by 60 because I have to know the total displacement per frame. – raphaklaus Nov 9 '19 at 11:06