Numerical integration/Adaptive Simpson's method: Difference between revisions
Numerical integration/Adaptive Simpson's method (view source)
Revision as of 15:28, 3 August 2023
, 9 months agoReplaced "func" with "proc" as the procedures can have side effects.
(→{{header|COBOL}}: Make abs-delta unsigned so we don't have to explicitely test the sign of delta) |
(Replaced "func" with "proc" as the procedures can have side effects.) |
||
Line 1,613:
type Func = float -> float
## Evaluates the Simpson's Rule, also returning m and f(m) to reuse
result.m = (a + b) / 2
Line 1,619:
result.val = abs(b - a) * (fa + 4 * result.fm + fb) / 6
## Efficient recursive implementation of adaptive Simpson's rule.
## Function values at the start, middle, end of the intervals are retained.
Line 1,631:
f.quadAsr(m, fm, b, fb, eps / 2, right, rm, frm)
## Integrate f from a to b using Adaptive Simpson's Rule with max error of eps.
let fa = f(a)
|