2019年10月1日火曜日

学習環境

微分積分学 (ちくま学芸文庫) (吉田 洋一(著)、筑摩書房)のⅡ.(微分法の公式)、6.(導関数の求め方)、演習問題II、1、2、3、4、5、6、7、8、9、10、11、12、13、14、15の解答を求めてみる。


  1. d dx x 5 + 4 x 3 + 7 x + 3 = 5 x 4 + 12 x 2 + 7

  2. d dx a + b x + c x 2 x = b + 2 c x x - a + b x + c x 2 1 2 x x = 2 x b + 2 c x - a + b x + c x 2 2 x x = 3 c x 2 + b x - a 2 x x

  3. d dx 3 x + 2 1 + x + x 2 = 3 1 + x + x 2 - 3 x + 2 1 + 2 x 1 + x + x 2 2 = 1 - 4 x - 3 x 2 1 + x + x 2 2

  4. d dx x - a x - b x - c = x - b x - c - x - a x - c + x - b x - b 2 x - c 2 = - x 2 + - b - c + b + c + 2 a x + b c - a b - a c x - b 2 x - c 2 = - x 2 + 2 a x - a b + b c - c a x - b 2 x - c 2

  5. d dx x x + a x + b = x + a x + b + x x + b + x x + a = 3 x 2 + 2 a + b x + a b

  6. d dx 1 x - a 2 + b 2 n = - n x - a 2 + b 2 n - 1 2 x - a x - a 2 + b 2 2 n

  7. d dx a 4 - x 4 = 1 2 a 4 - x 4 · - 4 x 3 = - 2 x 3 a 4 - x 4

  8. d dx x - 2 x - 3 = 1 2 x - 2 x - 3 · x - 3 + x - 2 = 2 x - 5 2 x - 2 x - 3

  9. d dx 1 + 2 x 1 + 3 x 3 = d dx 1 + 2 x 1 2 1 + 3 x - 1 3 = 1 2 1 + 2 x - 1 2 2 1 + 3 x - 1 3 + 1 + 2 x 1 2 · - 1 3 1 + 3 x - 4 3 · 3 = 1 + 2 x - 1 2 1 + 3 x - 1 3 - 1 + 2 x 1 2 1 + 3 x - 4 3

  10. d dx 1 - x 3 1 + x 3 = 1 2 1 + x 3 1 - x 3 · 1 1 + x 3 2 - 1 3 x - 2 3 1 + x 3 - 1 - x 3 · 1 3 x - 2 3 = - x - 2 3 3 1 + x 3 1 - x 3 1 1 + x 3 2 = - 1 3 x - 2 3 1 1 - x 3 1 + x 3 · 1 1 + x 3 = - 1 3 1 x 2 3 1 - x 2 3 · 1 1 + x 3

  11. d dx a 2 + x 2 + a 2 - x 2 a 2 + x 2 - a 2 - x 2 = d dx a 2 + x 2 + 2 a 4 - x 4 + a 2 - x 2 a 2 + x 2 - a 2 - x 2 = d dx 2 a 2 + 2 a 4 - x 4 2 x 2 = d dx a 2 + a 4 - x 4 x 2 = - 4 x 3 2 a 4 - x 4 x 2 - a 2 + a 4 - x 4 2 x x 4 = - 2 x 4 a 4 - x 4 - a 2 + a 4 - x 4 2 x 3 a 4 - x 4 = - 2 x 4 - a 2 + a 4 - x 4 2 a 4 - x 4 x 3 a 4 - x 4 = - 2 x 4 + a 2 a 4 - x 4 + a 4 - x 4 x 3 a 4 - x 4 = - 2 a 2 a 4 - x 4 + a 2 x 3 a 4 - x 4

  12. d dx a 2 3 - x 2 3 3 2 = 3 2 a 2 3 - x 2 3 1 2 · - 2 3 x - 1 3 = - a 2 3 - x 2 3 1 2 x - 1 3

  13. d dx 1 x + 1 m x + 3 n = d dx x + 1 - m x + 3 - n = - m x + 1 - m - 1 x + 3 - n + x + 1 - m - n x + 3 - n - 1

  14. d dx x m a + b x n p = m x m - 1 a + b x n p + x m p a + b x n p - 1 b x n - 1

  15. d dx 1 x + x 2 + a 2 = - 1 + 2 x 2 x 2 + a 2 x + x 2 + a 2 2 = - x 2 + a 2 + x x + x 2 + a 2 2 x 2 + a 2 = - 1 x + x 2 + a 2 x 2 + a 2 2

コード

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()

入出力結果(Bash、cmd.exe(コマンドプロンプト)、Terminal、Jupyter(IPython))

$ ./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
$ 

計算間違いしてる可能性があるけど、気にせず先に進めていくことに。

0 コメント:

コメントを投稿