pythonodetaylor-series

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

Solution

  • 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.