2019年11月14日木曜日

学習環境

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


  1. n+m0,n-n0-11sinnxcosmxdx=-11sinnx+mx+sinnx-mx2dx=-11sinn+mx+sinn-mx2dx=12-cosn+mxn+m+-cosn-mxn-m-11=-12cosn+m-cos-n+mn+m+cosn-m-cos-n-mn-m=-12cosn+n-cosn+mn+m+cosn-m-cosn-mn-m=0

    また、

    n+m=0,n-m0

    のとき、

    -11sinnxcosmxdx=-12cosn-m-cosn-mn-m=0

    また、

    n+m0,n-m=0

    のときも同様に0。

    また、

    n+m=n-m=0

    の場合 も同様に0。

    よって、 関牧

    sinnx,cosmxn,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 コメント:

コメントを投稿