5  A1

Jupyter Notebooks, LaTeX, Julia & Prerequisites

Published

January 21, 2026

Note
  • Complete the following and submit to Canvas before Jan 28, 23:59
  • Late work will recieve 0%,
  • Each assignment is worth the same,
  • Please get in contact with the TA/instructor in plenty of time if you need help,
  • Before submitting your work, make sure to check everything runs as expected. Click Kernel > Restart Kernel and Run All Cells.
  • Feel free to add more cells to experiment or test your answers,
  • I encourage you to discuss the course material and assignment questions with your classmates. However, unless otherwise explicitly stated on the assignment, you must complete and write up your solutions on your own,
  • The use of GenAI is prohibited as outlined in the course syllabus. If I suspect you of cheating, you may be asked to complete a written or oral exam on the content of this assignment.

Approx. time spent on this assignment:

Did you do the suggested reading? Yes/No


5.1 A: Jupyter Notebooks

Tip

You may do this part (part A only) with the help from your classmates

Exercise 1.

  • Follow the steps here to install Julia and Jupyter,
  • Upload and run this .ipynb file,
  • Double click on the following cell to replace YOUR NAME HERE with your name
Name = "YOUR NAME HERE"
"YOUR NAME HERE"

5.2 B: \LaTeX

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.

5.3 C. Julia

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:

  • some of the code has been written for you,
  • mesh is the array ( t_j )_{j=0}^n,
  • u_exact is the exact solution,
  • You may use maximum( @. abs( u - u_exact(mesh) ) ) to compute the error between the exact solution u_exact and the approximation u,
  • You may need to change the scale of the final graph to find the rate of decay.
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" )

5.4 D. Reading

Read: Pages 259–268 of Burden, Faires, and Burden (2015)

Burden, Richard L., Douglas J. Faires, and Annette M. Burden. 2015. Numerical Analysis. 10th ed. CENGAGE Learning.