2019年5月18日土曜日

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

1. $\begin{array}{l}\mathrm{sin}x=x-\frac{1}{3!}{x}^{3}+O\left({x}^{5}\right)\\ {\mathrm{sin}}^{2}x\\ ={\left(x-\frac{1}{3!}{x}^{3}+O\left({x}^{5}\right)\right)}^{2}\\ ={x}^{2}-2·\frac{1}{3!}{x}^{4}+O\left({x}^{6}\right)\\ ={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, sin, factorial

print('9.')

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

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

p = plot(sin(x), sin(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('sample9.png')


C:\Users\...>py sample9.py
9.
5    3
x    x
- ─── + ── - x
120   6

4
x     2
- ── + x
3

10      8      6    4
x       x    2⋅x    x     2
───── - ─── + ──── - ── + x
14400   360    45    3

C:\Users\...>