Exercise 27

Use the Taylor series given in Key Idea 8.8.1 to create the Taylor series of the given functions:

\[ f(x) = sin(2x+3) \]

Per Key Idea 8.8.1, the Taylor series (when centered at \(c\)) is given by:

\[ \sum_{n=0}^{\infty}\frac{f^{(n)}(c)}{n!}(x-c)^n \] This involves determining a \(c\) value on which to center our series, evaluating successive derivatives at \(c\), and deriving a new function via this summation. Let’s start by assuming a \(c\) of \(0\), a common jumping off point and one that, when successful, results in the special form of a Taylor series known as the Maclaurin series.

First, we’ll take the first, second and third derivatives of f(x), relying on the chain rule:

\[ f(x) = sin(2x+3) \] \[ f'(x) = 2cos(2x+3) \] \[ f''(x) = -4sin(2x+3) \] \[ f'''(x) = -8cos(2x+3) \]

Now, we’ll evaluate each derivative (in addition to the original function) at our \(c\) value of \(0\):

\[ f(0) = sin(2(0)+3) = sin(3) \approx 0.1411 \]

\[ f'(0) = 2cos(2(0)+3) = 2cos(3) \approx -1.980 \]

\[ f''(0) = -4sin(2(0)+3) = -4sin(3) \approx -0.5645 \]

\[ f'''(0) = -8cos(2(0)+3) = -8cos(3) \approx 7.920 \]

Now using the above construction, up to \(n=3\):

\[ \sum_{n=0}^{3}\frac{f^{(n)}(0)}{n!}(x)^n = 0.1411 -1.98x-\frac{0.5645}{2}x^2+\frac{7.92}{6}x^3 \] \[ = 0.1411 -1.98x-0.2823x^2+1.32x^3 \] In order to check if this is a good approximation of the original function, we can plot it against that function near our determined \(c\) value of \(0\):

f <- function(x) sin(2*x+3)
f_t <- function(x) 0.1411 - 1.98*(x) - 0.2823*(x)^2 + 1.32*(x)^3

# Setup x range
x <- seq(-1, 1, by = 0.1)

# Create the plot
plot(x, f(x), type = "l", ylim = c(-5, 5), ylab = "y", xlab = "x", main = "Multiple Function Plot")
lines(x, f(x), col = "blue")
lines(x, f_t(x), col = "green")

# Add a legend
legend("topright", legend = c("f(x)", "Taylor approx."), col = c("blue", "green"), lty = 1, cex = 0.8)