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

101 Views Asked by At

Having function v(x,a) - velocity for simple harmonic movement - as described below:

enter image description here

If I do the summation like this:

enter image description here

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:

enter image description here

enter image description here

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.

1

There are 1 best solutions below

6
On

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