Taylor series for pendulum in python


I have a question from school to simulate pendulum motion based on taylor series expansion.

Angular frequency d 2 θ d t 2 = − m G R I sin ⁡ ( θ )

I am quite new to python. I know now how to simulate using Euler’s method.

  for n in range(N_t):

  u[n+1] = u[n] + dt*v[n]

  v[n+1] = v[n] + dt*(m*g*r/I)*sin(u[n])

How can I simulate it using taylor expansion?
Should I run it the code only as below?

f′′(x0) = 2a2


I assume you meant this from your code,

enter image description here

I also assume that u := θ and v := θ’.

So, the Taylor expansion of sin(x) is

enter image description here

and your equation is now

enter image description here

So, you can calculate u and v from the above equation. Or, I don’t know if your teacher wanted you to calculate the integrals first and then use Taylor series.

Answered By – Mochan

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published