This week, we’ll work out some Taylor Series expansions of popular functions.
\[f (x) = (1−x)\]
\[f (x) = e^x\]
\[f (x) = ln(1 + x)\]
\[f(x)=x^{(1/2)}\]
For each function, only consider its valid ranges as indicated in the notes when you are computing the Taylor Series expansion. Please submit your assignment as an R- Markdown document.
library(tidyverse)
## Warning: package 'dplyr' was built under R version 4.2.3
## Warning: package 'stringr' was built under R version 4.2.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(calculus)
##
## Attaching package: 'calculus'
##
## The following object is masked from 'package:purrr':
##
## cross
\[f (x) = (1−x)\]
taylor("1-x", 0, var = "x", order = 5)
## $f
## [1] "(1) * 1 + (-1) * x^1"
##
## $order
## [1] 5
##
## $terms
## var coef degree
## 0 1 1 0
## 1 x^1 -1 1
## 2 x^2 0 2
## 3 x^3 0 3
## 4 x^4 0 4
## 5 x^5 0 5
\[f (x) = e^x \]
taylor("exp(1)^x", 0, var = "x", order = 5)
## $f
## [1] "(1) * 1 + (1) * x^1 + (0.5) * x^2 + (0.166666666666667) * x^3 + (0.0416666666666667) * x^4 + (0.00833333333333333) * x^5"
##
## $order
## [1] 5
##
## $terms
## var coef degree
## 0 1 1.000000000 0
## 1 x^1 1.000000000 1
## 2 x^2 0.500000000 2
## 3 x^3 0.166666667 3
## 4 x^4 0.041666667 4
## 5 x^5 0.008333333 5
\[f (x) = ln(1 + x)\]
taylor("log(1+x)", 0, var = "x", order = 5)
## $f
## [1] "(1) * x^1 + (-0.5) * x^2 + (0.333333333333333) * x^3 + (-0.25) * x^4 + (0.2) * x^5"
##
## $order
## [1] 5
##
## $terms
## var coef degree
## 0 1 0.0000000 0
## 1 x^1 1.0000000 1
## 2 x^2 -0.5000000 2
## 3 x^3 0.3333333 3
## 4 x^4 -0.2500000 4
## 5 x^5 0.2000000 5
\[f(x)=x^{(1/2)}\]
taylor("x^(1/2)", 0, var = "x", order = 5)
## $f
## [1] "(Inf) * x^1 + (-Inf) * x^2 + (Inf) * x^3 + (-Inf) * x^4 + (Inf) * x^5"
##
## $order
## [1] 5
##
## $terms
## var coef degree
## 0 1 0 0
## 1 x^1 Inf 1
## 2 x^2 -Inf 2
## 3 x^3 Inf 3
## 4 x^4 -Inf 4
## 5 x^5 Inf 5