## 2019年8月4日日曜日

### 数学 - Python - 微分積分学 - 微分法 - 偶関数と奇関数

1. $\begin{array}{l}f\left(-x\right)\\ =1-\frac{{\left(-x\right)}^{2}}{2}+\frac{{\left(-x\right)}^{4}}{24}\\ =1-\frac{{x}^{2}}{2}+\frac{{x}^{4}}{24}\\ =f\left(x\right)\end{array}$

また、

$\begin{array}{l}f\left(-x\right)\\ =\left(-x\right)-\frac{{\left(-x\right)}^{3}}{6}+\frac{{\left(-x\right)}^{5}}{120}\\ =-x+\frac{{x}^{3}}{6}-\frac{{x}^{5}}{120}\\ =-\left(x-\frac{{x}^{3}}{6}+\frac{{x}^{5}}{120}\right)\\ =-f\left(x\right)\end{array}$

コード

Python 3

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

print('2.')

x = symbols('x')
f = 1 - x ** 2 / 2 + x ** 4 / 24
g = x - x * 3 / 6 + x ** 5 / 120

for h in [f.subs({x: -x}), f, f.subs({x: -x}) == f,
g.subs({x: -x}), -g, g.subs({x: -x}) == -g]:
pprint(h)
print()

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']
p = plot(f, g,
ylim=(-10, 10),
legend=True,
show=False)

for o, color in zip(p, colors):
o.line_color = color

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


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

4    2
x    x
── - ── + 1
24   2

True

5
x    x
- ─── - ─
120   2

5
x    x
- ─── - ─
120   2

True

c:\Users\...>