f(u,p,t) = cos( u )
u0, tspan = 0., (0., 10.)
ivp = ODEProblem(f, u0, tspan)
sol = solve(ivp, Tsit5());
P = plot(sol,
title=L"u'=f(t,u)", legend=false, label="u0 = $u0",
xlabel=L"t", ylabel=L"u(t)")
for u0 = vcat(0:.1:2π, [π/2,π,3π/2,2π])
ivp = ODEProblem(f, u0, tspan)
sol = solve(ivp, Tsit5());
plot!(sol,
label="u0 = $u0",
xlabel=L"t", ylabel=L"u(t)")
end
display(P)7 P1
Problem Class 1: Initial Value Problems
Make sure we are all happy with the examples/exercises from lectures 1-4.
Exercise 7.1 Consider the problem: u : [0,T] \to \mathbb R
\begin{align} u(0) &= u_0 \nonumber\\ u'(t) &= f\big( t, u(t) \big). \tag{IVP} \end{align}
For each of the following functions f and time intervals [0,T] does (\text{IVP}) has a unique solution?
- (i) f(t, u) = t^2 \sin u and T = 1,
- (ii) f(t, u) = \sqrt[3]{u} and T = 5,
- (iii) f(t, u) = \mu u, T = 2026.
Exercise 7.2 Explain why the IVP
\begin{align} u(0) &= 1 \nonumber\\ u'(t) &= u(t) + e^{-t} \end{align}
has a unique solution for all time. Compute the solution using the integrating factor.
Exercise 7.3 Here, we plot solutions to
\begin{align} u(0) &= u_0 \nonumber\\ u'(t) &= \cos u(t) \end{align}
for different choices of initial values u_0.
What are the possible values \alpha for which u(t) \to \alpha as t\to\infty. Do all solutions have limits for large t?
Now add the term \sin t and consider
\begin{align} u(0) &= u_0 \nonumber\\ u'(t) &= \cos u(t) + \sin t. \end{align}
What do you expect to happen to the solutions? Change the code above to find out - was your hypothesis correct?
Exercise 7.4 Show that the following IVP is well-posed
\begin{align} u(0) &= 0 \nonumber\\ u'(t) &= t + u(t). \end{align}
Compute the first few terms of Euler’s method. Show that Euler’s method generates the sequence
\begin{align} u_j = (1 + h)^j - ( 1 + jh ). \end{align}
Check that the exact solution is given by u(t) = e^t - t- 1. Hence, prove an error bound for |u(t_j) - u_j| and compare with the error bound obtained from the Theorem from lectures.
Exercise 7.5 Write down the method that corresponds to the Butcher tableau:
\begin{array} {c|cccc} 0\\ c & a \\ \hline & 0 & b \end{array}Exercise 7.6 Consider the IVP
\begin{align} u(0) &= 1 \nonumber\\ u'(t) &= u(t). \end{align}
Compute the terms in the following method
\begin{align} u_{j+1} &= u_j + \frac{h}{2} \left[ f(t_j, u_j) + f\big( t_{j+1}, u_j + h f(t_j, u_j) \big) \right] \end{align}
explicitly. What is the order of accuracy of this method?