viewof example = Inputs.select(
[
{
label: "linear",
a: 0,
b: 4,
f: x => 1 + x/2,
f_tex: String.raw`\left(1+x/2\right)`,
actual: 8
},
{
label: "quadratic",
a: 0,
b: 2,
f: x => 2 - x**2/2,
f_tex: String.raw`\left(2 - \frac{1}{2}x^2\right)`,
actual: 2.666666666
},
{
label: "cubic",
a: -3,
b: 4,
f_tex: "(x^3 - 5x - 2)",
f: x => x**3 - 5*x - 2,
actual: 12.25
},
{
label: "exponential",
a: 0,
b: 3,
f_tex: "e^{-x}",
f: x => Math.exp(-x),
actual: 0.950212931632137
},
{
label: "normal",
a: -2,
b: 2,
f_tex: String.raw`\frac{1}{\sqrt{2\pi}} e^{-x^2/2}`,
f: x => Math.exp(-x*x/2)/Math.sqrt(2*Math.PI),
actual: 0.9544997361036
},
{
label: "crazy sine",
a: 0,
b: 3,
f_tex: String.raw`\sin(x^3)`,
f: x => Math.sin(x**3),
actual: 0.45642404618707
}
],
{format: o => o.label, label: "Example:"});Riemann Sums
Numerical estimates to definite integrals can be obtained via various types of summations. This page provides
- A visualization illustrating why summation should work and why some techniques are more precise than others.
- A numerical tool for actually computing these sums.
Visualization
This demo allows you to choose a function, partition size, and sum type (from Left, Right, Midpoint, or Trapezoidal) to compute and visualize the corresponding numerical integration approximation.
Computation
Here’s some live SageMath code that allows you to actually compute these sums.
\[\int_a^b f(x) \, dx \approx \sum_{i=1}^n f(x_{i-1}) \, \Delta x\]
\[\int_a^b f(x) \, dx \approx \sum_{i=1}^n f(x_i) \, \Delta x\]
\[\int_a^b f(x) \, dx \approx \sum_{i=1}^n f\left(\frac{x_{i-1} + x_i}{2}\right) \, \Delta x\]
\[\int_a^b f(x) \, dx \approx \sum_{i=1}^n \frac{f(x_{i-1}) + f(x_i)}{2} \, \Delta x\]
Note how similar the computer code for the sum is to the mathematical notation. That is
sum(f(x(i))*dx, i,1,n)looks like- \(\sum_{i=1}^n f(x_i) \, \Delta x\)