ローラン級数(Laurent Series)のテイラー展開を試す。

**ローラン級数**（<font color=blue>Laurent Series</font>）の概念が難しく手を焼いています
[ローラン級数 - Wikipedia](https://ja.wikipedia.org/wiki/%E3%83%AD%E3%83%BC%E3%83%A9%E3%83%B3%E7%B4%9A%E6%95%B0)

>負冪の項も含む形での冪級数としての関数の表示のことである。テイラー級数展開できない複素関数を表示する場合に利用される。ローラン級数の名は、最初の発表が<font color=green>1843年</font>に**ピエール・アルフォンス・ローラン**によってなされたことに由来する。ローラン級数の概念自体はそれより先の<font color=green>1841年</font>に**カール・ワイエルシュトラス**によって発見されていたが公表されなかった。

こういう時にはとりあえず例題を動かしてみるに限ります。

**関数**<font color=purple>exp(x)/x+exp(-x)</font>のローラン変換
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20210211/20210211131242.gif)

```R
Macrolin_expansion_Laurent<-function(x){

#グラフのスケール決定
Graph_scale_x<-c(0,3)
Graph_scale_y<-c(0,100)
#関数と凡例の決定
switch(x,
"0"= f0<-function(x) {2*x/x},
"1"= f0<-function(x) {2*(x^-1)+2+x/2},
"2"= f0<-function(x) {(x^-2)/2+2*(x^-1)+2+x/2+(x^2)/6},
"3"= f0<-function(x) {(x^-3)/6+(x^-2)/2+2*(x^-1)+2+x/2+(x^2)/6+(x^3)/24},
"4"= f0<-function(x) {(x^-4)/24+(x^-3)/6+(x^-2)/2+2*(x^-1)+2+x/2+(x^2)/6+(x^3)/24+(x^4)/120},
"5"= f0<-function(x) {(x^-5)/120+(x^-4)/24+(x^-3)/6+(x^-2)/2+2*(x^-1)+2+x/2+(x^2)/6+(x^3)/24+(x^4)/120+(x^5)/720},
"6"= f0<-function(x) {(x^-6)/720+(x^-5)/120+(x^-4)/24+(x^-3)/6+(x^-2)/2+2*(x^-1)+2+x/2+(x^2)/6+(x^3)/24+(x^4)/120+(x^5)/720+(x^6)/5040},
"7"= f0<-function(x) {(x^-7)/5040+(x^-6)/720+(x^-5)/120+(x^-4)/24+(x^-3)/6+(x^-2)/2+2*(x^-1)+2+x/2+(x^2)/6+(x^3)/24+(x^4)/120+(x^5)/720+(x^6)/5040+(x^7)/40320},
"8"= f0<-function(x) {(x^-8)/40320+(x^-7)/5040+(x^-6)/720+(x^-5)/120+(x^-4)/24+(x^-3)/6+(x^-2)/2+2*(x^-1)+2+x/2+(x^2)/6+(x^3)/24+(x^4)/120+(x^5)/720+(x^6)/5040+(x^7)/40320+(x^8)/362880},
"9"= f0<-function(x) {(x^-9)/362880+(x^-8)/40320+(x^-7)/5040+(x^-6)/720+(x^-5)/120+(x^-4)/24+(x^-3)/6+(x^-2)/2+2*(x^-1)+2+x/2+(x^2)/6+(x^3)/24+(x^4)/120+(x^5)/720+(x^6)/5040+(x^7)/40320+(x^8)/362880+(x^9)/3628800}
)

switch(x,
"0"=text<-c("2"),
"1"=text<-c("2x^-1+2+1/2*x/2"),
"2"=text<-c("x^-2/2!+2x^-1+2+1/2*x/2!+x^2/3!"),
"3"=text<-c("x^-3/3!+x^-2/2!+2x^-1+2+1/2*x/2!+x^2/3!+x^3/4!"),
"4"=text<-c("x^-4/4!+x^-3/3!+x^-2/2!+2x^-1+2+1/2*x/2!+x^2/3!+x^3/4!+x^4/5!"),
"5"=text<-c("x^-5/5!+x^-4/4!+x^-3/3!+x^-2/2!+2x^-1+2+1/2*x/2!+x^2/3!+x^3/4!+x^4/5!+x^5/6!"),
"6"=text<-c("x^-6/6!+x^-5/5!+x^-4/4!+x^-3/3!+x^-2/2!+2x^-1+2+1/2*x/2!+x^2/3!+x^3/4!+x^4/5!+x^5/6!+x^6/7!"),
"7"=text<-c("x^-7/7!+x^-6/6!+x^-5/5!+x^-4/4!+x^-3/3!+x^-2/2!+2x^-1+2+1/2*x/2!+x^2/3!+x^3/4!+x^4/5!+x^5/6!+x^6/7!+x^7/8!"),
"8"=text<-c("x^-8/8!+x^-7/7!+x^-6/6!+x^-5/5!+x^-4/4!+x^-3/3!+x^-2/2!+2x^-1+2+1/2*x/2!+x^2/3!+x^3/4!+x^4/5!+x^5/6!+x^6/7!+x^7/8!+x^8/9!"),
"9"=text<-c("x^-9/9!+x^-8/8!+x^-7/7!+x^-6/6!+x^-5/5!+x^-4/4!+x^-3/3!+x^-2/2!+2x^-1+2+1/2*x/2!+x^2/3!+x^3/4!+x^4/5!+x^5/6!+x^6/7!+x^7/8!+x^8/9!+x^9/10!")
)

f1=function(x){exp(x)/x+exp(-x)}

plot(f1,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(0,0,0),main="Laurent expansion", xlab="X", ylab="Y")
par(new=T)#上書き指定
plot(f0,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(1,0,0),main="", xlab="", ylab="")

legend("topright", legend=c("exp(x)/x+exp(-x)",text),lty=c(1,1),col=c(rgb(0,0,0),rgb(1,0,0)))
}

library("animation")
Time_Code=c("0","0","0","1","1","1","2","2","2","3","3","3","4","4","4","5","5","5","6","6","6","7","7","7","8","8","8","9","9","9")
saveGIF({
for (i in Time_Code){
　　Macrolin_expansion_Laurent(i)
}
}, interval = 0.1, movie.name = "Laurent01.gif")
```
あれ、これで合ってるの？　そもそもテイラー展開への理解が決定的に不足しているので何もわかりません。何しろこれまでは著名な関数のそれの表示に使ってただけですからね。
[【Rで球面幾何学】オイラーの公式を導出したマクローリン級数の限界？](https://qiita.com/ochimusha01/items/4a484d5759f96abb0ab3)

#「<font color=purple>収束半径が有限</font>」の場合のテイラー展開

そもそも**テーラー展開**が生成する**演算結果集合**は、それ自体が**演算対象**となるので、当然**演算規則**があります。
[第9回 テイラー展開の計算／ローラン級数](https://www2.yukawa.kyoto-u.ac.jp/~norihiro.tanahashi/pdf/complex-analysis/note_9.pdf)

>展開前の関数<font color=purple>f(z)</font>について変数を<font color=green>z→w</font>と置き換えてからテイラー展開したものは、<font color=purple>f(z)</font>をテイラー展開してから<font color=green>z→w</font>と置き換えたものと同じである。
>
>関数の**和**<font color=purple>f(z)+g(z)</font>の級数展開は、収束半径内では級数の各項の和で与えられる。
>
>関数の**積**<font color=purple>f(z)g(z)</font>の級数展開は、一般には**コーシー積**で与えられるが、場合によってはより単純に計算できる場合もある。
>[コーシー積 - Wikipedia](https://ja.wikipedia.org/wiki/%E3%82%B3%E3%83%BC%E3%82%B7%E3%83%BC%E7%A9%8D)
>
>関数の**微分**<font color=purple>f′(z)</font>、**積分**<font color=purple> ∫f(z)dz</font>をテイラー展開したものは、収束半径の内部においては関数をテイラー展開してから微分・積分を取ったものと等しい。また、収束半径は微分・積分の前後で同じ値となる。工夫をすれば、この性質を利用してテイラー展開を簡単化することもできる。

そもそも基本中の基本を試してませんでした。

<font color=purple>1/(1-x)</font>のテイラー展開
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20210211/20210211185710.gif)

```R
Macrolin_expansion_Laurent<-function(x){

#グラフのスケール決定
Graph_scale_x<-c(0,3)
Graph_scale_y<-c(0,100)
#関数と凡例の決定
switch(x,
"0"= f0<-function(x) {x/x},
"1"= f0<-function(x) {x+1},
"2"= f0<-function(x) {1+x+x^2},
"3"= f0<-function(x) {1+x+x^2+x^3},
"4"= f0<-function(x) {1+x+x^2+x^3+x^4},
"5"= f0<-function(x) {1+x+x^2+x^3+x^4+x^5},
"6"= f0<-function(x) {1+x+x^2+x^3+x^4+x^5+x^6},
"7"= f0<-function(x) {1+x+x^2+x^3+x^4+x^5+x^6+x^7},
"8"= f0<-function(x) {1+x+x^2+x^3+x^4+x^5+x^6+x^7+x^8},
"9"= f0<-function(x) {1+x+x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9}
)

switch(x,
"0"=text<-c("1"),
"1"=text<-c("1+x"),
"2"=text<-c("1+x+x^2"),
"3"=text<-c("1+x+x^2+x^3"),
"4"=text<-c("1+x+x^2+x^3+x^4"),
"5"=text<-c("1+x+x^2+x^3+x^4+x^5"),
"6"=text<-c("1+x+x^2+x^3+x^4+x^5+x^6"),
"7"=text<-c("1+x+x^2+x^3+x^4+x^5+x^6+x^7"),
"8"=text<-c("1+x+x^2+x^3+x^4+x^5+x^6+x^7+x^8"),
"9"=text<-c("1+x+x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9")
)

f1=function(x){1/(1-x)}

plot(f1,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(0,0,0),main="Macrolin expansion", xlab="X", ylab="Y")
par(new=T)#上書き指定
plot(f0,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(1,0,0),main="", xlab="", ylab="")

legend("topright", legend=c("1/(1-x)",text),lty=c(1,1),col=c(rgb(0,0,0),rgb(1,0,0)))
}

library("animation")
Time_Code=c("0","0","0","1","1","1","2","2","2","3","3","3","4","4","4","5","5","5","6","6","6","7","7","7","8","8","8","9","9","9")
saveGIF({
for (i in Time_Code){
　　Macrolin_expansion_Laurent(i)
}
}, interval = 0.1, movie.name = "Macrolin02.gif")
```
<font color=purple>1/(1-x)^2</font>のテイラー展開
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20210211/20210211194947.gif)

```R
Macrolin_expansion_Laurent<-function(x){

#グラフのスケール決定
Graph_scale_x<-c(0,3)
Graph_scale_y<-c(0,100)
#関数と凡例の決定
switch(x,
"0"= f0<-function(x) {x/x},
"1"= f0<-function(x) {2*x+1},
"2"= f0<-function(x) {1+2*x+3*x^2},
"3"= f0<-function(x) {1+2*x+3*x^2+4*x^3},
"4"= f0<-function(x) {1+2*x+3*x^2+4*x^3+5*x^4},
"5"= f0<-function(x) {1+2*x+3*x^2+4*x^3+5*x^4+6*x^5},
"6"= f0<-function(x) {1+2*x+3*x^2+4*x^3+5*x^4+6*x^5+7*x^6},
"7"= f0<-function(x) {1+2*x+3*x^2+4*x^3+5*x^4+6*x^5+7*x^6+8*x^7},
"8"= f0<-function(x) {1+2*x+3*x^2+4*x^3+5*x^4+6*x^5+7*x^6+8*x^7+9*x^8},
"9"= f0<-function(x) {1+2*x+3*x^2+4*x^3+5*x^4+6*x^5+7*x^6+8*x^7+9*x^8+10*x^9}
)

switch(x,
"0"=text<-c("1"),
"1"=text<-c("1+2x"),
"2"=text<-c("1+2x+3x^2"),
"3"=text<-c("1+2x+3x^2+4x^3"),
"4"=text<-c("1+2x+3x^2+4x^3+5x^4"),
"5"=text<-c("1+2x+3x^2+4x^3+5x^4+6x^5"),
"6"=text<-c("1+2x+3x^2+4x^3+5x^4+6x^5+7x^6"),
"7"=text<-c("1+2x+3x^2+4x^3+5x^4+6x^5+7x^6+8x^7"),
"8"=text<-c("1+2x+3x^2+4x^3+5x^4+6x^5+7x^6+8x^7+9x^8"),
"9"=text<-c("1+2x+3x^2+4x^3+5x^4+6x^5+7x^6+8x^7+9x^8+10x^9")
)

f1=function(x){1/(1-x)^2}

plot(f1,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(0,0,0),main="Macrolin expansion", xlab="X", ylab="Y")
par(new=T)#上書き指定
plot(f0,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(1,0,0),main="", xlab="", ylab="")

legend("topright", legend=c("1/(1-x)^2",text),lty=c(1,1),col=c(rgb(0,0,0),rgb(1,0,0)))
}

library("animation")
Time_Code=c("0","0","0","1","1","1","2","2","2","3","3","3","4","4","4","5","5","5","6","6","6","7","7","7","8","8","8","9","9","9")
saveGIF({
for (i in Time_Code){
　　Macrolin_expansion_Laurent(i)
}
}, interval = 0.1, movie.name = "Macrolin05.gif")
```
次いで<font color=purple>1/(1+x)</font>のテイラー展開。
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20210211/20210211191215.gif)

