For each of the following functions, we will derive a Taylor series expansion around a particular point. To do so, we will follow the same general process:

  1. Determine the point a around which we’ll base our approximation.
  2. Find a series of successive derivatives for the function at a, depending on the level of precision we’re looking for.
  3. Use those derivative values as coefficients in our function approximation.

Function 1

\[ f(x) = \frac{1}{(1-x)} \] Because \(f(x)\) is defined at \(0\), it makes sense to set \(a=0\) as a starting point. Now we can derive our function, up to the third derivative (a relatively common standard).

\[ f'(x) = \frac{1}{(x-1)^2} \] \[ f''(x) = -\frac{2}{(x-1)^3} \] \[ f'''(x) = \frac{6}{(x-1)^4} \] Now, we can evaluate these derivatives (and \(f(x)\)) at \(x=0\) to get the coefficients for our polynomial. These values will be divided by \(n!\) corresponding to the power of each term in the polynomial

\[ f(0) = \frac{1}{(1-0)} = 1 \\ \] \[ f'(0) = \frac{1}{(0-1)^2} = 1 \\ \]

\[ f''(0) = -\frac{2}{(0-1)^3} = 2 \\ \]

\[ f'''(0) = \frac{6}{(0-1)^4} = 6 \]

Now, we construct the polynomial with these values serving as the basis for consecutive coefficients of \(x\) to various powers (divided by factorials as noted above), starting at \(0\) and going to \(3\).

\[ f(x) \approx f(0) + f'(0)x + \frac{f''(0)}{2!}x^2 + \frac{f'''(0)}{3!}x^3 \\ \]

\[ \approx 1 + x + \frac{2}{2!}x^2 + \frac{6}{3!}x^3 \\ \]

\[ \approx 1 + x + x^2 + x^3 \] In order to check how well we’ve approximated the function, we can plot both functions around \(0\).

f <- function(x) 1 / (1 -x)
f_t <- function(x) 1 + x + x^2 + x^3

# Setup x range
x <- seq(-2, 2, 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)

Our approximated polynomial appears to hew closely to \(f(x)\) around \(x=0\)

Function 2

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

Following the same process as above, we would take the first, second, and third derivatives of \(f(x)\) to start. Because of the unique properties of \(e^x\), each successive derivative also equals \(e^x\). That means \(f(0)\), \(f'(0)\), \(f''(0)\), and \(f'''(0)\) all equal \(1\).

Given our previous construction:

$$ f(x) f(0) + f’(0)x + x^2 + x^3 \

+ x + x^2 + x^3 $$ Plotting for a visual gut-check:

f <- function(x) exp(1)^x
f_t <- function(x) 1 + x + (1/2)*x^2 + (1/6)*x^3

# Setup x range
x <- seq(-2, 2, 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)

Looks solid!

Function 3

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

Taking derivatives:

\[ f'(x) = \frac{1}{x+1} \\ \]

\[ f''(x) = -\frac{1}{(x+1)^2} \\ \]

\[ f'''(x) = \frac{2}{(x+1)^3} \] Evaluating at \(x=0\):

\[ f(0) = ln(1 + 0) = 0 \\ \]

\[ f'(0) = \frac{1}{0+1} = 1 \\ \]

\[ f''(0) = -\frac{1}{(0+1)^2} = -1 \\ \]

\[ f'''(0) = \frac{2}{(0+1)^3} = 2 \] Plugging values into the above construction:

\[ f(x) \approx f(0) + f'(0)x + \frac{f''(0)}{2!}x^2 + \frac{f'''(0)}{3!}x^3 \\ \]

\[ \approx x + \frac{-1}{2}x^2 + \frac{1}{3}x^3 \] Visual approximation:

f <- function(x) log(1+x)
f_t <- function(x) x - (1/2)*x^2 + (1/3)*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)

Function 4

\[ f(x) = x^{(1/2)} \] Calculating successive derivatives using the power rule:

\[ f'(x) = \frac{1}{2}x^{-(1/2)} \\ \]

\[ f''(x) = -\frac{1}{4}x^{-(3/2)} \\ \]

\[ f'''(x) = \frac{3}{8}x^{-(5/2)} \] Values of each function at \(x=0\):

\[ f(0) = 0^{(1/2)} = 0 \\ \]

\[ f'(0) = \frac{1}{2}(0)^{-(1/2)} = \frac{1}{2} * \frac{1}{\sqrt 0} = undefined \] Because the derivative is undefined at \(0\), we need to find a different \(x\) value around which to build our approximation. Instead, let’s try \(x=1\).

\[ f(1) = 1^{(1/2)} = 1 \\ \]

\[ f'(1) = \frac{1}{2}(1)^{-(1/2)} = \frac{1}{2} \\ \]

\[ f''(1) = -\frac{1}{4}(1)^{-(3/2)} = -\frac{1}{4}\\ \] \[ f'''(1) = \frac{3}{8}(1)^{-(5/2)} = \frac{3}{8} \]

We will construct our polynomial similarly to the above. However, because this is not a Maclaurin series (because we are not using \(x=0\)), we need to subtract our \(a\) value from \(x\) in the formula.

\[ f(x) \approx f(1) + f'(1)(x-1) + \frac{f''(1)}{2!}(x-1)^2 + \frac{f'''(1)}{3!}(x-1)^3 \]

\[ \approx 1 + \frac{1}{2}x + \frac{-\frac{1}{4}}{2}x^2 + \frac{\frac{3}{8}}{6}x^3 \]

\[ \approx 1 + \frac{1}{2}(x-1) - \frac{1}{8}(x-1)^2 + \frac{1}{16}(x-1)^3 \]

Visual check:

f <- function(x) x^(1/2)
f_t <- function(x) 1 + (1/2)*(x-1) - (1/8)*(x-1)^2 + (1/16)*(x-1)^3

# Setup x range
x <- seq(0, 2, 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)