\(f(x) = \frac{1}{1-x}\)

Taylor Series Derivation
  1. Function and Its Derivatives:

    • First derivative \(f'(x) = \frac{1}{(1-x)^2}\)
    • Second derivative \(f''(x) = \frac{2}{(1-x)^3}\)
    • Third derivative \(f'''(x) = \frac{6}{(1-x)^4}\)
    • Fourth derivative \(f''''(x) = \frac{24}{(1-x)^5}\)


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

    • \(f(0) = 1\)
    • \(f'(0) = 1\)
    • \(f''(0) = 2\)
    • \(f'''(0) = 6\)
    • \(f''''(0) = 24\)


  1. 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))


\(f(x) = e^x\)

Taylor Series Derivation
  1. 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\)

    • First derivative \(f'(x) = e^x\)
    • Second derivative \(f''(x) = e^x\)
    • Third derivative \(f'''(x) = e^x\)
    • Fourth derivative \(f''''(x) = e^x\)


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

    • \(f(0) = e^0 = 1\)
    • \(f'(0) = e^0 = 1\)
    • \(f''(0) = e^0 = 1\)
    • \(f'''(0) = e^0 = 1\)
    • \(f''''(0) = e^0 = 1\)


  1. 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))


\(f(x) = \ln(1+x)\)

Taylor Series Derivation
  1. Function and Its Derivatives:

    • First derivative \(f'(x) = \frac{1}{1+x}\)
    • Second derivative \(f''(x) = -\frac{1}{(1+x)^2}\)
    • Third derivative \(f'''(x) = \frac{2}{(1+x)^3}\)
    • Fourth derivative \(f''''(x) = -\frac{6}{(1+x)^4}\)


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

    • \(f(0) = \ln(1+0) = 0\)
    • \(f'(0) = \frac{1}{1+0} = 1\)
    • \(f''(0) = -\frac{1}{(1+0)^2} = -1\)
    • \(f'''(0) = \frac{2}{(1+0)^3} = 2\)
    • \(f''''(0) = -\frac{6}{(1+0)^4} = -6\)


  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) = 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))


\(f(x) = x^{1/2}\)

Taylor Series Derivation
  1. 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:

    • First derivative \(f'(x) = \frac{1}{2}x^{-1/2}\)
    • Second derivative \(f''(x) = -\frac{1}{4}x^{-3/2}\)
    • Third derivative \(f'''(x) = \frac{3}{8}x^{-5/2}\)
    • Fourth derivative \(f''''(x) = -\frac{15}{16}x^{-7/2}\)


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

    • \(f(1) = 1\) (since \(1^{1/2} = 1\))
    • \(f'(1) = \frac{1}{2}\)
    • \(f''(1) = -\frac{1}{4}\)
    • \(f'''(1) = \frac{3}{8}\)
    • \(f''''(1) = -\frac{15}{16}\)


  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))