## 2019年8月23日金曜日

### 数学 - Python - 微分積分学 - 微分法 - 累乗(べき乗)、逆数、累乗根(平方)の微分

1. $-2x$

2. $3{x}^{2}+8x$

3. $\begin{array}{l}-2\left(1-x\right)\\ =2x-2\end{array}$

4. $\begin{array}{l}-\frac{1}{{x}^{4}}·2x\\ =-\frac{2}{{x}^{3}}\end{array}$

5. $\begin{array}{l}\frac{\left(b+2cx\right)x-\left(a+bx+c{x}^{2}\right)}{{x}^{2}}\\ =\frac{-a+c{x}^{2}}{{x}^{2}}\end{array}$

6. $\frac{1}{2}{\left(1+x\right)}^{-\frac{1}{2}}$

7. $2{x}^{-\frac{1}{2}}-\frac{5}{{x}^{2}}$

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

9. $\begin{array}{l}\frac{1}{2}{\left(1+{x}^{2}\right)}^{-\frac{1}{2}}·2x\\ =x{\left(1+{x}^{2}\right)}^{-\frac{1}{2}}\end{array}$

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

コード

Python 3

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

print('6〜15.')

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

def tearDown(self):
pass

def test(self):
x, a, b, c = symbols('x, a, b, c')
fs = [a ** 2 - x ** 2,
x ** 3 + 4 * x ** 2 + 3,
(1 - x) ** 2,
1 / x ** 2,
(a + b * x + c * x ** 2) / x,
sqrt(1 + x),
4 * sqrt(x) + 5 / x + 3,
x * (1 - x ** 2),
sqrt(1 + x ** 2),
sqrt(1 - x ** 2)]
ans = [-2 * x,
3 * x ** 2 + 8 * x,
- 2 * (1 - x),
-2 / x ** 3,
(-a + c * x ** 2) / x ** 2,
(1 + x) ** Rational(-1, 2) / 2,
2 * x ** Rational(-1, 2) - 5 / x ** 2,
1 - 3 * x ** 2,
x * (1 + x ** 2) ** Rational(-1, 2),
-x * (1 - x ** 2) ** Rational(-1, 2)]
for f, a in zip(fs, ans):
self.assertEqual(Derivative(f, x, 1).doit().factor(), a.factor())

if __name__ == '__main__':
main()


C:\Users\...>py sample6.py
6〜15.
.
----------------------------------------------------------------------
Ran 1 test in 0.079s

OK

c:\Users\...>