# Trapezoidal Rule Calculator

Your input: approximate the integral 10sin3(x)+1−−−−−−−−−√ dx

using n=5

$n=5$

trapezoids.

The trapezoidal rule states that baf(x)dxΔx2(f(x0)+2f(x1)+2f(x2)+...+2f(xn1)+f(xn))

${\int }_{a}^{b}f\left(x\right)dx\approx \frac{\mathrm{\Delta }x}{2}\left(f\left({x}_{0}\right)+2f\left({x}_{1}\right)+2f\left({x}_{2}\right)+...+2f\left({x}_{n-1}\right)+f\left({x}_{n}\right)\right)$

, where Δx=ban

$\mathrm{\Delta }x=\frac{b-a}{n}$

.

We have that a=0

$a=0$

b=1

$b=1$

n=5

$n=5$

.

Therefore, Δx=105=15

$\mathrm{\Delta }x=\frac{1-0}{5}=\frac{1}{5}$

.

Divide the interval [0,1]

$\left[0,1\right]$

into n=5

$n=5$

subintervals of length Δx=15

$\mathrm{\Delta }x=\frac{1}{5}$

, with the following endpoints: a=0,15,25,35,45,1=b

$a=0,\frac{1}{5},\frac{2}{5},\frac{3}{5},\frac{4}{5},1=b$

.

Now, we just evaluate the function at these endpoints:

f(x0)=f(a)=f(0)=1=1

$f\left({x}_{0}\right)=f\left(a\right)=f\left(0\right)=1=1$

2f(x1)=2f(15)=2sin3(15)+1−−−−−−−−−−−√=2.00782606791279

$2f\left({x}_{1}\right)=2f\left(\frac{1}{5}\right)=2\sqrt{{\mathrm{sin}}^{3}\left(\frac{1}{5}\right)+1}=2.00782606791279$

2f(x2)=2f(25)=2sin3(25)+1−−−−−−−−−−−√=2.05820697233265

$2f\left({x}_{2}\right)=2f\left(\frac{2}{5}\right)=2\sqrt{{\mathrm{sin}}^{3}\left(\frac{2}{5}\right)+1}=2.05820697233265$

2f(x3)=2f(35)=2sin3(35)+1−−−−−−−−−−−√=2.17257446116512

$2f\left({x}_{3}\right)=2f\left(\frac{3}{5}\right)=2\sqrt{{\mathrm{sin}}^{3}\left(\frac{3}{5}\right)+1}=2.17257446116512$

2f(x4)=2f(45)=2sin3(45)+1−−−−−−−−−−−√=2.34021475342487

$2f\left({x}_{4}\right)=2f\left(\frac{4}{5}\right)=2\sqrt{{\mathrm{sin}}^{3}\left(\frac{4}{5}\right)+1}=2.34021475342487$

f(x5)=f(b)=f(1)=sin3(1)+1−−−−−−−−−√=1.26325897447473

$f\left({x}_{5}\right)=f\left(b\right)=f\left(1\right)=\sqrt{{\mathrm{sin}}^{3}\left(1\right)+1}=1.26325897447473$ 