Numerical integration/Adaptive Simpson's method: Difference between revisions
Numerical integration/Adaptive Simpson's method (view source)
Revision as of 14:05, 17 May 2023
, 1 year ago→{{header|ATS}}: There was needless recomputation of f. That is fixed now. Also more passing around of f than was necessary; also fixed.
(→{{header|ATS}}: There was needless recomputation of f. That is fixed now. Also more passing around of f than was necessary; also fixed.) |
|||
Line 239:
quadrature_by_adaptive_simpson (f, a, b, tol, depth) =
let
(*
typedef real = g0float tk
(* In ATS, you can nest functions inside functions to whatever
depth you like. *)
fn
_quad_asr_simpsons (
fa : real,
b : real,
Line 271 ⟶ 269:
val h = b - a
in
@(m, fm, (h / g0i2f 6) * (
end
Line 286 ⟶ 284:
run out of stack space, etc.). *)
.<depth>.
(
fa : real,
b : real,
Line 302 ⟶ 299:
perhaps it is good as documentation. In some instances it
is REALLY what you want. *)
val @(lm, flm, left) = _quad_asr_simpsons (
and @(rm, frm, right) = _quad_asr_simpsons (
val delta = left + right - whole
Line 321 ⟶ 318:
else
let
val left_val = _quad_asr (
lm, flm, depth - 1)
and right_val = _quad_asr (
rm, frm, depth - 1)
in
Line 334 ⟶ 331:
val @(fa, fb) = @(f(a), f(b))
val @(m, fm, whole) = _quad_asr_simpsons (
in
_quad_asr (
end
|