## 2019年8月9日金曜日

### 数学 - Python - 微分積分学 - 微分法 - 導関数 - 累乗、累乗根

1. $\begin{array}{l}\frac{\left(1-{\left(x+h\right)}^{2}\right)-\left(1-{x}^{2}\right)}{h}\\ =\frac{-2hx-{h}^{2}}{h}\\ =-2x-h\\ h\to 0⇒-2x-h\to -2x\end{array}$

2. $\begin{array}{l}\frac{{\left(x+h\right)}^{3}-{x}^{3}}{h}\\ =\frac{3{x}^{2}h+3x{h}^{2}+{h}^{3}}{h}\\ =3{x}^{2}+3xh+{h}^{2}\\ h\to 0⇒\frac{{\left(x+h\right)}^{3}-{x}^{3}}{h}\to 3{x}^{2}\end{array}$

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

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

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

6. $\begin{array}{l}\frac{{\left(x+h\right)}^{\frac{1}{3}}-{x}^{\frac{1}{3}}}{h}\\ =\frac{\left({\left(x+h\right)}^{\frac{1}{3}}-{x}^{\frac{1}{3}}\right)\left({\left(x+h\right)}^{\frac{2}{3}}+{\left(x+h\right)}^{\frac{1}{3}}{x}^{\frac{1}{3}}+{x}^{\frac{2}{3}}\right)}{h\left({\left(x+h\right)}^{\frac{2}{3}}+{\left(x+h\right)}^{\frac{1}{3}}{x}^{\frac{1}{3}}+{x}^{\frac{2}{3}}\right)}\\ =\frac{\left(x+h\right)-x}{h\left({\left(x+h\right)}^{\frac{2}{3}}+{\left(x+h\right)}^{\frac{1}{3}}{x}^{\frac{1}{3}}+{x}^{\frac{2}{3}}\right)}\\ =\frac{h}{h\left({\left(x+h\right)}^{\frac{2}{3}}+{\left(x+h\right)}^{\frac{1}{3}}{x}^{\frac{1}{3}}+{x}^{\frac{2}{3}}\right)}\\ =\frac{1}{{\left(x+h\right)}^{\frac{2}{3}}+{\left(x+h\right)}^{\frac{1}{3}}{x}^{\frac{1}{3}}+{x}^{\frac{2}{3}}}\\ h\to 0⇒\frac{{\left(x+h\right)}^{\frac{1}{3}}-{x}^{\frac{1}{3}}}{h}\to \frac{1}{3}{x}^{-\frac{2}{3}}\end{array}$

コード

Python 3

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

print('1.')

x, h = symbols('x, h')
fs = [1 - x ** 2,
x ** 3,
x + 1 / x,
x ** 3 - 3 * x ** 2 + 2,
3 * x - x ** 3,
x ** Rational(1, 3)]

for i, f in enumerate(fs, 1):
print(f'({i})')
df = Derivative(f, x, 1)
for o in [df, df.doit()]:
pprint(o)
print()
g = (f.subs({x: x + h}) - f) / h
for d in ['+', '-']:
l = Limit(g, h, 0, dir=d)
for o in [l, l.doit()]:
pprint(o)
print()

p = plot(*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('sample1.png')


C:\Users\...>py sample1.py
1.
(1)
d ⎛     2⎞
──⎝1 - x ⎠
dx

-2⋅x

⎛ 2          2⎞
⎜x  - (h + x) ⎟
lim ⎜─────────────⎟
h─→0⁺⎝      h      ⎠

-2⋅x

⎛ 2          2⎞
⎜x  - (h + x) ⎟
lim ⎜─────────────⎟
h─→0⁻⎝      h      ⎠

-2⋅x

(2)
d ⎛ 3⎞
──⎝x ⎠
dx

2
3⋅x

⎛   3          3⎞
⎜- x  + (h + x) ⎟
lim ⎜───────────────⎟
h─→0⁺⎝       h       ⎠

2
3⋅x

⎛   3          3⎞
⎜- x  + (h + x) ⎟
lim ⎜───────────────⎟
h─→0⁻⎝       h       ⎠

2
3⋅x

(3)
d ⎛    1⎞
──⎜x + ─⎟
dx⎝    x⎠

1
1 - ──
2
x

⎛      1     1⎞
⎜h + ───── - ─⎟
⎜    h + x   x⎟
lim ⎜─────────────⎟
h─→0⁺⎝      h      ⎠

2
x  - 1
──────
2
x

⎛      1     1⎞
⎜h + ───── - ─⎟
⎜    h + x   x⎟
lim ⎜─────────────⎟
h─→0⁻⎝      h      ⎠

2
x  - 1
──────
2
x

(4)
d ⎛ 3      2    ⎞
──⎝x  - 3⋅x  + 2⎠
dx

2
3⋅x  - 6⋅x

⎛   3      2          3            2⎞
⎜- x  + 3⋅x  + (h + x)  - 3⋅(h + x) ⎟
lim ⎜───────────────────────────────────⎟
h─→0⁺⎝                 h                 ⎠

2
3⋅x  - 6⋅x

⎛   3      2          3            2⎞
⎜- x  + 3⋅x  + (h + x)  - 3⋅(h + x) ⎟
lim ⎜───────────────────────────────────⎟
h─→0⁻⎝                 h                 ⎠

2
3⋅x  - 6⋅x

(5)
d ⎛   3      ⎞
──⎝- x  + 3⋅x⎠
dx

2
3 - 3⋅x

⎛       3          3⎞
⎜3⋅h + x  - (h + x) ⎟
lim ⎜───────────────────⎟
h─→0⁺⎝         h         ⎠

2
3 - 3⋅x

⎛       3          3⎞
⎜3⋅h + x  - (h + x) ⎟
lim ⎜───────────────────⎟
h─→0⁻⎝         h         ⎠

2
3 - 3⋅x

(6)
d ⎛3 ___⎞
──⎝╲╱ x ⎠
dx

1
──────
2/3
3⋅x

⎛  3 ___   3 _______⎞
⎜- ╲╱ x  + ╲╱ h + x ⎟
lim ⎜───────────────────⎟
h─→0⁺⎝         h         ⎠

1
──────
2/3
3⋅x

⎛  3 ___   3 _______⎞
⎜- ╲╱ x  + ╲╱ h + x ⎟
lim ⎜───────────────────⎟
h─→0⁻⎝         h         ⎠

1
──────
2/3
3⋅x

c:\Users\...>