Q1:

\[f(x) = 1-x\]


The Taylor series \(f(x)\) at \(a\) is defined as:

\(f(x) = f(a) + \frac{f'(a)}{1!}(x-a) + \frac{f''(a)}{2!}(x -a)^2 + \frac{f'''(a)}{3!}(x-a)^3 + ...\)

With a center 0: 1-x

\(= 1 + \frac{f'(1-x)(0)}{1!}x + \frac{f''(1-x)(0)}{2!}x^2 + \frac{f'''(1-x)(0)}{3!}x^3 + ...\)

\(= 1 + \frac{-1}{1!}x + \frac{0}{2!}x^2 + \frac{0}{3!}x^3 + \frac{0}{4!}x^4 + \frac{0}{5!}x^5 + ...\)

\(= 1-x\)

f1 = function(x){
  1-x
}
taylor(f1, 0, 5)
## [1] -1.403922e-07  7.569318e-07  0.000000e+00  0.000000e+00 -1.000000e+00
## [6]  1.000000e+00

Q2:

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


The derivative of \(e^x\) is always \(e^x\)

so,

\(= 1 + \frac{f'x(e^x)(0)}{1!}x + \frac{f''(e^x)(0)}{2!}x^2 + \frac{f'''(e^x)(0)}{3!}x^3 + ...\)

\(= 1 + \frac{1}{1!}x + \frac{1}{2!}x^2 + \frac{1}{3!}x^3 + \frac{1}{4!}x^4 + ...\)

The series sum representation is:

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

f2 = function(x) {
  exp(x)
}

taylor(f2,0,4)
## [1] 0.04166657 0.16666673 0.50000000 1.00000000 1.00000000

Q3:

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


\(= 0 + \frac{f'x(ln(1+x))(0)}{1!}x + \frac{f''(ln(1+x))(0)}{2!}x^2 + \frac{f'''(ln(1+x))(0)}{3!}x^3 + ...\)

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

$= x - x^2 + x^3 - x^4 + x^5 + … $

The sum series representation is:

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

f3 = function(x) {
  log(1+x)
}

taylor(f3, 0, 5)
## [1]  0.2000413 -0.2500044  0.3333339 -0.5000000  1.0000000  0.0000000

Q4:

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


\(= 1 + \frac{f'x(x^{\frac{1}{2}})(1)}{1!}(x - 1) + \frac{f''(x^{\frac{1}{2}})(1)}{2!}(x-1)^2 + \frac{f'''(x^{\frac{1}{2}})(1)}{3!}(x-1)^3 + ...\)

\(= 1 + \frac{{\frac{1}{2}}}{1!}(x - 1) + \frac{-{\frac{1}{4}}}{2!}(x-1)^2 + \frac{{\frac{3}{8}}}{3!}(x-1)^3 + \frac{-{\frac{15}{16}}}{4!}(x-1)^4 ...\)

\(= 1 + \frac{1}{2}(x-1) - \frac{1}{8}(x-1)^2 + \frac{1}{16}(x-1)^3 - \frac{5}{128}(x-1)^4 + ...\)

Thus, the Taylor series \(x^{\frac{1}{2}}\) with center 1 \(= 1 + \frac{1}{2}(x-1) - \frac{1}{8}(x-1)^2 + \frac{1}{16}(x-1)^3 - \frac{5}{128}(x-1)^4 + ...\)