## 2019年9月26日木曜日

### 数学 - Python - 微分積分学 - 微分法の公式 - 有理関数とその導関数

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

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

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

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

コード

Python 3

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

print('1.')

x, a, n = symbols('x, a, n', real=True)
fs = [x ** 3 - 3 * x,
x ** 4 - 6 * x ** 2 + 3,
1 / (1 + 2 * a * x + x ** 2),
x ** n / (1 - x ** n)]

for i, f in enumerate(fs, 1):
print(f'({i})')
d = Derivative(f, x, 1)
for o in [d, d.doit()]:
pprint(o.factor())
print()

p = plot(*[f.subs({a: 2, n: 3}) for f in fs],
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('sample1.png')


$./sample1.py 1. (1) d ⎛ 3 ⎞ ──⎝x - 3⋅x⎠ dx 3⋅(x - 1)⋅(x + 1) (2) d ⎛ 4 2 ⎞ ──⎝x - 6⋅x + 3⎠ dx ⎛ 2 ⎞ 4⋅x⋅⎝x - 3⎠ (3) ∂ ⎛ 1 ⎞ ──⎜──────────────⎟ ∂x⎜ 2 ⎟ ⎝2⋅a⋅x + x + 1⎠ -2⋅(a + x) ───────────────── 2 ⎛ 2 ⎞ ⎝2⋅a⋅x + x + 1⎠ (4) ⎛ n ⎞ ∂ ⎜ x ⎟ ──⎜──────⎟ ∂x⎜ n⎟ ⎝1 - x ⎠ n n⋅x ─────────── 2 ⎛ n ⎞ x⋅⎝x - 1⎠$