Code
Name = "YOUR NAME HERE""YOUR NAME HERE"
Assignment 1: Jupyter Notebooks, LaTeX, Julia & Prerequisites
Published: Wed 9 Sept
Tip: You may do this part with the help from your classmates
Exercise 1.
Name = "YOUR NAME HERE""YOUR NAME HERE"
Exercise 2. Taylor expansion
Answer.
\[\begin{align} T_nf(x) = .... \nonumber \end{align}\]
Answer.
\[\begin{align} R_n(x) = .... \nonumber \end{align}\]
Answer.
using PlotsExercise 3. Archimedes’ method for computing (lower bounds to) \(\pi\).
Recall that \(\pi\) is half the circumference of the unit circle. Let \(P_n\) be the inscribed regular \(n\)-gon inside the unit circle and notice that its perimeter satisfies \(2 \pi_n \leq 2 \pi\).
Answer.
# your answer hereExercise 4. Subtractive Cancellation
Take \(f(x) := \frac{e^x - 1}{x}\). Implementing this function directly is a bad idea due to subtractive cancellation (we will go through this in detail in week 2). Julia has the built-in function expm1 which uses the Taylor expansion of \(e^x\) (as you did in Exercise 2) to evaluate \(e^x-1\) without subtractive cancellation.
Here are two ways of evaluating \(f(10^{-15})\):
g(x) = (exp(x)-1)/x
h(x) = expm1(x)/x
g_x, h_x = g(1e-15), h(1e-15)(1.1102230246251565, 1.0000000000000007)
What are the relative errors between the mathematical value of \(f(10^{-15})\) and the approximations g_x (naive formula) and h_x (Taylor expansion).
You may use y defined in the code below as the “exact” value of \(f(10^{-15})\) (which is correct to the first 100 significant digits).
y = 1.000000000000000500000000000000166666666666666708333333333333341666666666666668055555555555555753968
# YOUR CODE HERE1.0000000000000004
Goal: Reflect on your learning strategies, track your workload, and help us improve future course material.
Format: Short answer (Graded on completion: Complete / incomplete).
Time: take 5-10 mins (this shouldn’t take too long)
Estimate the approximate hours you spent:
* Assignment: ____
* Reading notes/materials: ____
* Exercises: ____
(Reminder: you should be spending around 8 hours per week on this course outside of the 4 hours of lectures)
Any other comments:
Take a moment to reflect on your learning over the past week:
What was the easiest topic or task and why? Where did you struggle, and how did you overcome those challenges? Which resources (e.g. lecture notes, practice exercises, peer discussions, …) helped you the most? How did you manage your time and workload (e.g., all at once, spread out over several days, or working with peers)? Looking back, what would you do differently if you were starting this week over today?
Comments:
(Optional) Any changes that would improve the lectures, exercises, or assignments for the future? You can also suggest things anonymously here (opens in a new tab)
Comments:
Catch up with the exercises from the lectures. If you have time, think about the following questions:
In Exercise 4, \(y\) is defined as \(y = 1.0000000000000005....\) but the output is \(y = 1.0000000000000004\). Why? How should you implement numbers with higher precision?
Think about why the following method for computing \(f(10^{-15})\) does not suffer from subtractive cancellation:
j(y) = (y-1)/log(y)
j_x = j(exp(1e-15))1.0000000000000004