今回は、5次までの展開を行い、Rで描写を行います。
以下の数式をR のプログラムとして実装します。
%maclaurin.tex
\documentclass{jsarticle}
\begin{document}
Maclaurin's expansion
\begin{eqnarray}
y = 1 \\
y = 1 + x \\
y = 1 + x + \frac{1}{2}x^2 \\
y = 1 + x + \frac{1}{2}x^2 + \frac{1}{6}x^3 \\
y = 1 + x + \frac{1}{2}x^2 + \frac{1}{6}x^3 + \frac{1}{24}x^4 \\
y = 1 + x + \frac{1}{2}x^2 + \frac{1}{6}x^3 + \frac{1}{24}x^4 + \frac{1}{120}x^5
\end{eqnarray}
\pagestyle{empty}
\end{document}
$ platex maclaurin.tex
$ dvipng -D 500 -T tight maclaurin.dvi
$ R
> source("./command.in")
## command.in ###
# Maclaurin's expansion
png("121024_Maclaurin's expansion.png")
curve(exp(x) , col="black" , ylim=c(0,2), xlim=c(-3,1), ylab="y",xlab="x")
curve(x * 0 + 1 , col="pink", ylim=c(0,1) , add=T )
curve(1 + x , , add = T, col="red" )
curve(1 + x + x^2/2 , , add = T, col="yellow" )
curve(1 + x + x^2/2 + x^3/6,, add = T, col="green" )
curve(1 + x + x^2/2 + x^3/6 + x^4/24, add = T, col="green" )
curve(1 + x + x^2/2 + x^3/6 + x^4/24 + x^5/120, add = T, col="purple" )
abline(h=1, lty=2)
abline(v=0, lty=2)
dev.off()
##################