## 2019年10月3日木曜日

### 数学 - Python - 微分積分学 - 微分法の公式 - 導関数の求め方 - 有理式、累乗、対数微分法

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

コード

Python 3

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

print('17.')

x = symbols('x')
f = (x + 1) ** 2 / ((x + 2) ** 3 * (x + 3) ** 4)
d = Derivative(f, x, 1).doit()

class MyTest(TestCase):
def setUp(self):
pass

def tearDown(self):
pass

def test(self):
d0 = -(x + 1) * (5 * x ** 2 + 14 * x + 5) / \
((x + 2) ** 4 * (x + 3) ** 5)
self.assertEqual(d.factor(), d0.factor())

p = plot(f, d,
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('sample17.png')

if __name__ == '__main__':
main()


$./sample17.py 17. . ---------------------------------------------------------------------- Ran 1 test in 0.023s OK$