+IDENTIFICATION DIVISION
+PROGRAM-ID Comet
+VERSION 20240205
+COMMENT A comet moves on a parabolic orbit in the gravitational field of the stationary sun.
+COMMENT Its orbital plane coincides with the plane of the Earth's orbit, which is assumed to be circular.
+COMMENT The perihelion distance is one third of the Earth's orbital radius R.E.
+COMMENT How long does the comet move within the Earth's orbit?
+COMMENT t(r)=root(2/(gamma*m(sun))*integral from 1/3RE to RE (r/root(r-1/3 RE)) dr
+
+ENVIRONMENT DIVISION
+ENGINE Anabrid-THAT
+TIMEBASE 100ms # use SLOW on both integrators
+REQUIRES COEFFICIENT 3, INTEGRATOR 2, COMPARATOR 1, SUMMER 1, OPEN-AMP 2, MULTIPLIER 2, INVERTER 1
+
+DATA DIVISION
+OUTPUT OUTPUT.X -xlimited
+OUTPUT OUTPUT.Y result
+COEFFICIENT.1 Factor # root(2/(gamma*m)), scaled to 0,142 10kd/Tm^3/2
+COEFFICIENT.2 RE # Earth's orbital radius, scaled to 0,150 Tm
+COEFFICIENT.3 1/3RE # note: dependent on RE, scaled to 0,05 Tm
+
+PROGRAM DIVISION
++1 -> COEFFICIENT.RE -> RE
++1 -> COEFFICIENT.1/3RE -> 1/3RE
+
+# obtaining x through integration of 1, starting at 1/3RE
++1, IC:1/3RE -> INTEGRATOR -> -x
+
+# limiting x to the upper limit of the integral RE and set x=0 if beyond
+A:-x, B:RE, GT0:-x -> COMPARATOR -> -xlimited
+
+-xlimited, 1/3RE -> SUMMER -> -(-x+1/3RE)=x-1/3RE
+
+# root of x-1/3RE
+## first invert because the input of a root has to be negative
+x-1/3RE -> INVERTER -> -(x-1/3RE)
+## now make sure the input is never >0 (which causes the circuit to error)
+A:-(x-1/3RE), LT0:-(x-1/3RE) -> COMPARATOR -> -(x-1/3RE)limited
+## now calculate the root
+-(x-1/3RE)limited, OA1 -> OPEN-AMP -> root
+root, root -> MULTIPLIER -> OA1
+
+# x/root
+-xlimited, OA2 -> OPEN-AMP -> x/root
+x/root, root -> MULTIPLIER -> OA2
+
+# integral
+x/root -> INTEGRATOR -> integral
+integral -> COEFFICIENT.Factor -> result
+
+OPERATION DIVISION
+MODE REPEAT
+OP-TIME 111ms