21 #include "ExampleHeader.H"
24 namespace ElmerModuleDriver {
41 double h = (xn - x0)/(static_cast<double>(n));
42 if(std::fabs(h) < 1e-12)
throw 1;
43 double sum = .5*(f(x0)+f(xn));
44 for(
int i = 1; i < n;i++)
53 double h = (xn - x0)/(static_cast<double>(n));
54 if(std::fabs(h) < 1e-12)
throw 1;
56 for(
int i = 1;i <= n;i++)
57 sum += f(x0+((static_cast<double>(i)-.5)*h));
double TrapezoidQuadrature(double(*f)(double), double x0, double xn, int n)
Integrates f with composite trapezoid rule.
std::string ExampleFunction(const std::string &instring)
Example function for ElmerModuleDriver (this is a brief description).
double MidPointQuadrature(double(*f)(double), double x0, double xn, int n)
Integrates f with composite midpoint rule.