2019年8月8日木曜日

数学 - Python - 解析学 - 各種の初等関数 - 累乗関数、大きさの比較 - 累乗(べき乗、平方)、指数関数、積、対数関数、逆数、グラフの概形、微分、極値、変曲点、増減表

1. $\begin{array}{l}f\text{'}\left(x\right)\\ =2x{e}^{-x}-{x}^{2}{e}^{-x}\\ =x{e}^{-x}\left(2-x\right)\\ f\text{'}\text{'}\left(x\right)\\ =2{e}^{-x}-2x{e}^{-x}-2x{e}^{-x}+{x}^{2}{e}^{-x}\\ ={e}^{-x}\left(2-4x+{x}^{2}\right)\\ ={e}^{-x}\left({x}^{2}-4x+2\right)\\ {x}^{2}-4x+2=0\\ x=2±\sqrt{4-2}\\ =2±\sqrt{2}\end{array}$

よって、求める関数のグラフの概形は、

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

よって、求める関数のグラフの概形は、

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

よって、求める関数のグラフの概形は、

コード

Python 3

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

print('3.')

x = symbols('x', real=True)
fs = [x ** 2 * exp(-x),
log(x) / x,
exp(1 / x)]

for i, f in enumerate(fs, 1):
print(f'({i})')
for n in range(3):
df = Derivative(f, x, n)
for o in [df, df.doit(), solve(df.doit())]:
pprint(o)
print()
print()

p = plot((fs[0], (x, -10, 10)),
(fs[1], (x, 0.1, 10)),
(fs[2], (x, -10, -0.1)),
(fs[2], (x, 0.1, 10)),
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('sample3.png')


C:\Users\...>py sample3.py
3.
(1)
2  -x
x ⋅ℯ

2  -x
x ⋅ℯ

[0]

d ⎛ 2  -x⎞
──⎝x ⋅ℯ  ⎠
dx

2  -x        -x
- x ⋅ℯ   + 2⋅x⋅ℯ

[0, 2]

2
d ⎛ 2  -x⎞
───⎝x ⋅ℯ  ⎠
2
dx

⎛ 2          ⎞  -x
⎝x  - 4⋅x + 2⎠⋅ℯ

[2 - √2, √2 + 2]

(2)
log(x)
──────
x

log(x)
──────
x

[1]

d ⎛log(x)⎞
──⎜──────⎟
dx⎝  x   ⎠

log(x)   1
- ────── + ──
2      2
x      x

[ℯ]

2
d ⎛log(x)⎞
───⎜──────⎟
2⎝  x   ⎠
dx

2⋅log(x) - 3
────────────
3
x

⎡ 3/2⎤
⎣ℯ   ⎦

(3)
1
─
x
ℯ

1
─
x
ℯ

[]

⎛ 1⎞
⎜ ─⎟
d ⎜ x⎟
──⎝ℯ ⎠
dx

1
─
x
-ℯ
────
2
x

[]

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

1
─
⎛    1⎞  x
⎜2 + ─⎟⋅ℯ
⎝    x⎠
──────────
3
x

[-1/2]

C:\Users\...>