```R
Macrolin_expansion_Laurent<-function(x){

#グラフのスケール決定
Graph_scale_x<-c(0,100)
Graph_scale_y<-c(0,2)
#関数と凡例の決定
switch(x,
"0"= f0<-function(x) {x/x},
"1"= f0<-function(x) {1-x},
"2"= f0<-function(x) {1-x+x^2},
"3"= f0<-function(x) {1-x+x^2-x^3},
"4"= f0<-function(x) {1-x+x^2-x^3+x^4},
"5"= f0<-function(x) {1-x+x^2-x^3+x^4-x^5},
"6"= f0<-function(x) {1-x+x^2-x^3+x^4-x^5+x^6},
"7"= f0<-function(x) {1-x+x^2-x^3+x^4-x^5+x^6-x^7},
"8"= f0<-function(x) {1-x+x^2-x^3+x^4-x^5+x^6-x^7+x^8},
"9"= f0<-function(x) {1-x+x^2-x^3+x^4-x^5+x^6-x^7+x^8-x^9}
)

switch(x,
"0"=text<-c("1"),
"1"=text<-c("1-x"),
"2"=text<-c("1-x+x^2"),
"3"=text<-c("1-x+x^2-x^3"),
"4"=text<-c("1-x+x^2-x^3+x^4"),
"5"=text<-c("1-x+x^2-x^3+x^4-x^5"),
"6"=text<-c("1-x+x^2-x^3+x^4-x^5+x^6"),
"7"=text<-c("1-x+x^2-x^3+x^4-x^5+x^6-x^7"),
"8"=text<-c("1-x+x^2-x^3+x^4-x^5+x^6-x^7+x^8"),
"9"=text<-c("1-x+x^2-x^3+x^4-x^5+x^6-x^7+x^8-x^9")
)

f1=function(x){1/(1+x)}

plot(f1,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(0,0,0),main="Macrolin expansion", xlab="X", ylab="Y")
par(new=T)#上書き指定
plot(f0,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(1,0,0),main="", xlab="", ylab="")

legend("topright", legend=c("1/(1+x)",text),lty=c(1,1),col=c(rgb(0,0,0),rgb(1,0,0)))
}

library("animation")
Time_Code=c("0","0","0","1","1","1","2","2","2","3","3","3","4","4","4","5","5","5","6","6","6","7","7","7","8","8","8","9","9","9")
saveGIF({
for (i in Time_Code){
　　Macrolin_expansion_Laurent(i)
}
}, interval = 0.1, movie.name = "Macrolin03.gif")
```
そのアップ。収束遅い!!
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20210211/20210211191913.gif)

