## 2019年7月6日土曜日

### 数学 - Python - 解析学 - 微分法 - 関数の凹凸 - 一次導関数、二次導関数、関数の増減、極値、変曲点、グラフの描画

1. $\begin{array}{l}f\text{'}\left(x\right)=\frac{2\left(1+{x}^{2}\right)-2x·2x}{{\left(1+{x}^{2}\right)}^{2}}\\ =\frac{2\left(1-{x}^{2}\right)}{{\left(1+{x}^{2}\right)}^{2}}\\ {f}^{\left(2\right)}\left(x\right)=\frac{-4x{\left(1+{x}^{2}\right)}^{2}-2\left(1-{x}^{2}\right)2\left(1+{x}^{2}\right)2x}{{\left(1+{x}^{2}\right)}^{4}}\\ =\frac{-4x\left(1+{x}^{2}\right)-8x\left(1-{x}^{2}\right)}{{\left(1+{x}^{2}\right)}^{3}}\\ =\frac{-4x\left(1+{x}^{2}+2-2{x}^{2}\right)}{{\left(1+{x}^{2}\right)}^{3}}\\ =\frac{-4x\left(3-{x}^{2}\right)}{{\left(1+{x}^{2}\right)}^{3}}\end{array}$

増減表。

グラつの描画。

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, solve, plot, Derivative
import random

print('3.')
x = symbols('x')
f = 2 * x / (1 + x ** 2)
fs = [Derivative(f, x, n) for n in range(3)]
for g in fs:
for o in [g, g.doit().factor(), solve(g.doit())]:
pprint(o)
print()
p = plot(*[g.doit() for g in fs],
(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('sample3.png')


C:\Users\...>py sample3.py
3.
2⋅x
──────
2
x  + 1

2⋅x
──────
2
x  + 1

[0]

d ⎛ 2⋅x  ⎞
──⎜──────⎟
dx⎜ 2    ⎟
⎝x  + 1⎠

-2⋅(x - 1)⋅(x + 1)
───────────────────
2
⎛ 2    ⎞
⎝x  + 1⎠

[-1, 1]

2
d ⎛ 2⋅x  ⎞
───⎜──────⎟
2⎜ 2    ⎟
dx ⎝x  + 1⎠

⎛ 2    ⎞
4⋅x⋅⎝x  - 3⎠
────────────
3
⎛ 2    ⎞
⎝x  + 1⎠

[0, -√3, √3]

C:\Users\...>