2017年5月16日火曜日

学習環境

解析入門〈1〉(松坂 和夫(著)、岩波書店)の第5章(各種の初等関数)、5.4(三角関数(続き)、逆三角関数)、問題4、5.を取り組んでみる。


  1. n=1 d dx ( e x sinx )= e x sinx+ e x cosx 2 e x sin( x+ π 4 ) = 2 e x ( sinxcos π 4 +cosxsin π 4 ) = 2 e x ( 1 2 sinx+ 1 2 cosx ) = e x sinx+ e x cosx = e x 2 ( 1 2 sinx+ 1 2 cosx ) = e x 2 ( sinxcos π 4 +cosxsin π 4 ) = 2 e x sin( x+ π 4 ) d dx ( ( 2 ) n e x sin( x+ nπ 4 ) ) = ( 2 ) n ( e x sin( x+ nπ 4 )+ e x cos( x+ nπ 4 ) ) = ( 2 ) n+1 e x ( sin( x+ nπ 4 ) 1 2 +cos( x+ nπ 4 ) 1 2 ) = ( 2 ) n+1 e x ( sin( x+ nπ 4 )cos π 4 +cos( x+ nπ 4 )sin π 4 ) = ( 2 ) n+1 e x sin( x+ nπ 4 + π 4 ) = ( 2 ) n+1 e x sin( x+ ( n+1 )π 4 )

    1. f'( x )=a 1 x sin( logx )+b 1 x cos( logx ) f''( x )=a( 1 x 2 sin( logx )+ 1 x 2 cos( logx ) )+b( 1 x 2 cos( logx ) 1 x 2 sin( logx ) ) a( cos( logx )sin( logx ) )+b( cos( logx )sin( logx ) )+ asin( logx )+bcos( logx )+ acos( logx )+bsin( logx ) =0

    2. n=1 d dx x( acos( logx )+bsin( logx ) ) =( acos( logx )+bsin( logx ) )+x( a 1 x sin( logx )+b 1 x cos( logx ) ) =( a+b )cos( logx )+( ba )sin( logx ) a 1 =a+b, a 2 =ba x n+1 f ( n+1 ) ( x ) = x n+1 d dx f ( n ) ( x ) = x n+1 d dx ( a n cos( logx )+ b n sin( logx ) x n ) = x n+1 ( ( a n 1 x sin( logx )+ b n 1 x cos( logx ) ) x n ( a n cos( logx )+ b n sin( logx ) )n x n1 x 2n ) = x n1 ( ( b n a n )cos( logx )+( a n b n )sin( logx ) ) x n1 =( b n a n )cos( logx )+( a n b n )sin( logx )

コード(Emacs)

Python 3

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from sympy import Symbol, symbols, Derivative, sqrt, sin, cos, exp, pi, log, solve, pprint

print('4')
n = Symbol('n', integer=True, positive=True)
x = Symbol('x')

expr1 = exp(x) * sin(x)
expr2 = sqrt(2) ** n * exp(x) * sin(x + n * pi / 4)
pprint(expr1)
pprint(expr2)

for i in range(10):
    print('n = {}'.format(i + 1))
    d = Derivative(expr1, x, i).doit()
    pprint(d)
    expr = expr2.subs({n: i})
    pprint(expr)
    print((d - expr).expand() == 0)

print('5.')
a, b = symbols('a b')
x = Symbol('x', nonzero=True)
f = a * cos(log(x)) + b * sin(log(x))
pprint(f)

print('(a)')
f1 = Derivative(f, x, 1).doit()
f2 = Derivative(f, x, 2).doit()
pprint(f1)
pprint(f2)

expr = x ** 2 * f2 + x * f1 + f
pprint(expr)
print(expr.expand() == 0)

print('(b)')
for i in range(10):
    print('n = {0}'.format(i + 1))
    expr = x**n * Derivative(f, x, i).doit()
    pprint(expr)

入出力結果(Terminal, IPython)

$ ./sample4.py
4
 x       
ℯ ⋅sin(x)
 n                
 ─                
 2  x    ⎛π⋅n    ⎞
2 ⋅ℯ ⋅sin⎜─── + x⎟
         ⎝ 4     ⎠
n = 1
 x       
ℯ ⋅sin(x)
 x       
ℯ ⋅sin(x)
True
n = 2
 x           x       
ℯ ⋅sin(x) + ℯ ⋅cos(x)
    x    ⎛    π⎞
√2⋅ℯ ⋅sin⎜x + ─⎟
         ⎝    4⎠
False
n = 3
   x       
2⋅ℯ ⋅cos(x)
   x       
2⋅ℯ ⋅cos(x)
True
n = 4
                      x
