## 2019年10月1日火曜日

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

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

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

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

4. $\begin{array}{l}\frac{d}{\mathrm{dx}}\frac{x-a}{\left(x-b\right)\left(x-c\right)}\\ =\frac{\left(x-b\right)\left(x-c\right)-\left(x-a\right)\left(x-c+x-b\right)}{{\left(x-b\right)}^{2}{\left(x-c\right)}^{2}}\\ =\frac{-{x}^{2}+\left(-b-c+b+c+2a\right)x+bc-ab-ac}{{\left(x-b\right)}^{2}{\left(x-c\right)}^{2}}\\ =\frac{-{x}^{2}+2ax-ab+bc-ca}{{\left(x-b\right)}^{2}{\left(x-c\right)}^{2}}\end{array}$

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

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

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

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

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

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

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

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

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

14. $\begin{array}{l}\frac{d}{\mathrm{dx}}{x}^{m}{\left(a+b{x}^{n}\right)}^{p}\\ =m{x}^{m-1}{\left(a+b{x}^{n}\right)}^{p}+{x}^{m}p{\left(a+b{x}^{n}\right)}^{p-1}b{x}^{n-1}\end{array}$

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

コード

Python 3

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

print('1-15.')

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

def tearDown(self):
pass

def test(self):
x, a, b, c, m, n, p = symbols('x, a, b, c, m, n, p')
spam = [x ** 5 + 4 * x ** 3 + 7 * x + 3,
(a + b * x + c * x ** 2) / sqrt(x),
(3 * x + 2) / (1 + x + x ** 2),
(x - a) / ((x - b) * (x - c)),
x * (x + a) * (x + b),
1 / ((x - a) ** 2 + b ** 2) ** n,
sqrt(a ** 4 - x ** 4),
sqrt((x - 2) * (x - 3)),
sqrt(1 + 2 * x) / root(1 + 3 * x, 3),
sqrt((1 - root(x, 3)) / (1 + root(x, 3))),
(sqrt(a ** 2 + x ** 2) + (a ** 2 - x ** 2)) /
(sqrt(a ** 2 + x ** 2) - sqrt(a ** 2 - x ** 2)),
(a ** Rational(2, 3) - x ** Rational(2, 3)) ** Rational(3, 2),
1 / ((x + 1) ** m * (x + 3) ** n),
x ** m * (a + b * x ** n) ** p,
1 / (x + sqrt(x ** 2 + a ** 2))]
egg = [5 * x ** 4 + 12 * x ** 2 + 7,
(3 * c * x ** 2 + b * x - a) / (2 * x * sqrt(x)),
(1 - 4 * x - 3 * x ** 2) / (1 + x + x ** 2) ** 2,
(-x ** 2 + 2 * a * x - a * b + b * c - c * a) /
((x - b) ** 2 * (x - c) ** 2),
3 * x ** 2 + 2 * (a + b) * x + a * b,
- (n * ((x - a) ** 2 + b ** 2) ** (n - 1) * 2 * (x - a)) /
((x - a) ** 2 + b ** 2) ** (2 * n),
-2 * x ** 3 / sqrt(a ** 4 - x ** 4),
(2 * x - 5) / (2 * sqrt((x - 2) * (x - 3))),
(1 + 2 * x) ** -Rational(1, 2) * (1 + 3 * x) ** -Rational(1, 3) -
(1 + 2 * x) ** Rational(1, 2) * (1 + 3 * x) ** -Rational(4, 3),
-Rational(1, 3) * x ** -Rational(2, 3) *
1 / sqrt((1 - root(x, 3)) * (1 + root(x, 3))) *
1 / (1 + root(x, 3)),
-2 * a ** 2 * (sqrt(a ** 4 - x ** 4) + a ** 2) /
(x ** 3 * sqrt(a ** 4 - x ** 4)),
-(a ** Rational(2, 3) - x ** Rational(2, 3)) ** Rational(1, 2) *
x ** -Rational(1, 3),
-m * (x + 1) ** -(m - 1) * (x + 3) ** -n +
(x + 1) ** -m * (-n) * (x + 3) ** -(n - 1),
m * x ** (m - 1) * (a + b * x ** n) ** p +
x ** m * p * (a + b * x ** n) ** (p - 1) * b * x ** (n - 1),
-1 / ((x + sqrt(x ** 2 + a ** 2)) * sqrt(x ** 2 + a ** 2))]
for i, (s, t) in enumerate(zip(spam, egg), 1):
d = Derivative(s, x, 1).doit()
try:
self.assertEqual(d.factor(), t.factor())
except:
try:
self.assertEqual(d.simplify(), t.simplify())
except:
try:
self.assertEqual(d.expand(), t.expand())
except AssertionError as err:
for o in [f'{i}.', s.simplify(),
d.factor(), t]:
pprint(o)
print()
print()

