RosettaCodeData/Task/Runge-Kutta-method/Jq/runge-kutta-method-5.jq
2017-09-25 22:28:19 +02:00

10 lines
261 B
Text

# state: [t,y]
[0,1]
| while( .[0] <= 10;
.[0] as $t | .[1] as $y
| [$t + dt, $y + dy(yprime) ] )
| .[0] as $t | .[1] as $y
| if $t | integerq then
"y(\($t|round(1))) = \($y|round(10000)) ± \( ($t|actual) - $y | abs)"
else empty
end