2⋅(-sin(x) + cos(x))⋅ℯ 
      x    ⎛    π⎞
2⋅√2⋅ℯ ⋅cos⎜x + ─⎟
           ⎝    4⎠
False
n = 5
    x       
-4⋅ℯ ⋅sin(x)
    x       
-4⋅ℯ ⋅sin(x)
True
n = 6
                      x
-4⋅(sin(x) + cos(x))⋅ℯ 
       x    ⎛    π⎞
-4⋅√2⋅ℯ ⋅sin⎜x + ─⎟
            ⎝    4⎠
False
n = 7
    x       
-8⋅ℯ ⋅cos(x)
    x       
-8⋅ℯ ⋅cos(x)
True
n = 8
                     x
8⋅(sin(x) - cos(x))⋅ℯ 
       x    ⎛    π⎞
-8⋅√2⋅ℯ ⋅cos⎜x + ─⎟
            ⎝    4⎠
False
n = 9
    x       
16⋅ℯ ⋅sin(x)
    x       
16⋅ℯ ⋅sin(x)
True
n = 10
                      x
16⋅(sin(x) + cos(x))⋅ℯ 
       x    ⎛    π⎞
16⋅√2⋅ℯ ⋅sin⎜x + ─⎟
            ⎝    4⎠
False
5.
a⋅cos(log(x)) + b⋅sin(log(x))
(a)
  a⋅sin(log(x))   b⋅cos(log(x))
- ───────────── + ─────────────
        x               x      
a⋅sin(log(x)) - a⋅cos(log(x)) - b⋅sin(log(x)) - b⋅cos(log(x))
─────────────────────────────────────────────────────────────
                               2                             
                              x                              
                                  ⎛  a⋅sin(log(x))   b⋅cos(log(x))⎞
a⋅sin(log(x)) - b⋅cos(log(x)) + x⋅⎜- ───────────── + ─────────────⎟
                                  ⎝        x               x      ⎠
True
(b)
n = 1
 n                                
x ⋅(a⋅cos(log(x)) + b⋅sin(log(x)))
n = 2
 n ⎛  a⋅sin(log(x))   b⋅cos(log(x))⎞
x ⋅⎜- ───────────── + ─────────────⎟
   ⎝        x               x      ⎠
n = 3
 n                                                                
x ⋅(a⋅sin(log(x)) - a⋅cos(log(x)) - b⋅sin(log(x)) - b⋅cos(log(x)))
──────────────────────────────────────────────────────────────────
                                 2                                
                                x                                 
n = 4
 n                                                                     
x ⋅(-a⋅sin(log(x)) + 3⋅a⋅cos(log(x)) + 3⋅b⋅sin(log(x)) + b⋅cos(log(x)))
───────────────────────────────────────────────────────────────────────
                                    3                                  
                                   x                                   
n = 5
     n                                 
-10⋅x ⋅(a⋅cos(log(x)) + b⋅sin(log(x))) 
───────────────────────────────────────
                    4                  
                   x                   
n = 6
    n                                                                    
10⋅x ⋅(a⋅sin(log(x)) + 4⋅a⋅cos(log(x)) + 4⋅b⋅sin(log(x)) - b⋅cos(log(x)))
─────────────────────────────────────────────────────────────────────────
                                     5                                   
                                    x                                    
n = 7
    n                                                                          
10⋅x ⋅(-9⋅a⋅sin(log(x)) - 19⋅a⋅cos(log(x)) - 19⋅b⋅sin(log(x)) + 9⋅b⋅cos(log(x))
───────────────────────────────────────────────────────────────────────────────
                                        6                                      
                                       x                                       

 
)
─
 
 
n = 8
    n                                                                          
10⋅x ⋅(73⋅a⋅sin(log(x)) + 105⋅a⋅cos(log(x)) + 105⋅b⋅sin(log(x)) - 73⋅b⋅cos(log(
───────────────────────────────────────────────────────────────────────────────
                                          7                                    
                                         x                                     

    
x)))
────
    
    
n = 9
    n                                                                          
20⋅x ⋅(-308⋅a⋅sin(log(x)) - 331⋅a⋅cos(log(x)) - 331⋅b⋅sin(log(x)) + 308⋅b⋅cos(l
───────────────────────────────────────────────────────────────────────────────
                                           8                                   
                                          x                                    

       
og(x)))
───────
       
       
n = 10
      n                                                                        
1300⋅x ⋅(43⋅a⋅sin(log(x)) + 36⋅a⋅cos(log(x)) + 36⋅b⋅sin(log(x)) - 43⋅b⋅cos(log(
───────────────────────────────────────────────────────────────────────────────
                                          9                                    
                                         x                                     

    
x)))
────
    
    
$

0 コメント:

コメントを投稿