--- /dev/null
+# Pendulum: Comparing Harmonic Oscillator with 4th order Taylor approximation
+
+### Taylor 4 approximation: phi'' = - g/r * (phi - 1/6 * phi^3)
+# fortunately, the components of orders 0, 2 and 4 are zero
+
+coefficient.1 -> g/r
+coefficient.2 -> 1/6 # set to 0,167 or 0 (for harmonic solution)
+coefficient.3(-1) -> -phi0
+
+iintegrate phi'' -> -phi'
+iintegrate -phi' -> phi
+ IC: -phi0
+
+multiply phi, phi -> phi^2
+multiply phi^2, phi -> phi^3
+invert phi^3 -> -phi^3
+
+cmultiply 1/6, -phi^3 -> -1/6*phi^3
+isum phi, -1/6*phi^3 -> -(phi-1/6*phi^3)
+cmultiply -(phi-1/6*phi^3), g/r -> -g/r*(phi-1/6*phi^3)
+assign -g/r*(phi-1/6*phi^3) -> phi''
+
+output phi -> out.x
+
+### Harmonic oscillator: phi'' = - g/r * phi
+coefficient.5 -> g/r_h # identical to g/r
+coefficient.7(-1) -> -phi0_h # identical to -phi0
+
+iintegrate phi_h'' -> -phi_h'
+iintegrate -phi_h' -> phi_h
+ IC: -phi0_h
+invert phi_h -> -phi_h
+
+cmultiply -phi_h, g/r_h -> -g/r*phi_h
+assign -g/r*phi_h -> phi_h''
+
+output phi_h -> out.y
--- /dev/null
+# Harmonic Oscillator
+# A mass m is subject to a force F=-k*r.
+# What is the trajectory if the mass starts at position (a,0,0)?
+# How much time does it take to pass through zero?
+# What is the trajectory if it starts at (a,0,0) with velocity (0,v0,0)?
+# Compare to the case including gravity on earth in x direction
+# m*x'' = -k*x + g
+# m*y'' = -k*y (z can be set to 0).
+
+coefficient.1(-1) -> -a # (a,0,0), has to be negative because x' is negative
+coefficient.2 -> k/m_x # k/m for x
+coefficient.3(+1) -> v0 # (0,v0,0), has to be positive because y'' is positive
+coefficient.4 -> k/m_y # k/m for y, identical to k/m for x
+coefficient.5(-1) -> -g # g
+
+iintegrate x'' -> -x'
+iintegrate -x' -> x
+ IC: -a
+cmultiply (k/m_x, x) -> k/m*x
+isum (k/m*x, -g) -> -k/m*x+g
+assign (-k/m*x+g) -> x''
+
+iintegrate y'' -> -y'
+ IC: v0
+iintegrate -y' -> y
+cmultiply (k/m_y, y) -> k/m*y
+invert (k/m*y) -> -k/m*y
+assign (-k/m*y) -> y''
+
+output x -> out.x
+output.y -> out.y
+++ /dev/null
-# Wiring mache ich von links nach rechts !!!
-
-...IDENTIFICATION DIVISION
-...PROGRAM-ID FallingParticle
-...VERSION 20240225
-...COMMENT Calculate the deflection from the vertical caused by the Earth's rotation of a particle falling freely from rest from a height h.
-...COMMENT Differential Equations:
-...COMMENT x''=-bz'+ay' # x-axis is along latitude, directed to east
-...COMMENT y''=-ax' # y-axis is along longitude, directed to north
-...COMMENT z''=-g+ax' # z-axis is perpendicular to the surface of earth
-...COMMENT g: gravitational acceleration = 9,81 m/s²
-...COMMENT a: 2*omega*sin(phi)
-...COMMENT b: 2*omega*cos(phi)
-...COMMENT omega: rotation velocity of the earth = 2*pi/day
-...COMMENT phi: Latitude of location (0-90°)
-...COMMENT Initial Condition: z(0)=h
-...COMMENT The full solution requires 6 INTEGRATORs, Anabrid-THAT just has 5. The deflection to longitude (y) is neglegible and can be omitted (marked #*).
-...COMMENT It could also be solved in a separated algorithm omitting x.
-
-...ENVIRONMENT DIVISION
-...TIMEBASE 1ms
-
-...DATA DIVISION
-SET COEFFICIENT.1 TO AY # 2*2pi/day*sin(phi)
-SET COEFFICIENT.2 TO AX # = AY
-SET COEFFICIENT.3 TO B # 2*2pi/day*cos(phi)
-SET COEFFICIENT.4 TO G # gravitational acceleration = 9,81 m/s²
-SET COEFFICIENT.5 TO H # height h
-SET OUTPUT.X TO x
-SET OUTPUT.Y TO y
-SET OUTPUT.Z TO z
-
-INITIALIZE H by -1 TO -h # same as COMPUTE -1 TIMES H TO -h
-INITIALIZE G by +1 TO g
-
-INTEGRATE 1*-bz',1*ay' TO -x' # Input is x''
-INTEGRATE -x' TO x
-
-INTEGRATE y'' TO -y'
-INTEGRATE -y' TO y
-
-INTEGRATE z'' TO -z'
-INTEGRATE -z', IC:-h, LIMIT:(z >= 0) TO z
-
--x' * AX -> -ax'
--ax' = y''
--y' * AY -> -ay'
-INVERT -ay' TO ay'
--z' * B -> -bz'
-ADD 1*-ax', 1*g TO -g+ax'
--g+ax' = z''
-
-...OPERATION DIVISION
-...MODE REPEAT
-...OP-TIME 7,3ms