forward euler

forward euler

forward euler

f(t)

y(t)

∫f(t)dt

y(0)

p = 0
f(t) = t^(2) - 10
t0 = 0
tFinal = 10
n = 10
dt = 1
fvals = Sequence(f(t0 + ((i + p) * dt)), i, 0, n)
cumsum: (Sequence[Sum[fvals, i], i, 0, n] * dt)
K = (2.514222222222222, 0)
y0 = 50
feest = Sequence((t0 + (dt * i), y0 + Element[cumsum, i + 1]), i, 0, n)
feconnect = PolyLine(feest)
L = Intersect(OrthogonalLine[(tFinal, 0), xAxis], feconnect)
C = Intersect(OrthogonalLine[(Max[t0, Min[tFinal, x(K)]], 0), xAxis], feconnect)
B = DynamicCoordinates(K, x(C), y(C))
t0PlusEpsilon: t0 + ((tFinal - t0) * 0.001)
fpoints = Sequence((t0 + ((i + p) * dt), f(t0 + ((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 = (2.514222222222222, 0)
G = Element(First[RemoveUndefined[Sequence[Intersect[Element[flines, i], OrthogonalLine[(Max[t0, Min[tFinal, x(D)]], 0), xAxis]], i, 1, n]]], 1)
fint0 = Integral(f)
fint = Function(fint0(t) - fint0(t0) + y0, t0, tFinal)
g: x = t0
h: x = tFinal
maxn = 1000
A = DynamicCoordinates(D, x(G), y(G))
E: (If[x(A)  <  t0 + (dt * (n - 1)), Max[0, (ceil((x(A) - t0) / dt - 1) * dt)] + t0, t0 + (dt * (n - 1))], y(A))
highlightseg1 = Segment(E, E + (dt, 0))
F = Intersect(OrthogonalLine[E, xAxis], feconnect)
highlightseg2 = Segment(F, F + (dt * (1, y(E))))
ti: x(E)
fti: y(E)
yi: y(F)
exact = false
yiPlus1: yi + (fti * dt)
yFinalExact: fint(tFinal)
ftidt: (fti * dt)
tiPlus1: ti + dt
yiPlus1Exact: fint(tiPlus1)
yiPlus1Errror: abs(yiPlus1 - yiPlus1Exact)
tiPlusFraction: x(B)
yiPlusFraction: y(B)
ftiPlusFraction: f(tiPlusFraction)
yiPlusFractionExact: fint(tiPlusFraction)
yiPlusFractionError: abs(yiPlusFraction - yiPlusFractionExact)
J = Point(g)
tiPluspdt: ti + (p * dt)
k: y = y(A)
l: y = y(B) + (y(A) * (x - x(B)))
details = true
yiApprox: "y(" + (LaTeX[ti]) + ") \approx " + (LaTeX[yi]) + ""
ftiEquation: "f(" + ti + ")=" + fti + ""
DeltatEquation: "\Delta t = " + (LaTeX[dt]) + ""
tiEquation: "t=" + (LaTeX[ti]) + ""
yiPlus1Word: "y(" + tiPlus1 + ")"
tiPlus1Equation: "t=" + (LaTeX[tiPlus1]) + ""
dydtEquation: "\frac{dy}{dt}=f(t)=" + (LaTeX[f]) + ""
yiPlusFractionApprox: "y(" + (LaTeX[tiPlusFraction]) + ")\approx " + (LaTeX[yiPlusFraction]) + ""
yiPlusFractionExactEquation: "y(" + (LaTeX[tiPlusFraction]) + ") = " + (LaTeX[yiPlusFractionExact]) + ""
minusyipPlusFractionExact = If(yiPlusFractionExact  <  1, "-(" + yiPlusFractionExact + ")", "-" + yiPlusFractionExact)
yiPlusFractionErrorEquation: "|" + (LaTeX[yiPlusFraction]) + "" + (LaTeX[minusyipPlusFractionExact]) + "|=" + (LaTeX[yiPlusFractionError]) + ""
tiPlusFractionEquation: "t=" + (LaTeX[tiPlusFraction]) + ""
LL1 = Corner(1, 1)
LL2 = Corner(2, 1)
UR2 = Corner(2, 3)
UR1 = Corner(1, 3)
ymax2 = 291.1646343726218
xmin1 = -1.233424657534247
xmax1 = 11.033424657534246
ymax1 = 129.95155822098016
ymin1 = -40.21518033649587
ymin2 = -35.34060295949264
xmax2 = 11.036858006042294
xmin2 = -1.236858006042296
yiPlus1Steps: "\begin{align*}
y(" + tiPlus1 + ") &= y(" + (LaTeX[ti]) + "+\Delta t)\\
& \approx y(" + (LaTeX[ti]) + ")+f(" + (LaTeX[ti]) + ")\Delta t\\
&=" + (LaTeX[yi]) + "+ (" + (LaTeX[fti]) + ")(" + (LaTeX[dt]) + ")\\
&=" + (LaTeX[yiPlus1]) + "
\end{align*}"