```R
Macrolin_expansion_Laurent<-function(x){

#グラフのスケール決定
Graph_scale_x<-c(0,2)
Graph_scale_y<-c(0,2)
#関数と凡例の決定
switch(x,
"0"= f0<-function(x) {x/x},
"1"= f0<-function(x) {1-x},
"2"= f0<-function(x) {1-x+x^2},
"3"= f0<-function(x) {1-x+x^2-x^3},
"4"= f0<-function(x) {1-x+x^2-x^3+x^4},
"5"= f0<-function(x) {1-x+x^2-x^3+x^4-x^5},
"6"= f0<-function(x) {1-x+x^2-x^3+x^4-x^5+x^6},
"7"= f0<-function(x) {1-x+x^2-x^3+x^4-x^5+x^6-x^7},
"8"= f0<-function(x) {1-x+x^2-x^3+x^4-x^5+x^6-x^7+x^8},
"9"= f0<-function(x) {1-x+x^2-x^3+x^4-x^5+x^6-x^7+x^8-x^9}
)

switch(x,
"0"=text<-c("1"),
"1"=text<-c("1-x"),
"2"=text<-c("1-x+x^2"),
"3"=text<-c("1-x+x^2-x^3"),
"4"=text<-c("1-x+x^2-x^3+x^4"),
"5"=text<-c("1-x+x^2-x^3+x^4-x^5"),
"6"=text<-c("1-x+x^2-x^3+x^4-x^5+x^6"),
"7"=text<-c("1-x+x^2-x^3+x^4-x^5+x^6-x^7"),
"8"=text<-c("1-x+x^2-x^3+x^4-x^5+x^6-x^7+x^8"),
"9"=text<-c("1-x+x^2-x^3+x^4-x^5+x^6-x^7+x^8-x^9")
)

f1=function(x){1/(1+x)}

plot(f1,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(0,0,0),main="Macrolin expansion", xlab="X", ylab="Y")
par(new=T)#上書き指定
plot(f0,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(1,0,0),main="", xlab="", ylab="")

legend("topright", legend=c("1/(1+x)",text),lty=c(1,1),col=c(rgb(0,0,0),rgb(1,0,0)))
}

library("animation")
Time_Code=c("0","0","0","1","1","1","2","2","2","3","3","3","4","4","4","5","5","5","6","6","6","7","7","7","8","8","8","9","9","9")
saveGIF({
for (i in Time_Code){
　　Macrolin_expansion_Laurent(i)
}
}, interval = 0.1, movie.name = "Macrolin04.gif")
```

