Name = "YOUR NAME HERE""YOUR NAME HERE"
Jupyter Notebooks, LaTeX, Julia & Prerequisites
Approx. time spent on this assignment:
Did you do the suggested reading? Yes/No
You may do this part (part A only) with the help from your classmates
Exercise 1.
Name = "YOUR NAME HERE""YOUR NAME HERE"
Exercise 2. Write down the degree n Taylor polynomial of f:\mathbb R \to \mathbb R about some point a.
Answer.
Your answer here
Exercise 3. Apply the Taylor remainder theorem to f(x) = e^x about x=0 to show that
\begin{align} 0 \leq 1+x \leq e^x \end{align}
for all x \geq -1.
Answer.
Your answer here
Exercise 4. Fix \alpha, \beta > 0 and suppose that x_n is a sequence such that x_{n+1} \leq (1 + \alpha) x_n + \beta for all n \in \mathbb N. Show that
\begin{align} x_{n+1} \leq (1 + \alpha)^{n+1} \left( x_0 + \frac{\beta}{\alpha} \right) - \frac{\beta}{\alpha} . \end{align}
Answer.
Suppose u : [0,T] \to \mathbb R solves the initial value problem
\begin{align} u'(t) &= f\big( t, u(t) \big) \qquad \text{on } (0,T) \nonumber \\ u(0) &= u_0. \tag{IVP} \end{align}
Recall from L1 that, in order to approximate the solution u at mesh points t_j = j h where h := \frac{T}{n} (for j=0,\dots,n), we may approximate the integral
\begin{align} u(t_{j+1}) - u( t_j ) = \int_{t_j}^{t_{j+1}} f\big( s, u(s) \big) \mathrm{d}s. \end{align}
In Math 5485, you used the Rectangular rule: u(t_j) \approx u_j where u_0 is given as the initial condition and
\begin{align} u_{j+1} := u_j + h f( t_j, u_j ). \end{align}
This is Euler’s method:
function Euler( u0, f, T, n )
h = T/n
t = 0:h:T
u = zeros(n+1)
u[1] = u0
for j = 1:n
u[j+1] = u[j] + h * f( t[j], u[j] )
end
return u
end Euler (generic function with 1 method)
Exercise 5. Use Euler’s method to approximate the solution of \text{(IVP)} for
\begin{align} &u_0 = 1, \quad T = 1, \quad \text{and} \\ &f(t, u) := \frac{2(1 - t u)}{1 + t^2}. \end{align}
In this case the exact solution is known and given by u(t) = \frac{1 + 2t}{1 + t^2}. Use the exact solution to compute the approximation errors \max_j | u(t_j) - u_j | (where u is the exact solution and u_j is the approximation at t_j). At what rate does the approximation error decay as a function of n?
Hints:
mesh is the array ( t_j )_{j=0}^n,u_exact is the exact solution,maximum( @. abs( u - u_exact(mesh) ) ) to compute the error between the exact solution u_exact and the approximation u,using Plots, LaTeXStrings
u0, T, n = 1, 1, 10
mesh = 0:T/n:T
f(t, u) = 2*(1-t*u)/(t^2 + 1)
u_exact = t -> (2*t+1)/(t^2 + 1)
# YOUR ANSWER HERE
u = zeros( n+1 ) # (change this)
plot( u_exact, 0, 1,
label="Exact solution" )
plot!( mesh, u,
label="Approximation (Euler, n = $n)" )N = 500
errs = zeros(N)
for n ∈ 1:N
# YOUR ANSWER HERE
u = zeros(n+1)
mesh = 0:T/n:T
errs[n] = maximum( @. abs( u - u_exact(mesh) ) )
end
scatter( errs, xlabel=L"n", label="approximation error", lw=3, title="Euler's Method" )Read: Pages 259–268 of Burden, Faires, and Burden (2015)