MathLab with Mr. Ahmed

MathLab with Mr. Ahmed is a math learning website by Ahmed Amasha, a mathematics teacher teaching the American curriculum. Explore Algebra 2, Precalculus, Calculus, and SAT and PSAT Math Prep through lessons, focused practice and printable resources.

MathLabwith Mr. Ahmed
Integration

4.6 Numerical Integration

Focus on trapezoidal, midpoint, and simpson rules, error bounds, choose a sampling method.

Free preview Explore the lesson before creating an account.

Play games for this section

Before you solve

Ideas in this lesson

Idea 1 of 3

Trapezoidal, midpoint, and Simpson rules

Use the appropriate weights for the chosen rule. Simpson’ss Rule requires an even number of equal subintervals.

Worked example 1

Approximate ∫01x2 dx\int_{0}^{1} x^{2}\,dx with n=2n = 2 by the Trapezoidal Rule.
  1. h=12h = \dfrac{1}{2}; xxᵢ =i2= \dfrac{i}{2}
  2. Tn=h2[f(0)+2∑f(xT_{n} = \dfrac{h}{2}[f(0) + 2\sum f(xᵢ)+f(1)]) + f(1)]
  3. T2=13+124=38≈0.38T_2 = \dfrac{1}{3} + \dfrac{1}{24} = \dfrac{3}{8} \approx 0.38

Answer: 38≈0.38\dfrac{3}{8} \approx 0.38

Worked example 2

Approximate ∫01x2 dx\int_{0}^{1} x^{2}\,dx with n=4n = 4 by Simpson’ss Rule.
  1. h=14h = \dfrac{1}{4}; xxᵢ =i4= \dfrac{i}{4}
  2. Sn=h3[f(0)+4∑f(xodd)+2∑f(xeven)+f(1)]S_{n} = \dfrac{h}{3}[f(0) + 4\sum f(x_{\mathrm{odd}}) + 2\sum f(x_{\mathrm{even}}) + f(1)]
  3. S4=13=13≈0.33S_4 = \dfrac{1}{3} = \dfrac{1}{3} \approx 0.33

Answer: 13≈0.33\dfrac{1}{3} \approx 0.33

Idea 2 of 3

Error bounds

A derivative bound controls the approximation error. A zero fourth derivative makes Simpson’ss Rule exact for a quadratic.

Worked example 1

For ∫01x2 dx\int_{0}^{1} x^{2}\,dx with n=4n = 4, find the Trapezoidal error bound.
  1. f′′=2f'' = 2; ff⁽4^{4}⁾ =0= 0; M2=2M_{2} = 2; M4=0M_{4} = 0
  2. ∣ET∣≤2(1−0)3192=196≈0.01|E_T| \le \dfrac{2(1 - 0)^{3}}{192} = \dfrac{1}{96} \approx 0.01

Answer: 196≈0.01\dfrac{1}{96} \approx 0.01

Worked example 2

For ∫01x2 dx\int_{0}^{1} x^{2}\,dx with n=6n = 6, find the Midpoint error bound.
  1. f′′=2f'' = 2; ff⁽4^{4}⁾ =0= 0; M2=2M_{2} = 2; M4=0M_{4} = 0
  2. ∣EM∣≤2(1−0)3864=1432≈0.00231|E_M| \le \dfrac{2(1 - 0)^{3}}{864} = \dfrac{1}{432} \approx 0.00231

Answer: 1432≈0.00231\dfrac{1}{432} \approx 0.00231

Idea 3 of 3

Choose a sampling method

Left, right, and midpoint sums use different heights on the same partition; a larger nn alone is not an exact answer.

Worked example 1

Approximate ∫02x2 dx\int_{0}^{2} x^{2}\,dx with 33 equal left rectangles.
xx000.66666666670.66666666671.3333333331.333333333
f(x)f(x)000.44444444440.44444444441.7777777781.777777778
  1. Δx=23≈0.67\Delta x = \dfrac{2}{3} \approx 0.67
  2. Sample points: xxᵢ =0,≈0.67,≈1.33= 0, \approx 0.67, \approx 1.33
  3. L3=23[02+≈0.672+≈1.332]=4027≈1.48L_3 = \dfrac{2}{3}[0^{2} + \approx 0.67^{2} + \approx 1.33^{2}] = \dfrac{40}{27} \approx 1.48

Answer: 4027≈1.48\dfrac{40}{27} \approx 1.48

Worked example 2

Approximate ∫03x2 dx\int_{0}^{3} x^{2}\,dx with 44 equal right rectangles.
xx0.750.751.51.52.252.2533
f(x)f(x)0.56250.56252.252.255.06255.062599
  1. Δx=34≈0.75\Delta x = \dfrac{3}{4} \approx 0.75
  2. Sample points: xxᵢ =0.75,1.5,2.25,3= 0.75, 1.5, 2.25, 3
  3. R4=34[0.752+1.52+2.252+32]=40532≈12.66R_4 = \dfrac{3}{4}[0.75^{2} + 1.5^{2} + 2.25^{2} + 3^{2}] = \dfrac{405}{32} \approx 12.66

Answer: 40532≈12.66\dfrac{405}{32} \approx 12.66

Resource alignment: Larson & Edwards, Calculus of a Single Variable, Tenth Edition, §4.6,p4.6, p. 305305. Explanations, diagrams and numerical practice variants are original MathLab content aligned to this section.