Numerical integration/Gauss-Legendre Quadrature: Difference between revisions

m
(OCaml implementation)
Line 262:
let quadrature n f a b =
let f1 x = f ((x*.(b-.a) +. a +. b)*.0.5) in
let eval s (x,w) = s +. w*.(f1 x) in
0.5*.(b-.a)*.(List.fold_left (+.)eval 0.0 (List.map eval (nodes n)));;</lang>
An example of how to use it:
<lang OCaml>let calc n =
Anonymous user