Key Idea 8.8.1 gives the nth term of the Taylor series of common functions. In Exercises 3– 6, verify the formula given in the Key Idea by finding the first few terms of the Taylor series of the given function and identifying a pattern:

  1. f(x) = ex; c = 0
# To calculate the first few terms of the Taylor series for e^x
n <- 5
x <- seq(-1, 1, length.out = 100)  # Choose an appropriate range for x
taylor_e <- 1 + x + x^2 / 2 + x^3 / 6 + x^4 / 24  # First 5 terms
plot(x, taylor_e, type = "l", xlab = "x", ylab = "e^x (approximation)",
     main = "Taylor Series for e^x (Maclaurin series)")

  1. f(x) = sinx; c = 0
# To calculate the first few terms of the Taylor series for sin(x)
taylor_sin <- x - x^3 / 6 + x^5 / 120 - x^7 / 5040  # First 5 terms
plot(x, taylor_sin, type = "l", xlab = "x", ylab = "sin(x) (approximation)",
     main = "Taylor Series for sin(x)")

5. f(x) = 1 (1 x); c =0

# To calculate the first few terms of the geometric series for 1/(1-x)
taylor_geom <- 1 + x + x^2 + x^3 + x^4  # First 5 terms
plot(x, taylor_geom, type = "l", xlab = "x", ylab = "1/(1-x) (approximation)",
     main = "Geometric Series for 1/(1-x)")

  1. f(x) = tan 1x; c = 0
# To calculate the first few terms of the Taylor series for atan(x)
taylor_atan <- x - x^3 / 3 + x^5 / 5 - x^7 / 7  # First 5 terms
plot(x, taylor_atan, type = "l", xlab = "x", ylab = "atan(x) (approximation)",
     main = "Taylor Series for atan(x)")