if __name__ == '__main__':
main()

$./sample1.py 1-15. 10. ___________ ╱ 3 ___ ╱ 1 - ╲╱ x ╱ ───────── ╱ 3 ___ ╲╱ ╲╱ x + 1 _______________ ╱ ⎛3 ___ ⎞ ╱ -⎝╲╱ x - 1⎠ ╱ ───────────── ╱ 3 ___ ╲╱ ╲╱ x + 1 ────────────────────────────── 2/3 ⎛3 ___ ⎞ ⎛3 ___ ⎞ 3⋅x ⋅⎝╲╱ x - 1⎠⋅⎝╲╱ x + 1⎠ -1 ─────────────────────────────────────────────── _________________________ 2/3 ╱ ⎛ 3 ___⎞ ⎛3 ___ ⎞ ⎛3 ___ ⎞ 3⋅x ⋅╲╱ ⎝1 - ╲╱ x ⎠⋅⎝╲╱ x + 1⎠ ⋅⎝╲╱ x + 1⎠ 11. _________ 2 2 ╱ 2 2 - a + x - ╲╱ a + x ─────────────────────────── _________ _________ ╱ 2 2 ╱ 2 2 ╲╱ a - x - ╲╱ a + x ⎛ _________ _________ _________ _____ ⎜ 2 ╱ 2 2 2 ╱ 2 2 2 2 ╱ 2 2 2 ╱ 2 -x⋅⎝3⋅a ⋅╲╱ a - x - a ⋅╲╱ a + x + 2⋅a + x ⋅╲╱ a - x + x ⋅╲╱ a + ────────────────────────────────────────────────────────────────────────────── 2 _________ ⎛ _________ _________⎞ ___________________ ╱ 2 2 ⎜ ╱ 2 2 ╱ 2 2 ⎟ ╲╱ -(-a + x)⋅(a + x) ⋅╲╱ a + x ⋅⎝- ╲╱ a - x + ╲╱ a + x ⎠ ____⎞ 2 ⎟ x ⎠ ────── ⎛ _________⎞ 2 ⎜ 2 ╱ 4 4 ⎟ -2⋅a ⋅⎝a + ╲╱ a - x ⎠ ────────────────────────── _________ 3 ╱ 4 4 x ⋅╲╱ a - x 13. -m -n (x + 1) ⋅(x + 3) -m -n -(x + 1) ⋅(x + 3) ⋅(m⋅x + 3⋅m + n⋅x + n) ─────────────────────────────────────────── (x + 1)⋅(x + 3) 1 - m -n -m 1 - n - m⋅(x + 1) ⋅(x + 3) - n⋅(x + 1) ⋅(x + 3) 14. p m ⎛ n⎞ x ⋅⎝a + b⋅x ⎠ p m ⎛ n⎞ ⎛ n n⎞ x ⋅⎝a + b⋅x ⎠ ⋅⎝a⋅m + b⋅m⋅x + b⋅n⋅p⋅x ⎠ ──────────────────────────────────────── ⎛ n⎞ x⋅⎝a + b⋅x ⎠ p - 1 p m n - 1 ⎛ n⎞ m - 1 ⎛ n⎞ b⋅p⋅x ⋅x ⋅⎝a + b⋅x ⎠ + m⋅x ⋅⎝a + b⋅x ⎠ . ---------------------------------------------------------------------- Ran 1 test in 2.027s OK$