2020年1月11日土曜日

学習環境

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



    1. -ππsinmxsinnxdx=-ππcosm-nx-cosm+nx2dxm=n0-ππ1-cosm+nx2dx=0π1-cosm+nxdx=x-sinm+nxm+n0π=πmnsinm-nxm-n-sinm+nxm+n0π=0

    2. -ππsinmxcosnxdx=-ππsinm+nx+sinm-nx2dx=0

    3. -ππcosmxcosnxdx=-ππcosm+nx+cosm-nx2dxm=n00πcosm+nx+1dx=sinm+nxm+n+x0π=πmn0m=n=0-ππdx=2π

コード

#!/usr/bin/env python3
from sympy import pprint, symbols, sin, cos, pi, Integral, plot

print('3.')

x = symbols('x')
m, n = symbols('m, n', integer=True, nonnegative=True)
fs = [sin(m * x) * sin(n * x),
      sin(m * x) * cos(n * x),
      cos(m * x) * cos(n * x)]

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

p = plot(*[f.subs({m: m0, n: n0})
           for f in fs
           for m0 in range(0, 2)
           for n0 in range(0, 2)],
         (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('sample3.png')

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

% ./sample3.py 
3.
(1)
π                      
⌠                      
⎮  sin(m⋅x)⋅sin(n⋅x) dx
⌡                      
-π                     

⎧0   for (m = 0 ∧ n = 0) ∨ (m = 0 ∧ m = n ∧ n = 0) ∨ (m = 0 ∧ m = -n ∧ n = 0) 
⎪                                                                             
⎪-π   for (m = 0 ∧ m = -n) ∨ (m = -n ∧ m = n) ∨ (m = -n ∧ n = 0) ∨ (m = 0 ∧ m 
⎨                                                                             
⎪π                                          for (m = 0 ∧ m = n) ∨ (m = n ∧ n =
⎪                                                                             
⎩0                                                            otherwise       

∨ (m = 0 ∧ m = -n ∧ m = n ∧ n = 0) ∨ m = 0 ∨ n = 0
                                                  
= -n ∧ m = n) ∨ (m = -n ∧ m = n ∧ n = 0) ∨ m = -n 
                                                  
 0) ∨ m = n                                       
                                                  
                                                  

(2)
π                      
⌠                      
⎮  sin(m⋅x)⋅cos(n⋅x) dx
⌡                      
-π                     

0

(3)
π                      
⌠                      
⎮  cos(m⋅x)⋅cos(n⋅x) dx
⌡                      
-π                     

⎧2⋅π                               for (m = 0 ∧ n = 0) ∨ (m = 0 ∧ m = n ∧ n = 
⎪                                                                             
⎨ π   for (m = 0 ∧ m = -n) ∨ (m = 0 ∧ m = n) ∨ (m = -n ∧ m = n) ∨ (m = n ∧ n =
⎪                                                                             
⎩ 0                                                                           

0) ∨ (m = 0 ∧ m = -n ∧ n = 0) ∨ (m = 0 ∧ m = -n ∧ m = n ∧ n = 0)              
                                                                              
 0) ∨ (m = -n ∧ n = 0) ∨ (m = 0 ∧ m = -n ∧ m = n) ∨ (m = -n ∧ m = n ∧ n = 0) ∨
                                                                              
      otherwise                                                               

               
               
 m = -n ∨ m = n
               
               

%

0 コメント:

コメントを投稿