## 2019年11月14日木曜日

### 数学 - Python - 微分積分学 - 平均値の定理 - 関数値の変動と導関数 - 極大値と極小値、増加と減少

1. $\begin{array}{l}f\left(x\right)={\left(x-2\right)}^{2}{\left(x+1\right)}^{3}\\ \frac{d}{\mathrm{dx}}f\left(x\right)\\ =2\left(x-2\right){\left(x+1\right)}^{3}+{\left(x-2\right)}^{2}3{\left(x+1\right)}^{2}\\ =\left(x-2\right){\left(x+1\right)}^{2}\left(2\left(x+1\right)+3\left(x-2\right)\right)\\ =\left(x-2\right){\left(x+1\right)}^{2}\left(5x-4\right)\end{array}$

よって、

$\begin{array}{l}\frac{d}{\mathrm{dx}}f\left(x\right)=0\\ x=-1,\frac{4}{5},2\end{array}$

よって、増加、減少について

よって、極大値、極小値はそれぞれ、

$\frac{{2}^{2}·{3}^{8}}{{5}^{5}},0$

コード

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

print('7.')

x = symbols('x')
f = (x - 2) ** 2 * (x + 1) ** 3
d = Derivative(f, x, 1)
f1 = d.doit()
xs = solve(f1, x)
for o in [d, f1, xs]:
pprint(o)
print()

for x0 in xs:
pprint(f.subs({x: x0}))
print()

p = plot(f, Rational(2 ** 2 * 3 ** 8, 5 ** 5),
ylim=(-10, 10),
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('sample7.png')


% ./sample7.py
7.
d ⎛       2        3⎞
──⎝(x - 2) ⋅(x + 1) ⎠
dx

2        2          3
3⋅(x - 2) ⋅(x + 1)  + (x + 1) ⋅(2⋅x - 4)

[-1, 4/5, 2]

0

26244
─────
3125

0

%