ついでに<font color=purple>1/(1+x)^2</font>のテイラー展開。
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20210211/20210211200256.gif)

```R
Macrolin_expansion_Laurent<-function(x){

#グラフのスケール決定
Graph_scale_x<-c(0,100)
Graph_scale_y<-c(0,2)
#関数と凡例の決定
switch(x,
"0"= f0<-function(x) {x/x},
"1"= f0<-function(x) {1-2*x},
"2"= f0<-function(x) {1-2*x+3*x^2},
"3"= f0<-function(x) {1-2*x+3*x^2-4*x^3},
"4"= f0<-function(x) {1-2*x+3*x^2-4*x^3+5*x^4},
"5"= f0<-function(x) {1-2*x+3*x^2-4*x^3+5*x^4-6*x^5},
"6"= f0<-function(x) {1-2*x+3*x^2-4*x^3+5*x^4-6*x^5+7*x^6},
"7"= f0<-function(x) {1-2*x+3*x^2-4*x^3+5*x^4-6*x^5+7*x^6-8*x^7},
"8"= f0<-function(x) {1-2*x+3*x^2-4*x^3+5*x^4-6*x^5+7*x^6-8*x^7+9*x^8},
"9"= f0<-function(x) {1-2*x+3*x^2-4*x^3+5*x^4-6*x^5+7*x^6-8*x^7+9*x^8-10*x^9}
)

switch(x,
"0"=text<-c("1"),
"1"=text<-c("1-2x"),
"2"=text<-c("1-2x+3x^2"),
"3"=text<-c("1-2x+3x^2-4x^3"),
"4"=text<-c("1-2x+3x^2-4x^3+5x^4"),
"5"=text<-c("1-2x+3x^2-4x^3+5x^4-6x^5"),
"6"=text<-c("1-2x+3x^2-4x^3+5x^4-6x^5+7x^6"),
"7"=text<-c("1-2x+3x^2-4x^3+5x^4-6x^5+7x^6-8x^7"),
"8"=text<-c("1-2x+3x^2-4x^3+5x^4-6x^5+7x^6-8x^7+9x^8"),
"9"=text<-c("1-2x+3x^2-4x^3+5x^4-6x^5+7x^6-8x^7+9x^8-10x^9")
)

f1=function(x){1/(1+x)^2}

plot(f1,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(0,0,0),main="Macrolin expansion", xlab="X", ylab="Y")
par(new=T)#上書き指定
plot(f0,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(1,0,0),main="", xlab="", ylab="")

legend("topright", legend=c("1/(1+x)^2",text),lty=c(1,1),col=c(rgb(0,0,0),rgb(1,0,0)))
}

library("animation")
Time_Code=c("0","0","0","1","1","1","2","2","2","3","3","3","4","4","4","5","5","5","6","6","6","7","7","7","8","8","8","9","9","9")
saveGIF({
for (i in Time_Code){
　　Macrolin_expansion_Laurent(i)
}
}, interval = 0.1, movie.name = "Macrolin06.gif")
```
そのアップ。
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20210211/20210211200634.gif)

