Function and Its Derivatives:
Evaluate at \(x = 0\):
Construct the Taylor Series:
Using the formula for 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) = 1 + x + x^2 + x^3 + x^4 + \dots \]
# Define the function and its Taylor series approximation
f1 <- function(x) 1/(1-x)
taylor_f1 <- function(x) {
1 + x + x^2 + x^3 + x^4
}
# Create a sequence of x values
x1 <- seq(-0.9, 0.9, by = 0.01)
# Plot the original function and the Taylor series approximation
plot(x1, f1(x1), type = "l", col = "blue", xlab = "x", ylab = "f(x)", main = "f(x) = 1/(1-x) and Taylor Series Approximation")
lines(x1, taylor_f1(x1), col = "red", lty = 2)
# Add a legend
legend("topleft", legend = c("f(x) = 1/(1-x)", "Taylor Series Approximation"), col = c("blue", "red"), lty = c(1, 2))
Function and Its Derivatives:
The function \(f(x) = e^x\) remains itself through differentiation. Every derivative at any point is exactly the function \(e^x\)
Evaluate at \(x = 0\):
Construct the Taylor Series:
Using the formula for 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) = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \dots \]
# Define the function and its Taylor series approximation
f2 <- function(x) exp(x)
taylor_f2 <- function(x) {
1 + x + x^2/2 + x^3/6 + x^4/24
}
# Create a sequence of x values
x2 <- seq(-2, 2, by = 0.01)
# Plot the original function and the Taylor series approximation
plot(x2, f2(x2), type = "l", col = "blue", xlab = "x", ylab = "f(x)", main = "f(x) = e^x and Taylor Series Approximation")
lines(x2, taylor_f2(x2), col = "red", lty = 2)
# Add a legend
legend("topleft", legend = c("f(x) = e^x", "Taylor Series Approximation"), col = c("blue", "red"), lty = c(1, 2))
Function and Its Derivatives:
Evaluate at \(x = 0\):
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) = x - \frac{x^2}{2} + \frac{x^3}{3} - \frac{x^4}{4} + \dots \]
# Define the function and its Taylor series approximation
f3 <- function(x) log(1+x)
taylor_f3 <- function(x) {
x - x^2/2 + x^3/3 - x^4/4
}
# Create a sequence of x values
x3 <- seq(-0.9, 0.9, by = 0.01)
# Plot the original function and the Taylor series approximation
plot(x3, f3(x3), type = "l", col = "blue", xlab = "x", ylab = "f(x)", main = "f(x) = ln(1+x) and Taylor Series Approximation")
lines(x3, taylor_f3(x3), col = "red", lty = 2)
# Add a legend
legend("bottomright", legend = c("f(x) = ln(1+x)", "Taylor Series Approximation"), col = c("blue", "red"), lty = c(1, 2))
Function and Its Derivatives:
The function \(f(x) = x^{1/2}\) has derivatives that decrease in magnitude but are complicated due to the fractional power:
Evaluate at \(x = 1\):
Construct the Taylor Series:
Using the formula for the Taylor series expanded about \(x = 1\): \[ f(x) = f(1) + f'(1)(x-1) + \frac{f''(1)}{2!}(x-1)^2 + \frac{f'''(1)}{3!}(x-1)^3 + \frac{f''''(1)}{4!}(x-1)^4 + \dots \] This simplifies to: \[ f(x) = 1 + \frac{1}{2}(x - 1) - \frac{1}{8}(x - 1)^2 + \frac{1}{16}(x - 1)^3 - \frac{1}{128}(x - 1)^4 + \dots \]
# Define the function f(x) = sqrt(x) and the Taylor series approximation
f <- function(x) sqrt(x)
taylor_approx <- function(x) {
1 + (x - 1)/2 - (x - 1)^2/8 + (x - 1)^3/16 - (x - 1)^4/128 + (x - 1)^5/256
}
# Create a sequence of x values
x <- seq(0, 2, 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) = sqrt(x) and Taylor Series Approximation")
lines(x, taylor_approx(x), col = "red", lty = 2)
# Add a legend
legend("bottomright", legend = c("f(x) = sqrt(x)", "Taylor Series Approximation"), col = c("blue", "red"), lty = c(1, 2))