2019年11月14日木曜日

学習環境

ラング線形代数学(上) (ちくま学現文庫)(S.ラング (著)、芹沢 正三 (翻訳)、筑摩書房)の1章(R^nにおけるベクトル)、3(スカラー積)、練習問題7の解答を求めてみる。


  1. n + m 0 , n - n 0 - 1 1 sin n x cos m x dx = - 1 1 sin n x + m x + sin n x - m x 2 dx = - 1 1 sin n + m x + sin n - m x 2 dx = 1 2 - cos n + m x n + m + - cos n - m x n - m - 1 1 = - 1 2 cos n + m - cos - n + m n + m + cos n - m - cos - n - m n - m = - 1 2 cos n + n - cos n + m n + m + cos n - m - cos n - m n - m = 0

    また、

    n + m = 0 , n - m 0

    のとき、

    - 1 1 sin n x cos m x dx = - 1 2 cos n - m - cos n - m n - m = 0

    また、

    n + m 0 , n - m = 0

    のときも同様に0。

    また、

    n + m = n - m = 0

    の場合 も同様に0。

    よって、 関牧

    sin n x , cos m x n , m

    は問題 のスカラー積に関して互いに直交している。

    (証明終)

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, Integral, sin, cos, plot

print('7.')

x = symbols('x')


class MyTestCase(TestCase):
    def test(self):
        n, m = symbols('n, m', integer=True)
        self.assertEqual(
            Integral(sin(n * x) * cos(m * x), (x, -1, 1)).doit(), 0)


p = plot(sin(x), cos(2 * x), sin(x) * cos(2 * x),
         (x, -2, 2),
         ylim=(-2, 2),
         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(f'sample7')

if __name__ == '__main__':
    main()

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

% ./sample7.py -v
7.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 1.681s

OK
%

0 コメント:

コメントを投稿