1#ifndef INTEGRATION_DEFINED
2#define INTEGRATION_DEFINED
8template <
typename Method,
typename F,
typename Float>
10double integrate(F f, Float a, Float b,
int steps, Method m) {
12 double h = (b - a) / steps;
13 for (
int i = 0; i < steps; ++i) s += m(f, a + h * i, h);
18 template <
typename F,
typename Float>
20 return (f(x) + f(x + h)) / 2;
26 template <
typename F,
typename Float>
28 return (f(x) + 4 * f(x + h / 2) + f(x + h)) / 6;
Definition Integration.hpp:24
double operator()(F f, Float x, Float h) const
Definition Integration.hpp:27
Definition Integration.hpp:16
double operator()(F f, Float x, Float h) const
Definition Integration.hpp:19
Definition Algorithm.hpp:10
double integrate(F f, Float a, Float b, int steps, Method m)
Definition Integration.hpp:10