RosettaCodeData/Task/Euler-method/Jq/euler-method-2.jq

11 lines
308 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
def euler_solution(df; x1; y1; x2; h):
def recursion(exp): reduce recurse(exp) as $x (.; $x);
h as $h
| [x1, y1]
| recursion( if ((.[0] < x2 and x1 < x2) or
(.[0] > x2 and x1 > x2)) then
2026-02-01 16:33:20 -08:00
[ (.[0] + $h), (.[1] + $h*df) ]
2023-07-01 11:58:00 -04:00
else empty
end )
| .[1] ;