Numerical Integration
Numerical Integration Numerical Integration
Simpson’s 1/3 Code (p.1) class Integration { private: double x0, xn; // limits of integration double (*f)(double x); //function to be integrated public: Integration(double (*F)(double x), double a, double b) { f=F; x0=a; xn=b;} double Trapezoidal(int n); double Simpsons13(int n); }; © 2003-2006 Roberto Muscedere 28
Simpson’s 1/3 Code (p.2) double Integration::Trapezoidal(int n) { double h=(xn-x0)/n; double sum=0.0; double x=x0; double I; for(int i=1; i
- Page 1 and 2: Numerical Integration • Newton-Co
- Page 3 and 4: Trapezoidal Rule • Trapezoidal Ru
- Page 5 and 6: Trapezoidal Rule • Same result if
- Page 7 and 8: Trapezoidal Rule: Example f (0) = 0
- Page 9 and 10: Trapezoidal Rule • Add a series o
- Page 11 and 12: • Grouping the terms: Trapezoidal
- Page 13 and 14: Trapezoidal Rule: Example f (0) = 0
- Page 15 and 16: Trapezoidal Code (p.2) double Integ
- Page 17 and 18: Trapezoidal Code -Output n=1, I=0.1
- Page 19 and 20: Simpson’s 1/3 Rule ( x − x1 )(
- Page 21 and 22: Simpson’s 1/3 Rule: Example • N
- Page 23 and 24: Simpson’s 1/3 Rule • Add a seri
- Page 25 and 26: Simpson’s 1/3 Rule • Grouping t
- Page 27: I f Simpson’s 1/3 Rule: Example (
- Page 31 and 32: Simpson’s 1/3 Code (p.4) double F
Simpson’s 1/3 Code (p.2)<br />
double <strong>Integration</strong>::Trapezoidal(int n)<br />
{<br />
double h=(xn-x0)/n;<br />
double sum=0.0;<br />
double x=x0;<br />
double I;<br />
for(int i=1; i