Problem Statement

This week, we’ll work out some Taylor Series expansions of popular functions.

• f(x) = 1/(1−x)
• f(x) = ex
• f(x) = ln(1+x)

For each function, only consider its valid ranges as indicated in the notes when you are computing the Taylor Series expansion.



Problem 1

The general formula for expanding a Taylor series is

\(f(x)\ =\sum _{ n=0 }^{ \infty }{ \frac { { f }^{ (n) }{ (c) } }{ n! } } { (x-c) }^{ n }\)

where f(n) is the nth derivative of f.

Here:

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

the derivatives can be found using the chain and power rules:

\(\frac { d }{ dx } \frac { 1 }{ 1-x } ,\quad where\quad \frac { d }{ du } \frac { 1 }{ u } \frac { du }{ dx } ,\quad u=1-x\quad and\quad \frac { d }{ du } \frac { 1 }{ u } =-\frac { 1 }{ { u }^{ 2 } }\)

\(=\frac { -1 }{ { (1-x) }^{ 2 } } \frac { d }{ dx } (1)-\frac { d }{ dx } (x)\ =\frac { 1 }{ { (1-x) }^{ 2 } }\)

And so on such that:

\({ f }^{ \prime }(0)=\frac { 1 }{ { (1-0) }^{ 2 } } =1,\quad { f }^{ \prime \prime }(0)=\frac { 2 }{ { (1-0) }^{ 3 } } =2,\quad { f }^{ \prime \prime \prime }(0)=\frac { 6 }{ { (1-0) }^{ 4 } } =6,\ ...\ { f }^{ (n)\ }(0)=\frac { n! }{ { 1 }^{ n } } =n!\quad\)

Applying our general formula leads to:

\(f(\frac { 1 }{ 1-x } )=1+\frac { 1 }{ 1! } x+\frac { 2 }{ 2! } { x }^{ 2 }+\frac { 6 }{ 3! } { x }^{ 3 }+\frac { 24 }{ 4! } { x }^{ 4 }...\frac { n! }{ n! } { x }^{ n }=\sum _{ n=0 }^{ \infty }{ { x }^{ n } }\)

We can confirm the derivative computations with R:

# our function
g <- makeFun(1/(1-x) ~ x)

# derivatives 1-4
g1 <- D(g(x)~x)
g2 <- D(g1(x)~x)
g3 <- D(g2(x)~x)
g4 <- D(g3(x)~x)

# print results
g1(0); g2(0); g3(0); g4(0)
## [1] 1
## [1] 2
## [1] 6
## [1] 24


Problem 2

Since:

\({ f }^{ \prime }(x)\ =\ { e }^{ x }\) and generally \({ f }^{ n }(x)\ ={ \ e }^{ x }\)

Then:

\({ f }^{ \prime }(0)=1,\ { f }^{ \prime \prime }(0)=1,\ { f }^{ \prime \prime \prime }(0)=1\ ...\)

And again following our general formula, the series is:

\({ e }^{ x }=1+x+\frac { 1 }{ 2! } { x }^{ 2 }+\frac { 1 }{ 3! } { x }^{ 3 }+\frac { 1 }{ 4! } { x }^{ 4 }...\frac { 1 }{ n! } { x }^{ n }=\sum _{ n=0 }^{ \infty }{ \frac { { x }^{ n } }{ n! } }\)



Problem 3

Here

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

Find our derivatives for the numerator using chain rule and elementary functions:

\(\frac { d }{ dx } log(\frac { 1 }{ 1+x } ),\ where\ \frac { d }{ du } \frac { 1 }{ u } \frac { du }{ dx } ,\ u=1+x\ and\ \frac { d }{ du } log(u)=\frac { 1 }{ u }\)

Computing futher order derivatives, we see a pattern:

\({ f }^{ \prime }(x)=\frac { 1 }{ { (1+x) }^{ 2 } } ,\quad { f }^{ \prime \prime }(x)=\frac { -2 }{ { (1+x) }^{ 3 } } ,\ { f }^{ \prime \prime \prime }(x)=\frac { 6 }{ { (1-x) }^{ 4 } } ,\ { f }^{ \prime \prime \prime \prime }(x)=\frac { -24 }{ { (1-x) }^{ 5 } } ,\ ...\ { f }^{ (n)\ }(x)={ (-1) }^{ n+1 }\frac { n! }{ { (1-x) }^{ n } }\)

Appling the general rule:

\(=\ 0\ +\frac { -1 }{ 1! } x+\frac { 2 }{ 2! } { x }^{ 2 }+\frac { -6 }{ 3! } { x }^{ 3 }+\frac { 24 }{ 4! } { x }^{ 4 }...=\sum _{ n=0 }^{ \infty }{ { { (-1) }^{ n+1 }\frac { { x }^{ n } }{ n } } }\)

Another easier solution is to substitute using the known Taylor series for natural logs:

\(ln(x)\ =\ \sum _{ n=0 }^{ \infty }{ { { (-1) }^{ n+1 }\frac { { (x-1) }^{ n } }{ n } } }\)

Substituting ln(x+1):

\(ln(x)\ =\ \sum _{ n=0 }^{ \infty }{ { { (-1) }^{ n+1 }\frac { { (x+1-1) }^{ n } }{ n } } } =\quad \sum _{ n=0 }^{ \infty }{ { { (-1) }^{ n+1 }\frac { { x }^{ n } }{ n } } }\)

Checking our derivatives:

# our function
f <- makeFun(log(1+x) ~ x)

# derivatives 1-4
f1 <- D(f(x)~x)
f2 <- D(f1(x)~x)
f3 <- D(f2(x)~x)
f4 <- D(f3(x)~x)

# print results
f1(0); f2(0); f3(0); f4(0)
## [1] 1
## [1] -1
## [1] 2
## [1] -6