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

  • Remainder term and error estimation

  • Diverging and converging Taylor series

  • Taylor’s theorem

  • Taylor’s limit formula

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 mathematical 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

(1)#\[\begin{equation} \frac{\left|f(x^*) - P_K(x^*)\right|}{\left|f(x^*)\right|} \leq \varepsilon \end{equation}\]

for a chosen fixed point \(x^*\). Test your Python function on \(f(x)=\operatorname{e}^x\) with the values \(x_0=0\), \(x^*=3\), and \(\varepsilon = 0.001\).

You may base your work on this template script:

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"