Computational Mathematics - Taylor Series Approximations

Euclides Rodriguez

2022-05-09

Introduction

Work out some Taylor Series expansions of the following popular functions

Library

library(Deriv)

Excercise 1

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

f_x <- function(x){1/(1-x)}
f_x(0)
## [1] 1
f1_x <- Deriv(f_x)
f1_x(0)
## [1] 1
f2_x <- Deriv(f1_x)
f2_x(0)
## [1] 2
f3_x <- Deriv(f2_x)
f3_x(0)
## [1] 6
f4_x <- Deriv(f3_x)
f4_x(0)
## [1] 24

\[\frac{1}{1-x}= 1 + x + x^{2}+x^3+x^4\]

Excercise 2

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

f_x <- function(x){exp(x)}
f_x(0)
## [1] 1
f1_x <- Deriv(f_x)
f1_x(0)
## [1] 1
f2_x <- Deriv(f1_x)
f2_x(0)
## [1] 1
f3_x <- Deriv(f2_x)
f3_x(0)
## [1] 1
f4_x <- Deriv(f3_x)
f4_x(0)
## [1] 1

\[e^{x}= 1 + x + \frac{x^{2}}{2!}+ \frac{x^{3}}{3!} + \frac{x^{4}}{4!}\]

Excercise 3

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

f_x <- function(x){log(1+x)}
f_x(0)
## [1] 0
f1_x <- Deriv(f_x)
f1_x(0)
## [1] 1
f2_x <- Deriv(f1_x)
f2_x(0)
## [1] -1
f3_x <- Deriv(f2_x)
f3_x(0)
## [1] 2
f4_x <- Deriv(f3_x)
f4_x(0)
## [1] -6

\[ln(1+x)= x - \frac{x^{2}}{2!}+ \frac{2x^{3}}{3!} - \frac{6x^{4}}{4!}\]

Excercise 4

\[f(x) = x^{1/2}\] Taylor series not applicable at c=0.

f_x <- function(x){x^.5}
f_x(0)
## [1] 0
f1_x <- Deriv(f_x)
f1_x(0)
## [1] Inf
f2_x <- Deriv(f1_x)
f2_x(0)
## [1] -Inf
f3_x <- Deriv(f2_x)
f3_x(0)
## [1] NaN
f4_x <- Deriv(f3_x)
f4_x(0)
## [1] NaN

Excercise 5

\[f(x) = e^{-x}\]

f_x <- function(x){exp(-x)}
f_x(0)
## [1] 1
f1_x <- Deriv(f_x)
f1_x(0)
## [1] -1
f2_x <- Deriv(f1_x)
f2_x(0)
## [1] 1
f3_x <- Deriv(f2_x)
f3_x(0)
## [1] -1
f4_x <- Deriv(f3_x)
f4_x(0)
## [1] 1

\[e^{-x}= 1 - x + \frac{x^{2}}{2!}- \frac{x^{3}}{3!} + \frac{x^{4}}{4!}\]