f(t)=

a=

b=

+

-

↑

↓

+

-

↑

↓

exact

p=

A(a)=

n=

p = 0
f(t) = t^(3) / 3 - 2 * t^(2) + 12
a = -2
b = 7
n = 9
dt: (b - a) / n
fvals = Sequence(f(a + (i + p) * dt), i, 0, n)
cumsum: Sequence[Sum[fvals, i], i, 0, n] * dt
K = (-1.467955801104972, 0)
y0 = 0
feest = Sequence((a + dt * i, y0 + Element[cumsum, i + 1]), i, 0, n)
feconnect = PolyLine(feest)
L = Intersect(OrthogonalLine[(b, 0), xAxis], feconnect)
C = Intersect(OrthogonalLine[(Max[a, Min[b, x(K)]], 0), xAxis], feconnect)
B = DynamicCoordinates(K, x(C), y(C))
aplus: a + (b - a) * 0.001
fpoints = Sequence((a + (i + p) * dt, f(a + (i + p) * dt)), i, 0, n)
flines = Sequence(Segment[Element[fpoints, i] - p * (dt, 0), Element[fpoints, i] + (1 - p) * (dt, 0)], i, 1, n)
D = (-1.467955801104972, 0.7030056062982862)
G = Element(First[RemoveUndefined[Sequence[Intersect[Element[flines, i], OrthogonalLine[(Max[a, Min[b, x(D)]], 0), xAxis]], i, 1, n]]], 1)
fint0 = Integral(f)
fint = Function(fint0(t) - fint0(a) + y0, a, b)
g: x = a
h: x = b
inputBoxf = Textfield(f)
inputBox4 = Textfield(a)
inputBox5 = Textfield(b)
maxn = 5000
centery1 = 13.047618865966797
centery2 = 59.78606396628372
height1 = 15.625
height2 = 74.50580596923831
miny1: centery1 - height1
miny2: centery2 - height2
maxy2: centery2 + height2
maxy1: centery1 + height1
minx: a - (b - a) * 0.1
A = DynamicCoordinates(D, x(G), y(G))
E: (If[x(A) < b - dt, floor((x(A) - a) / dt) * dt + a, b - dt], y(A))
highlightseg1 = Segment(E, E + (dt, 0))
F = Intersect(OrthogonalLine[E, xAxis], feconnect)
highlightseg2 = Segment(F, F + dt * (1, y(E)))
c: x(E)
fc: y(E)
yc: y(F)
exact = false
ycp1: yc + fc * dt
yfinalexact: fint(b)
poly1, d_2, e1, i, j = Polygon(E, A, (x(A), 0), (x(E), 0))
fcdx: fc * dt
cp1: c + dt
ycp1exact: fint(cp1)
ycp1errror: abs(ycp1 - ycp1exact)
maxx: b + (b - a) * 0.1
rsum = RectangleSum(f, a, b, n, p)
inputBox3 = Textfield(p)
text2: "$\Delta t=" + (LaTeX[dt]) + "$"
d: x(B)
rsumpartial = RectangleSum(f, a, x(E), n * (x(E) - a) / (b - a), p)
yd: y(B)
fd: f(d)
text4: "$ \hat{A}(" + (LaTeX[d]) + ")= " + (LaTeX[yd]) + "$"
ydexact: fint(d)
yderror: abs(yd - ydexact)
text5: "$A(" + (LaTeX[d]) + ")=" + (LaTeX[ydexact]) + "$
Error: $|" + (LaTeX[yd]) + "-" + (LaTeX[ydexact]) + "|=" + (LaTeX[yderror]) + "$"
J = Point(g)
text1: "$ A(" + (LaTeX[a]) + ") $"
inputBox1 = Textfield(y0)
cpdt: c + p * dt
text3: "$\hat{A}(" + (LaTeX[c]) + ")=" + (LaTeX[yc]) + ", f(" + (LaTeX[cpdt]) + ")= " + (LaTeX[fc]) + "$
$\begin{align}\hat{A}(" + (LaTeX[c]) + "+\Delta t)&=\hat{A}(" + (LaTeX[c]) + ")+f(" + (LaTeX[c]) + ")\Delta t\\
&=" + (LaTeX[yc]) + "+ " + (LaTeX[fc]) + "\cdot " + (LaTeX[dt]) + "\\
&=" + (LaTeX[ycp1]) + "\end{align}$"
area = true
k: y = y(A)
l: y = y(B) + y(A) * (x - x(B))
n1 = 9
inputBox2 = Textfield(n1)
defint = Integral(f, a, b)