Riemann Sum
Author: Doug Kuhlmann

Shows the value of an approximating Riemann sum
and Trapepzoid sum also.

Change a and b by points along X-axis.  Change  n, the number of intervals, and p, the position in the interval where the function is evaluated by using the sliders

a

b

RiemannSum

Trapezoid

Right

Midpoint

Left

Number of subintervals

Where the function is evaluated
in an interval

f(x) = 2.0 * sin(x)
n = 15 (slider from 1 to 100, step 1)
A = Point(xAxis)
a: x(A)
B = Point(xAxis)
b: x(B)
Δx: (b - a) / n
p = 0.2 (slider from 0 to 1, step 0.1)
xpts = Sequence(a + (p + i) * Δx, i, 0.0, n - 1.0)
fxpts: f(xpts)
RSum = BarChart(a, b, fxpts)
TrapSum = TrapezoidalSum(f, a, b, n)
r = true
ts = false
u = Vector(A, B)
RiemannSum: "Riemann Sum = " + RSum
Trap: "Trapezoid Sum =" + TrapSum
Int = Integral(f, a, b)
Integral: "\int_{" + a + " }^{" + b + "}{(" + (LaTeX[f]) + ")dx = " + Int
Tpts = Sequence((a + i * Δx, f(a + i * Δx)), i, 0.0, n)
points = Sequence((Element[xpts, i], Element[fxpts, i]), i, 1.0, n)