## 2019年8月8日木曜日

### 数学 - Python - 微分積分学 - 微分法 - 微分係数 - 平方、逆数

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

よって、

$f\text{'}\left(c\right)=-\frac{1}{{c}^{2}}$

（証明終）

コード

Python 3

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

print('1.')

x, h = symbols('x, h')
f = 1 / x
df = Derivative(f, x, 1)
g = (f.subs({x: x+h}) - f) / ((x + h) - x)

for d in ['+', '-']:
l = Limit(g, h, 0, dir=d)
for o in [l, l.doit()]:
pprint(o)
print()

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

p = plot(f, df.doit(),
(x, -5, 5),
ylim=(-5, 5),
legend=True,
show=False)

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

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


C:\Users\...>py sample1.py
1.
⎛  1     1⎞
⎜───── - ─⎟
⎜h + x   x⎟
lim ⎜─────────⎟
h─→0⁺⎝    h    ⎠

-1
───
2
x

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

-1
───
2
x

c:\Users\...>