## 2019年10月6日日曜日

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

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

コード

Python 3

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

print('20.')

x, a = symbols('x, a')
f = x ** 2 * (a ** 2 + x ** 2) * sqrt(a ** 2 - x ** 2)
d = Derivative(f, x, 1).doit()

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

def tearDown(self):
pass

def test(self):
d0 = f * (2 / x +
2 * x / (a ** 2 + x ** 2) -
x / (a ** 2 - x ** 2))
self.assertEqual(d.factor(), d0.factor())

a0 = 2
epsilon = 0.1
g = f.subs({a: a0})
p = plot(g,
(x, -a0 + epsilon, a0 - epsilon),
ylim=(0, 4),
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('sample20.png')

if __name__ == '__main__':
main()


$./sample20.py 20. . ---------------------------------------------------------------------- Ran 1 test in 0.029s OK$