```R
Macrolin_expansion_Laurent<-function(x){

#グラフのスケール決定
Graph_scale_x<-c(0,2)
Graph_scale_y<-c(0,2)
#関数と凡例の決定
switch(x,
"0"= f0<-function(x) {x/x},
"1"= f0<-function(x) {1-2*x},
"2"= f0<-function(x) {1-2*x+3*x^2},
"3"= f0<-function(x) {1-2*x+3*x^2-4*x^3},
"4"= f0<-function(x) {1-2*x+3*x^2-4*x^3+5*x^4},
"5"= f0<-function(x) {1-2*x+3*x^2-4*x^3+5*x^4-6*x^5},
"6"= f0<-function(x) {1-2*x+3*x^2-4*x^3+5*x^4-6*x^5+7*x^6},
"7"= f0<-function(x) {1-2*x+3*x^2-4*x^3+5*x^4-6*x^5+7*x^6-8*x^7},
"8"= f0<-function(x) {1-2*x+3*x^2-4*x^3+5*x^4-6*x^5+7*x^6-8*x^7+9*x^8},
"9"= f0<-function(x) {1-2*x+3*x^2-4*x^3+5*x^4-6*x^5+7*x^6-8*x^7+9*x^8-10*x^9}
)

switch(x,
"0"=text<-c("1"),
"1"=text<-c("1-2x"),
"2"=text<-c("1-2x+3x^2"),
"3"=text<-c("1-2x+3x^2-4x^3"),
"4"=text<-c("1-2x+3x^2-4x^3+5x^4"),
"5"=text<-c("1-2x+3x^2-4x^3+5x^4-6x^5"),
"6"=text<-c("1-2x+3x^2-4x^3+5x^4-6x^5+7x^6"),
"7"=text<-c("1-2x+3x^2-4x^3+5x^4-6x^5+7x^6-8x^7"),
"8"=text<-c("1-2x+3x^2-4x^3+5x^4-6x^5+7x^6-8x^7+9x^8"),
"9"=text<-c("1-2x+3x^2-4x^3+5x^4-6x^5+7x^6-8x^7+9x^8-10x^9")
)

f1=function(x){1/(1+x)^2}

plot(f1,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(0,0,0),main="Macrolin expansion", xlab="X", ylab="Y")
par(new=T)#上書き指定
plot(f0,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(1,0,0),main="", xlab="", ylab="")

legend("topright", legend=c("1/(1+x)^2",text),lty=c(1,1),col=c(rgb(0,0,0),rgb(1,0,0)))
}

library("animation")
Time_Code=c("0","0","0","1","1","1","2","2","2","3","3","3","4","4","4","5","5","5","6","6","6","7","7","7","8","8","8","9","9","9")
saveGIF({
for (i in Time_Code){
　　Macrolin_expansion_Laurent(i)
}
}, interval = 0.1, movie.name = "Macrolin07.gif")
```
とりあえず「**関数に収束半径がある**」とはこういうイメージで、それに対して**テイラー級数**/**マクローリン級数**はこう展開されるという話ですね。

* そういえば<font color=purple>log(1+x)</font>と<font color=purple>-log(1-x)</font>と両者の和<font color=purple>log((1-x)/(1+x))</font>(<font color=blue>収束半径1</font>)という特殊ケースについては既に邂逅済みだったが、この場合もまだ**ローラン変換**の出番はなかったのである。<br>[【Rで球面幾何学】オイラーの公式を導出したマクローリン級数の限界？](https://qiita.com/ochimusha01/items/4a484d5759f96abb0ab3)<br>![image.gif](https://qiita-user-contents.imgix.net/https%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Fo%2Fochimusha01%2F20210204%2F20210204091231.gif?ixlib=rb-1.2.2&auto=format&gif-q=60&q=75&w=1400&fit=max&s=e2324af520a612da1030d9bc019c7879)

#最も簡単なローラン級数(<font color=blue>Laurent Series</font>)の例

[第9回 テイラー展開の計算／ローラン級数](https://www2.yukawa.kyoto-u.ac.jp/~norihiro.tanahashi/pdf/complex-analysis/note_9.pdf)

><font color=purple>1/(z(1−z))</font>を**原点**<font color=green>z0=0</font>の周りでローラン展開するときは、<font color=purple>1/z×1/(1-z)</font>と書き換えてから、<font color=purple>1/(1−z)</font>を**原点**<font color=purple>z0=0</font>の周りでテイラー展開すればよい。この級数の収束領域は、**円形領域**<font color=purple>|z|<1</font>から**原点**<font color=green>z=0</font>を除いた領域となる。

![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20210212/20210212033610.gif)

```R
Laurent_expansion<-function(x){

#グラフのスケール決定
Graph_scale_x<-c(0,3)
Graph_scale_y<-c(0,100)
#関数と凡例の決定
switch(x,
"0"= f0<-function(x) {1/x},
"1"= f0<-function(x) {1/x+1},
"2"= f0<-function(x) {1/x+1+x},
"3"= f0<-function(x) {1/x+1+x+x^2},
"4"= f0<-function(x) {1/x+1+x+x^2+x^3},
"5"= f0<-function(x) {1/x+1+x+x^2+x^3+x^4},
"6"= f0<-function(x) {1/x+1+x+x^2+x^3+x^4+x^5},
"7"= f0<-function(x) {1/x+1+x+x^2+x^3+x^4+x^5+x^6},
"8"= f0<-function(x) {1/x+1+x+x^2+x^3+x^4+x^5+x^6+x^7},
"9"= f0<-function(x) {1/x+1+x+x^2+x^3+x^4+x^5+x^6+x^7+x^8}
)

switch(x,
"0"=text<-c("1/x"),
"1"=text<-c("1/x+1"),
"2"=text<-c("1/x+1+x"),
"3"=text<-c("1/x+1+x+x^2"),
"4"=text<-c("1/x+1+x+x^2+x^3"),
"5"=text<-c("1/x+1+x+x^2+x^3+x^4"),
"6"=text<-c("1/x+1+x+x^2+x^3+x^4+x^5"),
"7"=text<-c("1/x+1+x+x^2+x^3+x^4+x^5+x^6"),
"8"=text<-c("1/x+1+x+x^2+x^3+x^4+x^5+x^6+x^7"),
"9"=text<-c("1/x+1+x+x^2+x^3+x^4+x^5+x^6+x^7+x^8")
)

f1=function(x){1/(x*(1-x))}

plot(f1,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(0,0,0),main="Laurent expansion", xlab="X", ylab="Y")
par(new=T)#上書き指定
plot(f0,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(1,0,0),main="", xlab="", ylab="")

legend("topright", legend=c("1/(x*(1-x)",text),lty=c(1,1),col=c(rgb(0,0,0),rgb(1,0,0)))
}

library("animation")
Time_Code=c("0","0","0","1","1","1","2","2","2","3","3","3","4","4","4","5","5","5","6","6","6","7","7","7","8","8","8","9","9","9")
saveGIF({
for (i in Time_Code){
　　Laurent_expansion(i)
}
}, interval = 0.1, movie.name = "Laurent02.gif")
```

>同じ関数<font color=purple>1/(z(1−z))</font>を**原点**<font color=green>z0=1</font>の周りでローラン展開するときは、<font color=purple>1/(1-z)×(-1/z)</font>と書き換えてから、<font color=purple>-1/z</font>を**原点**<font color=purple>z0=1</font>の周りでテイラー展開すればよい。この級数の収束領域は、**円形領域**<font color=purple>|z|<1</font>から**原点**<font color=green>z=1</font>を除いた領域となる。

![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20210212/20210212042719.gif)
<font color=red>＊何か間違ってる気もするけど、現時点の私には直せません(2021.2.12)</font>

```R
Laurent_expansion<-function(x){

#グラフのスケール決定
Graph_scale_x<-c(0,3)
Graph_scale_y<-c(-100,100)
#関数と凡例の決定
switch(x,
"0"= f0<-function(x) {-1/(1-x)},
"1"= f0<-function(x) {-1/(1-x)+1},
"2"= f0<-function(x) {-1/(1-x)+1-(x-1)},
"3"= f0<-function(x) {-1/(1-x)+1-(x-1)+(x-1)^2},
"4"= f0<-function(x) {-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3},
"5"= f0<-function(x) {-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3+(x-1)^4},
"6"= f0<-function(x) {-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5},
"7"= f0<-function(x) {-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5+(x-1)^6},
"8"= f0<-function(x) {-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5+(x-1)^6+(x-1)^7},
"9"= f0<-function(x) {-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5+(x-1)^6+(x-1)^7+(x-1)^8}
)

switch(x,
"0"=text<-c("-1/(1-x)"),
"1"=text<-c("-1/(1-x)+1"),
"2"=text<-c("-1/(1-x)+1-(x-1)"),
"3"=text<-c("-1/(1-x)+1-(x-1)+(x-1)^2"),
"4"=text<-c("-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3"),
"5"=text<-c("-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3+(x-1)^4"),
"6"=text<-c("-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5"),
"7"=text<-c("-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5+(x-1)^6"),
"8"=text<-c("-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5+(x-1)^6+(x-1)^7"),
"9"=text<-c("-1/(1-x)+(x-1)-(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5+(x-1)^6+(x-1)^7+(x-1)^8")
)

f1=function(x){1/(x*(1-x))}

plot(f1,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(0,0,0),main="Laurent expansion", xlab="X", ylab="Y")
par(new=T)#上書き指定
plot(f0,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(1,0,0),main="", xlab="", ylab="")

legend("topright", legend=c("1/(x*(1-x)",text),lty=c(1,1),col=c(rgb(0,0,0),rgb(1,0,0)))
}

library("animation")
Time_Code=c("0","0","0","1","1","1","2","2","2","3","3","3","4","4","4","5","5","5","6","6","6","7","7","7","8","8","8","9","9","9")
saveGIF({
for (i in Time_Code){
　　Laurent_expansion(i)
}
}, interval = 0.1, movie.name = "Laurent03.gif")
```
<font color=red>符号を逆転してみたら混沌が広がりました。チェルノブイリ!!(2021.2.12)。</font>
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20210212/20210212122141.gif)

```R
Laurent_expansion<-function(x){

#グラフのスケール決定
Graph_scale_x<-c(0,3)
Graph_scale_y<-c(-100,100)
#関数と凡例の決定
switch(x,
"0"= f0<-function(x) {1/(1+x)},
"1"= f0<-function(x) {1/(1+x)+1},
"2"= f0<-function(x) {1/(1+x)+1-(x+1)},
"3"= f0<-function(x) {1/(1+x)+1-(x+1)+(x+1)^2},
"4"= f0<-function(x) {1/(1+x)+1-(x+1)+(x+1)^2+(x+1)^3},
"5"= f0<-function(x) {1/(1+x)+1-(x+1)+(x+1)^2+(x+1)^3+(x+1)^4},
"6"= f0<-function(x) {1/(1+x)+1-(x+1)+(x+1)^2+(x+1)^3+(x+1)^4+(x+1)^5},
"7"= f0<-function(x) {1/(1+x)+1-(x+1)+(x+1)^2+(x+1)^3+(x+1)^4+(x+1)^5+(x+1)^6},
"8"= f0<-function(x) {1/(1+x)+1-(x+1)+(x+1)^2+(x+1)^3+(x+1)^4+(x+1)^5+(x+1)^6+(x+1)^7},
"9"= f0<-function(x) {1/(1+x)+1-(x+1)+(x+1)^2+(x+1)^3+(x+1)^4+(x+1)^5+(x+1)^6+(x+1)^7+(x+1)^8}
)

switch(x,
"0"=text<-c("-1/(1-x)"),
"1"=text<-c("-1/(1-x)+1"),
"2"=text<-c("-1/(1-x)+1-(x-1)"),
"3"=text<-c("-1/(1-x)+1-(x-1)+(x-1)^2"),
"4"=text<-c("-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3"),
"5"=text<-c("-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3+(x-1)^4"),
"6"=text<-c("-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5"),
"7"=text<-c("-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5+(x-1)^6"),
"8"=text<-c("-1/(1-x)+1-(x-1)+(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5+(x-1)^6+(x-1)^7"),
"9"=text<-c("-1/(1-x)+(x-1)-(x-1)^2+(x-1)^3+(x-1)^4+(x-1)^5+(x-1)^6+(x-1)^7+(x-1)^8")
)

f1=function(x){1/(x*(1-x))}

plot(f1,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(0,0,0),main="Laurent expansion", xlab="X", ylab="Y")
par(new=T)#上書き指定
plot(f0,xlim=Graph_scale_x,ylim=Graph_scale_y,type="l",col=rgb(1,0,0),main="", xlab="", ylab="")

legend("topright", legend=c("1/(x*(1-x)",text),lty=c(1,1),col=c(rgb(0,0,0),rgb(1,0,0)))
}

library("animation")
Time_Code=c("0","0","0","1","1","1","2","2","2","3","3","3","4","4","4","5","5","5","6","6","6","7","7","7","8","8","8","9","9","9")
saveGIF({
for (i in Time_Code){
　　Laurent_expansion(i)
}
}, interval = 0.1, movie.name = "Laurent04.gif")
```

もっと複素解析についての基礎知識を蓄えないと**ローラン変換**の世界(<font color=blue>つまりそれを必要とする領域</font>)には進めない様です。それが分かった時点で以下続報…