186 lines
3.6 KiB
Typst
186 lines
3.6 KiB
Typst
#import "@preview/physica:0.9.6": *
|
|
|
|
|
|
== a)
|
|
|
|
$
|
|
cases(
|
|
5y + 2y' + y'' + 3 & = 0,
|
|
y(0) & = 1,
|
|
y'(0) & = 4
|
|
)
|
|
$
|
|
|
|
we introduce the substitutions $y_1 = y$ and $y_2 = y'_1 = y$ such that we get
|
|
$
|
|
5y_1 + 2y_2 + y_2 ' + 3 = 0 \
|
|
=> y_2 ' = y'' = -3 - 2y_2 - 5y_1
|
|
$
|
|
for the first equation. this yields an autonomous first-order system
|
|
$
|
|
cases(
|
|
y_1 ' = y_2,
|
|
y_2 ' = -3 - 2y_2 - 5y_1
|
|
)
|
|
$
|
|
since there is no explicit $t$ on the right sides of the equations, i.e. the
|
|
state of the system only relies on its current state.
|
|
|
|
since we only use a step size of $h = 1$, we simply do
|
|
$
|
|
y_(n + 1) = y_n + y'_n,
|
|
$
|
|
so starting at $t = 0$ we get, using our initial values
|
|
$
|
|
cases(
|
|
y_1(0) = 1 quad #text(gray)[initial],
|
|
y_2(0) = 4 quad #text(gray)[initial],
|
|
y'_1(0) = y_2 (0) = 4,
|
|
y'_2(0) = -3 - 2y_2(0) - 5y_1(0) = -16
|
|
)
|
|
$
|
|
which we can plug in to get our next values for $y_1$ and $y_2$
|
|
$
|
|
cases(
|
|
y_1(1) = y_1(0) + y'_1(0) = 5,
|
|
y_2(1) = -12,
|
|
)
|
|
$
|
|
which concludes the first step in euler's method.
|
|
|
|
== b)
|
|
|
|
for $k = 0, 1, 2, 3$
|
|
$
|
|
cases(
|
|
y + 3y'' + 4y^((3)) + sin(t) & = 3,
|
|
y^((k))(0) & = 4 - k
|
|
)
|
|
$
|
|
yields five equations.
|
|
|
|
in this case, we can make yet more substitutions
|
|
$
|
|
cases(
|
|
y_0 & = y,
|
|
y'_k & = y_(k+1) = y^((k+1))
|
|
)
|
|
$
|
|
such that
|
|
$
|
|
& cases(
|
|
y_0 + 3 y_2 + 4 y_3 + sin(t) = 3,
|
|
y_k (0) = 4 - k
|
|
) \
|
|
=> & cases(
|
|
y'_0 = y_1,
|
|
y'_1 = y_2,
|
|
y'_2 = y_3,
|
|
y'_3 = -1/4 (y_1 + 3y_3 + cos(t))
|
|
)
|
|
$
|
|
|
|
so starting at $t = 0$ with step size $h = 1$ we obtain
|
|
$
|
|
y_0(0) = 4, quad
|
|
y_1(0) = 3, quad
|
|
y_2(0) = 2, quad
|
|
y_3(0) = 1
|
|
$
|
|
and
|
|
$
|
|
y'_0(0) = 3, quad
|
|
y'_1(0) = 2, quad
|
|
y'_2(0) = 1, quad
|
|
y'_3(0) = -7 slash 4
|
|
$
|
|
such that after one step we have
|
|
$
|
|
cases(
|
|
y_0(1) = y_0(0) + y'_0(1) = 7,
|
|
y_1(1) = 5,
|
|
y_2(1) = 3,
|
|
y_3(1) = -3 slash 4,
|
|
)
|
|
$
|
|
|
|
== c)
|
|
|
|
we have the system of ODEs
|
|
$
|
|
cases(
|
|
2u + cos(u) sin(u') + 3(u'')^3 + ln(t + 1) & = 42,
|
|
v^2 - 2v v' + (v'')^2 + v^((3)) & = t,
|
|
u^((k))(0) & = k^2\, quad #$k = 0, 1$,
|
|
v^((k))(1) & = 1\, quad #$k = 0, 1, 2$
|
|
)
|
|
$
|
|
|
|
this time we have two functions of $t$, $u$ and $v$. we can substitute as
|
|
usual, then each one independently, since the equations don't overlap.
|
|
|
|
let
|
|
$
|
|
u^((k)) = u_k quad "and" quad v^((k)) = v_k
|
|
$
|
|
such that we obtain the two disjoint systems
|
|
$
|
|
& cases(
|
|
2u_0 + cos(u_0) sin(u_1) + 3(u_2)^3 + ln(t + 1) & = 42,
|
|
u_k (0) & = k^2\, quad #$k = 0, 1$,
|
|
) \
|
|
and & cases(
|
|
v_0^2 - 2v_0 v_1 + v_2^2 + v_3 & = t,
|
|
v_k (1) & = 1\, quad #$k = 0, 1, 2$
|
|
)
|
|
$
|
|
which yields
|
|
$
|
|
& cases(
|
|
u'_0 = u_1,
|
|
u'_1 = u_2,
|
|
u'_2 = dv(, t) root(3, 1/3 (42 - 2u_0 - cos(u_0) sin(u_1) - ln(t + 1)))
|
|
) \
|
|
and & cases(
|
|
v'_0 = v_1,
|
|
v'_1 = v_2,
|
|
v'_2 = v_3,
|
|
v'_3 = dv(, t) (t - v_0^2 + 2 v_0 v_1 - v_2^2)
|
|
)
|
|
$
|
|
combined with the initial conditions
|
|
$
|
|
cases(
|
|
u_0 (0) = 0,
|
|
u_1 (0) = 1
|
|
) quad
|
|
and quad cases(
|
|
v_0 (1) = 1,
|
|
v_1 (1) = 1,
|
|
v_2 (1) = 1
|
|
)
|
|
$
|
|
yields for step size $h = 1$
|
|
$
|
|
cases(
|
|
u_0(1) & = u_0(0) + u_1(0) = 1,
|
|
u_1(1) & = u_1(0) + u'_1(0) \
|
|
& = 1 + root(3, 1/3 (42 - 2 u_0(0) - cos(u_0(0)) sin(u_1(0)) - ln(0 + 1))) \
|
|
& = 1 + root(3, (42 - sin(1))/3) approx #{
|
|
calc.round(1 + calc.root((42 - calc.sin(1)) / 3, 3), digits: 4)
|
|
}
|
|
)
|
|
$
|
|
and
|
|
$
|
|
cases(
|
|
v_0(2) & = v_0(1) + v_1(1) = 2,
|
|
v_1(2) & = v_1(1) + v_2(1) = 2,
|
|
v_2(2) & = v_2(1) + v'_2(1) \
|
|
& = 1 + (1 - (v_0(1))^2 + 2 v_0(1) v_1(1) - (v_2(1))^2) \
|
|
& = 2
|
|
)
|
|
$
|
|
|
|
thus have I done a step of euler's method for the system of ODEs.
|