マクローリン展開をお勉強（おまけ）


### [前回「マクローリン展開をお勉強(Python)」](https://qiita.com/yellow_detteiu/items/d0c10d7158a620a08144)の続きです。

```Python:McLaughlin2.py
import numpy as np
import matplotlib.pyplot as plt

def kaijyo(n):
    result = 1
    for i in range(1, n+1):
        result *= i
    return result

def sin(x, n):
    result = 0
    for i in range(1, n+1):
        result += (-1)**(i+1) * (1 / kaijyo(2*i-1)) * x**(2*i-1)
    return result

def cos(x, n):
    result = 1
    for i in range(1, n+1):
        result += (-1)**(i+1) * 1 / kaijyo(2 * (i-1)) * x**(2*(i-1))
    return result

def tan(x, n):
    return sin(x, n) / cos(x, n)

def arctan(x, n):
    result = 0
    for i in range(1, n+1):
        result += (-1)**(i+1) * x**(2*i-1) / (2*i-1)
    return result

x = np.linspace(-2 * np.pi, 2 * np.pi, 101)

for n in range(1, 11, 1):
    plt.plot(x, sin(x, n)**2, label = str(n) + "D")

plt.legend()
plt.ylim(-2,4)
plt.show()

for n in range(1, 11, 1):
    plt.plot(x, cos(x, n)**2, label = str(n) + "D")

plt.legend()
plt.ylim(-2,4)
plt.show()

for n in range(1, 11, 1):
    plt.plot(x, tan(x, n)**2, label = str(n) + "D")

plt.legend()
plt.ylim(-2,4)
plt.show()

for n in range(1, 11, 1):
    plt.plot(x, arctan(x, n)**2, label = str(n) + "D")

plt.legend()
plt.ylim(-2,4)
plt.show()

```
sin,cosなどをそれぞれ2乗してみました。こんなグラフになります。

## sinの2乗
![maclolinSinSin1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2475646/6d343a38-a2a7-4c6d-029a-897b4cfc6363.png)

## cosの2乗
![maclolinCosCos1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2475646/c7dc4d6b-183e-35f0-bb53-448bc980ce76.png)

## tanの2乗
![maclolinTanTan1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2475646/6c8077d9-941e-e049-76f8-e7cd734fd4aa.png)

## arctanの2乗
![maclolinArctanArctan1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2475646/e88c36eb-1b0b-cb01-91f1-1f7ce9c026e3.png)


```Python:McLaughlin3.py
import numpy as np
import matplotlib.pyplot as plt

def kaijyo(n):
    result = 1
    for i in range(1, n+1):
        result *= i
    return result

def sin(x, n):
    result = 0
    for i in range(1, n+1):
        result += (-1)**(i+1) * (1 / kaijyo(2*i-1)) * x**(2*i-1)
    return result

def cos(x, n):
    result = 1
    for i in range(1, n+1):
        result += (-1)**(i+1) * 1 / kaijyo(2 * (i-1)) * x**(2*(i-1))
    return result

def tan(x, n):
    return sin(x, n) / cos(x, n)

def arctan(x, n):
    result = 0
    for i in range(1, n+1):
        result += (-1)**(i+1) * x**(2*i-1) / (2*i-1)
    return result

x = np.linspace(-2 * np.pi, 2 * np.pi, 101)

for n in range(1, 11, 1):
    plt.plot(x, sin(x, n)*cos(x, n), label = str(n) + "D")

plt.legend()
plt.ylim(-4,4)
plt.show()

for n in range(1, 11, 1):
    plt.plot(x, sin(x, n) * cos(x, n) * tan(x, n), label = str(n) + "D")

plt.legend()
plt.ylim(-2,4)
plt.show()

for n in range(1, 11, 1):
    plt.plot(x, sin(x, n)*cos(x, n) + cos(x, n)*sin(x, n), label = str(n) + "D")

plt.legend()
plt.ylim(-4,4)
plt.show()

for n in range(1, 11, 1):
    plt.plot(x, arctan(x, n)**sin(x, n), label = str(n) + "D")

plt.legend()
plt.ylim(-4,4)
plt.show()

for n in range(1, 11, 1):
    plt.plot(x, cos(x, n)**sin(x, n), label = str(n) + "D")

plt.legend()
plt.ylim(-4,4)
plt.show()

for n in range(1, 11, 1):
    plt.plot(x, (cos(x, n)+sin(x, n)) ** tan(x, n), label = str(n) + "D")

plt.legend()
plt.ylim(-1,8)
plt.show()
```

　その他、色々作ってみました。

## sin × cos
![maclolinOmake1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2475646/7614bfa5-09c1-028e-4118-ef3553ed7220.png)

## sin × cos × tan
![maclolinOmake2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2475646/b47720fd-a1c8-62a5-9053-b1c6c846c650.png)

## sin × cos + cos × sin (咲いたコスモスコスモス咲いたみたいなやつ)
![maclolinOmake3.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2475646/c4077186-b786-31a6-daf6-4c36b4e12f6f.png)

## arctanのsin乗（自分でも意味わからないです）
![maclolinOmake4.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2475646/67c99b5c-755b-bf9a-6156-50071e7b17b2.png)

## cosのsin乗
![maclolinOmake5.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2475646/4654e634-962d-24bc-718e-32789c21b06c.png)

## cos + sin のtan乗
![maclolinOmake6.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2475646/2ae45d37-c03d-a05b-e5be-d0fb76f0c1ca.png)

# まとめ
誰かこれらがどういうグラフなのか教えてください。