2020年1月2日木曜日

学習環境

解析入門(上) (松坂和夫 数学入門シリーズ 4) (松坂 和夫(著)、岩波書店)の第8章(積分の計算)、8.1(不定積分の計算)、問題8の解答を求めてみる。



    1. e - x cos 2 x dx = e - x · cos 2 x + 1 2 dx = 1 2 e - x cos 2 x dx + 1 2 e - x dx = 1 2 e - x cos 2 x dx - 1 2 e - x e - x cos 2 x dx = - e - x cos 2 x - 2 e - x sin 2 x dx e - x sin 2 x dx = - e - x sin 2 x + 2 e - x cos 2 x dx e - x cos 2 x dx = - e - x cos 2 x + 2 e - x sin 2 x - 4 e - x cos 2 x dx e - x cos 2 x dx = - 1 5 e - x cos 2 x + 2 5 e - x sin 2 x e - x cos 2 x dx = - 1 10 e - x cos 2 x + 1 5 e - x sin 2 x - 1 2 e - x

    2. x = tan t dx dt = 1 cos 2 t 1 x 2 + 1 3 2 dx = 1 tan 2 t + 1 3 2 · 1 cos 2 t dt = 1 sin 2 t cos 2 t + 1 3 2 · 1 cos 2 t dt = cos 3 t cos 2 t dt = cos t dt = sin t = sin arctan x

    3. α - 1

      の場合。

      log x α x dx = 1 α + 1 · log x α + 1

      である。

      α = - 1

      の場合。

      log x - 1 x dx = 1 x log x dx = log log x

    4. e x - 1 = t dt dx = e x 2 e x - 1 e x - 1 dx = e x - 1 · 2 e x - 1 e x dt = 2 e x - 2 e x dt = 2 dt - 1 e x dt = 2 t - 1 1 + t 2 dt = 2 e x - 1 - arctan t = 2 e x - 1 - arctan e x - 1

    5. log x = t 1 x = dt dx sin log x dx = sin t x dt = e t sin t dt e t sin t dt = e t sin t - e t cos t dt = e t sin t - e t cos t + e t sin t dt = e t sin t - e t cos t - e t sin t dt e t sin t dt = e t 2 sin t - cos t sin log x dx = e t 2 sin t - cos t = x 2 sin log x - cos log x

    6. 1 a + b tan x dx = cos x a cos x + b sin x dx d dx a cos x + b sin x = - a sin x + b cos x cos x = A a cos x + b sin x + B - a sin x + b cos x { a A + b B = 1 b A - a B = 0 a 2 A + a b B = a b 2 A - a b B = 0 A = a a 2 + b 2 B = b a A = b a 2 + b 2 dx a + b tan x = a a 2 + b 2 x + b a 2 + b 2 log a cos x + b sin x

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import pprint, symbols, sin, cos, tan, atan, log, plot, Rational, exp, sqrt
from sympy import Integral, Derivative

print('8.')

x, alpha = symbols('x, alpha')
a, b = symbols('a, b', nonzero=True)
fs = [exp(-x) * cos(x) ** 2,
      1 / (x ** 2 + 1) ** Rational(3, 2),
      log(x) ** alpha / x,
      sqrt(exp(x) - 1),
      sin(log(x)),
      1 / (a + b * tan(x))]

for i, f in enumerate(fs, 1):
    print(f'({i})')
    I = Integral(f, x)
    for o in [I, I.doit()]:
        pprint(o.simplify())
        print()


class MyTestCase(TestCase):
    def test(self):
        gs = [-exp(-x) * cos(2 * x) / 10 + exp(-x) * sin(2 * x) / 5 - exp(-x) / 2,
              sin(atan(x)),
              2 * (sqrt(exp(x) - 1) - atan(sqrt(exp(x) - 1))),
              x / 2 * (sin(log(x)) - cos(log(x)))]
        for f, g in zip(fs[:2] + fs[3:-1], gs):
            self.assertEqual(float(f.subs({x: 1})),
                             float(Derivative(g, x, 1).doit().subs({x: 1})))


p = plot(*[f.subs({a: 1, b: 2, alpha: 3}) for f in fs],
         (x, -5, 5),
         ylim=(-5, 5),
         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('sample8.png')


if __name__ == '__main__':
    main()

入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))

% ./sample8.py -v
8.
(1)
⌠               
⎮  -x    2      
⎮ ℯ  ⋅cos (x) dx
⌡               

⎛           cos(2⋅x)   5⎞  -x
⎜sin(2⋅x) - ──────── - ─⎟⋅ℯ  
⎝              2       2⎠    
─────────────────────────────
              5              

(2)
⌠               
⎮      1        
⎮ ─────────── dx
⎮         3/2   
⎮ ⎛ 2    ⎞      
⎮ ⎝x  + 1⎠      
⌡               

     x     
───────────
   ________
  ╱  2     
╲╱  x  + 1 

(3)
⌠           
⎮    α      
⎮ log (x)   
⎮ ─────── dx
⎮    x      
⌡           

⎧   α + 1               
⎪log     (x)            
⎪───────────  for α ≠ -1
⎨   α + 1               
⎪                       
⎪log(log(x))  otherwise 
⎩                       

(4)
⌠               
⎮    ________   
⎮   ╱  x        
⎮ ╲╱  ℯ  - 1  dx
⌡               

     ________         ⎛   ________⎞
    ╱  x              ⎜  ╱  x     ⎟
2⋅╲╱  ℯ  - 1  - 2⋅atan⎝╲╱  ℯ  - 1 ⎠

(5)
⌠               
⎮ sin(log(x)) dx
⌡               

         ⎛         π⎞ 
-√2⋅x⋅cos⎜log(x) + ─⎟ 
         ⎝         4⎠ 
──────────────────────
          2           

(6)
⌠                
⎮      1         
⎮ ──────────── dx
⎮ a + b⋅tan(x)   
⌡                

                               ⎛   1   ⎞
                          b⋅log⎜───────⎟
                               ⎜   2   ⎟
           ⎛a         ⎞        ⎝cos (x)⎠
a⋅x + b⋅log⎜─ + tan(x)⎟ - ──────────────
           ⎝b         ⎠         2       
────────────────────────────────────────
                 2    2                 
                a  + b                  

test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.044s

OK
%

0 コメント:

コメントを投稿