## 2019年5月17日金曜日

### 数学 - Python - 解析学 - 級数 - テイラーの公式 - 一意性定理(三角関数(余弦)、累乗(べき乗、平方))

1. $\begin{array}{l}\mathrm{cos}x=1-\frac{1}{2!}{x}^{2}+\frac{1}{4!}{x}^{4}+O\left({x}^{6}\right)\\ {\mathrm{cos}}^{2}x={\left(1-\frac{1}{2!}{x}^{2}+\frac{1}{4!}{x}^{4}\right)}^{2}+O\left({x}^{6}\right)\\ =1-\frac{1}{2!}·2{x}^{2}+\left({\left(\frac{1}{2!}\right)}^{2}+\frac{1}{4!}·2\right){x}^{4}+O\left({x}^{6}\right)\\ =1-{x}^{2}+\left(\frac{1}{4}+\frac{1}{12}\right){x}^{4}+O\left({x}^{6}\right)\\ =1-{x}^{2}+\frac{1}{3}{x}^{4}+O\left({x}^{6}\right)\end{array}$

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, plot, cos, factorial

print('8.')

x = symbols('x')
f = sum([(-1) ** k * 1 / factorial(2 * k) * x ** (2 * k) for k in range(3)])
g = 1 - x ** 2 + x ** 4 / 3

for o in [f, g, (f ** 2).expand()]:
pprint(o)
print()

p = plot(cos(x), cos(x) ** 2, f, f ** 2, g,
(x, -5, 5),
ylim=(-5, 5),
legend=True,
show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']
for o, color in zip(p, colors):
o.line_color = color

p.show()
p.save('sample8.png')


C:\Users\...>py sample8.py
8.
4    2
x    x
── - ── + 1
24   2

4
x     2
── - x  + 1
3

8    6    4
x    x    x     2
─── - ── + ── - x  + 1
576   24   3

C:\Users\...>