2019年9月12日木曜日

学習環境

ラング線形代数学(下) (ちくま学現文庫)(S.ラング (著)、芹沢 正三 (翻訳)、筑摩書房)の12章(多項式と素因子分解)、7(多項式の α - 進展開)、練習問題2の解答を求めてみる。



    1. a + b t - 3 + c t - 3 2 = a + b t - 3 b + c t 2 - 6 c t + 9 c a - 3 b + 9 c = - 1 b - 6 c = 0 c = 1 b = 6 a - 18 + 9 = - 1 a = 8

      よって、問題の 多項式の3-進展開は、

      t 2 - 1 = 8 + 6 t - 3 + t - 3 2

    2. a + b t - 3 + c t - 3 2 + t - 3 3 = a + b t - 3 b + c t 2 - 6 c t + 9 c + t 3 - 9 t 2 + 27 t - 27 c - 9 = 0 c = 9 b - 54 + 27 = 1 b = 28 a - 84 + 81 - 27 = - 1 a = 29 t 3 + t - 1 = 29 + 28 t - 3 + 9 t - 3 2 + t - 3 3

    3. a + b t - 3 + t - 3 2 = a + b t - 3 b + t 2 - 6 t + 9 b - 6 = 0 b = 6 a - 18 + 9 = 3 a = 12 t 2 + 3 = 12 + 6 t - 3 + t - 3 2

    4. a + b t - 3 + c t - 3 2 + d t - 3 3 + t - 3 4 = a + b t - 3 b + c t 2 - 6 c t + 9 c + d t 3 - 9 d t 2 + 27 dt - 27 d + t 4 - 12 t 3 + 54 t 2 - 108 t + 81 d - 12 = 2 d = 14 c - 126 + 54 = 0 c = 72 b - 432 + 378 - 108 = - 1 b = 161 a - 483 + 648 - 378 + 81 = 5 a = 137 t 4 + 2 t 3 - t + 5 = 137 + 161 t - 3 + 72 t - 3 2 + 14 t - 3 3 + t - 3 4

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols
from unittest import TestCase, main


print('2.')


class MyTest(TestCase):
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test(self):
        t = symbols('t')
        coefficients1 = [(-1, 0, 1),
                         (-1, 1, 0, 1),
                         (3, 0, 1),
                         (5, -1, 0, 2, 1)]
        coefficients2 = [(8, 6, 1),
                         (29, 28, 9, 1),
                         (12, 6, 1),
                         (137, 161, 72, 14, 1)]

        for cs1, cs2 in zip(coefficients1, coefficients2):
            self.assertEqual(
                sum([c * t ** i for i, c in enumerate(cs1)]),
                sum([c * (t - 3) ** i for i, c in enumerate(cs2)]).expand())


if __name__ == '__main__':
    main()

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

C:\Users\...>py sample2.py
2.
.
----------------------------------------------------------------------
Ran 1 test in 0.010s

OK

C:\Users\...>

0 コメント:

コメントを投稿