Skip to content

Commit ee8e988

Browse files
authored
Fix #26: IVP small fixes (#27)
1 parent 30a7627 commit ee8e988

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/11_Initial_value_problems.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ function forward_euler(f, u₀, a, b, N)
360360
t = [a + i * h for i in 0:N]
361361

362362
# Setup output vector with all elements initialised to u₀
363-
u = [copy(u₀) for i in 0:N]
363+
u = [float(copy(u₀)) for i in 0:N]
364364

365365
# Time integration
366366
u[1] = u₀
@@ -838,7 +838,7 @@ function midpoint(f, u₀, a, b, N)
838838
t = [a + i * h for i in 0:N]
839839

840840
# Setup output vector with all elements initialised to u₀
841-
u = [copy(u₀) for i in 0:N]
841+
u = [float(copy(u₀)) for i in 0:N]
842842

843843
# Time integration ... this is what changes over forward_euler
844844
u[1] = u₀
@@ -923,7 +923,7 @@ function rk4(f, u₀, a, b, N)
923923
t = [a + i * h for i in 0:N]
924924

925925
# Setup output vector with all elements initialised to u₀
926-
u = [copy(u₀) for i in 0:N]
926+
u = [float(copy(u₀)) for i in 0:N]
927927

928928
# Time integration ... this is what changes over forward_euler
929929
u[1] = u₀
@@ -1066,7 +1066,7 @@ Let us consider the innocent looking initial value problem
10661066
```math
10671067
\left\{
10681068
\begin{aligned}
1069-
\frac{d u(t)}{d t} &= -C && t > 0 \\
1069+
\frac{d u(t)}{d t} &= -Cu(t) && t > 0 \\
10701070
u(0) &= 10.
10711071
\end{aligned}\right.
10721072
```
@@ -1458,7 +1458,7 @@ function backward_euler(f, u₀, a, b, N; tol=1e-10)
14581458
t = [a + i * h for i in 0:N]
14591459

14601460
# Setup output vector with all elements initialised to u₀
1461-
u = [copy(u₀) for i in 0:N]
1461+
u = [float(copy(u₀)) for i in 0:N]
14621462

14631463
# Time integration
14641464
u[1] = u₀

0 commit comments

Comments
 (0)