1 # Pendulum: Comparing Harmonic Oscillator with 4th order Taylor approximation
3 ### Taylor 4 approximation: phi'' = - g/r * (phi - 1/6 * phi^3)
4 # fortunately, the components of orders 0, 2 and 4 are zero
7 coefficient.2 -> 1/6 # set to 0,167 or 0 (for harmonic solution)
8 coefficient.3(-1) -> -phi0
10 iintegrate phi'' -> -phi'
11 iintegrate -phi' -> phi
14 multiply phi, phi -> phi^2
15 multiply phi^2, phi -> phi^3
16 invert phi^3 -> -phi^3
18 cmultiply 1/6, -phi^3 -> -1/6*phi^3
19 isum phi, -1/6*phi^3 -> -(phi-1/6*phi^3)
20 cmultiply -(phi-1/6*phi^3), g/r -> -g/r*(phi-1/6*phi^3)
21 assign -g/r*(phi-1/6*phi^3) -> phi''
25 ### Harmonic oscillator: phi'' = - g/r * phi
26 coefficient.5 -> g/r_h # identical to g/r
27 coefficient.7(-1) -> -phi0_h # identical to -phi0
29 iintegrate phi_h'' -> -phi_h'
30 iintegrate -phi_h' -> phi_h
32 invert phi_h -> -phi_h
34 cmultiply -phi_h, g/r_h -> -g/r*phi_h
35 assign -g/r*phi_h -> phi_h''