Time (hours)

show estimates

t_0

t_1

t_2

t_3

t_4

t_5

t_6

t_7

t_8

t_9

t_{10}

f(t) = 1 + (3 * t)
T = 2
side = 0 (slider from 0 to 1, step 1)
n = 2 (slider from 2 to nmax, step 1)
ncut = Min(n, 10)
dt: T / n
fpoints = Sequence((((i + side) * dt), f(((i + side) * dt))), i, 0, n)
flines = Sequence(Segment[Element[fpoints, i] - (side * (dt, 0)), Element[fpoints, i] + ((1 - side) * (dt, 0))], i, 1, n)
midpoints = Zip(Midpoint[a], a, flines)
terms = Sequence((dt * y(Element[midpoints, i])), i, 1, n)
xmax = 2.2
xmin = -0.3
ymax = 10
ymin = -2
fshow(x) = If[0 ≤ x ≤ 2, f(x)]
side_text = If(side ≟ 0, "Left", "Right")
estimate_text: "" + side_text + "-hand estimate"
text4: "Δt=" + dt + ""
l1: y(Element[midpoints, 1]) + " km/h"
l2: y(Element[midpoints, 2]) + " km/h"
l3: y(Element[midpoints, 3]) + " km/h"
l4: y(Element[midpoints, 4]) + " km/h"
l5: y(Element[midpoints, 5]) + " km/h"
l6: y(Element[midpoints, 6]) + " km/h"
l7: y(Element[midpoints, 7]) + " km/h"
l8: y(Element[midpoints, 8]) + " km/h"
l9: y(Element[midpoints, 9]) + " km/h"
l10: y(Element[midpoints, 10]) + " km/h"
psums = Sequence(Sum[terms, i], i, 1, ncut)
tpoints = Sequence(((dt * i), 0), i, 0, ncut)
show_estimates = true
sumsub1: "" + (Sum[Sequence[y(Element[midpoints, i]) + " \cdot " + ((dt * " + ")), i, 1, n - 1]] + (y(Element[midpoints, ncut]))) + " \cdot " + dt + " = " + (Element[psums, ncut]) + ""
sumsub2: "" + (Sum[Sequence["f(t_" + (i + side) + ")\Delta t +", i, 0, ncut - 2]]) + "f(t_" + (ncut - 1 + side) + ")\Delta t"
sumsub3: "\sum_{i=1}^{" + ncut + "} f(t_{i" + (If[side ≟ 0, "-1", ""]) + "})\Delta t"
text2 = RotateText("Rate (km/h)", 1.5708)
ft_text: "f(t_{i" + (If[side ≟ 0, "-1", ""]) + "})"
ftdt_text: "f(t_{i" + (If[side ≟ 0, "-1", ""]) + "})\Delta t"
sumtextn: "\displaystyle I_" + (If[side ≟ 0, "l", "r"]) + " = \sum_{i=1}^{n} f(t_{i" + (If[side ≟ 0, "-1", ""]) + "})\Delta t"
nmax = 10
r_tot = Sum(terms)
chart: "\small\begin{array}{cccc}\text{Interval}&\text{Rate}&\text{Distance}&\text{Total Distance}\\" + (Sum[Sequence[x(Element[tpoints, i]) + " \text{ to } " + (x(Element[tpoints, i + 1])) + "&" + (y(Element[midpoints, i])) + "&" + (Element[terms, i]) + "&" + (Element[psums, i]) + "\\", i, 1, ncut]]) + "\end{array}"
sumtexttot: "\displaystyle I_" + (If[side ≟ 0, "l", "r"]) + " = \sum_{i=1}^{" + n + "} f(t_{i" + (If[side ≟ 0, "-1", ""]) + "})\Delta t =" + r_tot + ""
sumtextcombo: "\tiny\begin{align*} I_" + (If[side ≟ 0, "l", "r"]) + "&=" + sumsub1 + "\\&=" + sumsub2 + "\\&=" + sumsub3 + "\end{align*}"
sumtext1: "\tiny\begin{align*} I_" + (If[side ≟ 0, "l", "r"]) + "&=" + sumsub1 + "\end{align*}"