Week 5: Closure#
Continue working on the the preparatory exercises and the in-class exercises that you have not yet completed.
Key Concepts#
Tangent lines and tangent planes
Taylor polynomials in one variable
Taylor polynomials in \(n\) variables
Taylor polynomials of vector functions
Taylor’s theorem
Taylor’s limit formula \(f(x) = P_K(x) + \) a term with an \(\varepsilon\)-function.
Remainder term and remainder estimation
If there are still concepts you are unsure about, you should reread the relevant chapters in the textbook or revisit the exercises of the week.
Extra Exercises#
We do not expect you to complete more exercises than those from from the week’s program. The following additional exercises are purely an optional offer for those who want extra practice and challenge.
1: Smallest Degree#
Write a Python function that for a given function \(f(x)\), expansion point \(x_0\) and acceptable relative error margin \(\varepsilon\) will compute the smallest value of the polynomial degree \(K\), such that
for a chosen fixed point \(x^*\). Test your function with \(f(x)=\operatorname{e}^x\) at \(x_0=0\), \(x^*=3\) and \(\varepsilon = 0.001\).
You can start from the following code structure:
def min_taylor_degree(f, x0, xstar, eps, max_degree=50):
f_val = f.subs(x, xstar)
for K in range(max_degree+1):
# Three lines of code are missing
# You might need a helper function that computes P_K(x) with
# expansion point x0 or uses the built-in `series`
if rel_error <= eps:
return K, Pk
return None, None # If not fulfilled before max_degree
# Test example: f(x) = e^x, x0 = 0, x* = 3, eps = 0.001
f = exp(x)
K, Pk = min_taylor_degree(f, x0=0, xstar=3, eps=0.001)
print("Smallest degree: ", K)
print("Taylor polynomial: ")
print(Pk)
# Should respond with "Smallest degree: 10"