ΣνΜDr. Sharon's Math PlatformSyvara Learning
Question Bank › 📘 Undergraduate › Numerical Method with Python (Math & Eng) › Q8

Q8 · Write a Python function `taylor_cos(x, n_terms)` that approximates $\cos(x)$ using the…

Taylor Series Approximation 🟡 Intermediate Coding
Question

Write a Python function taylor_cos(x, n_terms) that approximates $\cos(x)$ using the first n_terms terms of the Taylor series:
$$\cos(x) \approx \sum_{k=0}^{n\_terms-1} \frac{(-1)^k \, x^{2k}}{(2k)!}$$

(a) Print the approximation and the true value (math.cos) for $x = 1.2$ using 3, 5, and 7 terms.
(b) Print the relative error for each case.
(c) What do you observe as the number of terms increases?

🔒

Log in to see the worked solution

Enter your email to get started. Your first free solutions in every course unlock as soon as you verify.

Log in or sign up with email
← Previous Next →
Working…