Taylor Series Expansion for \(f(x) = \sin(2x + 3)\)

Chapter 8.8, #27

  1. Function and Its Derivatives:

    • First derivative \(f'(x) = 2\cos(2x + 3)\)
    • Second derivative \(f''(x) = -4\sin(2x + 3)\)
    • Third derivative \(f'''(x) = -8\cos(2x + 3)\)
    • Fourth derivative \(f''''(x) = 16\sin(2x + 3)\)


  1. Evaluate at \(x = 0\):

    • \(f(0) = \sin(3)\)
    • \(f'(0) = 2\cos(3)\)
    • \(f''(0) = -4\sin(3)\)
    • \(f'''(0) = -8\cos(3)\)
    • \(f''''(0) = 16\sin(3)\)


  1. Construct the Taylor Series:

    Using the formula for the Taylor series expanded about \(x = 0\): \[ f(x) = f(0) + f'(0)x + \frac{f''(0)}{2!}x^2 + \frac{f'''(0)}{3!}x^3 + \frac{f''''(0)}{4!}x^4 + \dots \]

    This simplifies to:

    \[ f(x) = \sin(3) + 2\cos(3)x - 2\sin(3)x^2 - \frac{4}{3}\cos(3)x^3 + \frac{2}{3}\sin(3)x^4 + \dots \]

# Load necessary library
library(ggplot2)

# Define the function f(x) = sin(2x + 3)
f <- function(x) sin(2*x + 3)

# Define the Taylor series approximation up to the 4th order term
# Taylor coefficients derived manually or using a symbolic calculator for sin(2x+3) evaluated at x = 0
taylor_approx <- function(x) {
  sin(3) + 2*cos(3)*x - 2*sin(3)*x^2/2 - (8/6)*cos(3)*x^3 + (16/24)*sin(3)*x^4
}

# Create a sequence of x values
x <- seq(-1, 1, by = 0.01)

# Plot the original function and the Taylor series approximation
plot(x, f(x), type = "l", col = "blue", xlab = "x", ylab = "f(x)", main = "f(x) = sin(2x+3) and Taylor Series Approximation")
lines(x, taylor_approx(x), col = "red", lty = 2)

# Add a legend
legend("bottomleft", legend = c("f(x) = sin(2x+3)", "Taylor Series Approximation"), col = c("blue", "red"), lty = c(1, 2))