Approximate $$$\int\limits_{-1}^{1} x e^{x}\, dx$$$ with $$$n = 5$$$ using the trapezoidal rule

The calculator will approximate the integral of $$$x e^{x}$$$ from $$$-1$$$ to $$$1$$$ with $$$n = 5$$$ subintervals using the trapezoidal rule, with steps shown.

Related calculator: Trapezoidal Rule Calculator for a Table

If the calculator did not compute something or you have identified an error, or you have a suggestion/feedback, please write it in the comments below.

Your Input

Approximate the integral $$$\int\limits_{-1}^{1} x e^{x}\, dx$$$ with $$$n = 5$$$ using the trapezoidal rule.

Solution

The trapezoidal rule uses trapezoids to approximate the area:

$$$\int\limits_{a}^{b} f{\left(x \right)}\, dx\approx \frac{\Delta x}{2} \left(f{\left(x_{0} \right)} + 2 f{\left(x_{1} \right)} + 2 f{\left(x_{2} \right)} + 2 f{\left(x_{3} \right)}+\dots+2 f{\left(x_{n-2} \right)} + 2 f{\left(x_{n-1} \right)} + f{\left(x_{n} \right)}\right)$$$

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

We have that $$$f{\left(x \right)} = x e^{x}$$$, $$$a = -1$$$, $$$b = 1$$$, and $$$n = 5$$$.

Therefore, $$$\Delta x = \frac{1 - \left(-1\right)}{5} = \frac{2}{5}$$$.

Divide the interval $$$\left[-1, 1\right]$$$ into $$$n = 5$$$ subintervals of the length $$$\Delta x = \frac{2}{5}$$$ with the following endpoints: $$$a = -1$$$, $$$- \frac{3}{5}$$$, $$$- \frac{1}{5}$$$, $$$\frac{1}{5}$$$, $$$\frac{3}{5}$$$, $$$1 = b$$$.

Now, just evaluate the function at these endpoints.

$$$f{\left(x_{0} \right)} = f{\left(-1 \right)} = - \frac{1}{e}\approx -0.367879441171442$$$

$$$2 f{\left(x_{1} \right)} = 2 f{\left(- \frac{3}{5} \right)} = - \frac{6}{5 e^{\frac{3}{5}}}\approx -0.658573963312832$$$

$$$2 f{\left(x_{2} \right)} = 2 f{\left(- \frac{1}{5} \right)} = - \frac{2}{5 e^{\frac{1}{5}}}\approx -0.327492301231193$$$

$$$2 f{\left(x_{3} \right)} = 2 f{\left(\frac{1}{5} \right)} = \frac{2 e^{\frac{1}{5}}}{5}\approx 0.488561103264068$$$

$$$2 f{\left(x_{4} \right)} = 2 f{\left(\frac{3}{5} \right)} = \frac{6 e^{\frac{3}{5}}}{5}\approx 2.186542560468611$$$

$$$f{\left(x_{5} \right)} = f{\left(1 \right)} = e\approx 2.718281828459045$$$

Finally, just sum up the above values and multiply by $$$\frac{\Delta x}{2} = \frac{1}{5}$$$: $$$\frac{1}{5} \left(-0.367879441171442 - 0.658573963312832 - 0.327492301231193 + 0.488561103264068 + 2.186542560468611 + 2.718281828459045\right) = 0.807887957295251.$$$

Answer

$$$\int\limits_{-1}^{1} x e^{x}\, dx\approx 0.807887957295251$$$A