Processing math: 100%

2018年9月5日水曜日

学習環境

線型代数入門(松坂 和夫(著)、岩波書店)の第7章(固有値と固有ベクトル)、2(固有多項式(特性多項式))、問題5-(e)、(f)、(g)、(h).を取り組んでみる。



    1. det(x-2-4-10x+1300x)=x(x-2)(x+1)

    2. det(x0-1-1x00-1x)=x3-1

    3. det(x-1002x-230-3x-2)=(x-1)(x-2)2+9(x-1)=(x-1)(x2-4x+4+9)=(x-1)(x2-4x+13)

    4. det(x-5661x-4-2-36x+4)=(x-5)(x-4)(x+4)+36+36-(-12(x-5)+6(x+4)-18(x-4))=(x-5)(x2-16)+72+12x-60-6x-24+18x-72=x3-5x2+(-16+12-6+18)x-84+80=x3-5x2+8x-4=(x-1)(x2-4x+4)=(x-1)(x-2)2

コード(Emacs)

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, Matrix, I
import random

print('5.')

x = symbols('x')


def g(i, j):
    if i == j:
        return 1
    return 0


def f(n, A):
    In = Matrix([[g(i, j) for j in range(n)]
                 for i in range(n)])
    return (x * In - A)


ms = [[[2, 4, 1],
       [0, -1, - 3],
       [0, 0, 0]],
      [[0, 0, 1],
       [1, 0, 0],
       [0, 1, 0]],
      [[1, 0, 0],
       [-2, 2, -3],
       [0, 3, 2]],
      [[5, -6, -6],
       [-1, 4, 2],
       [3, -6, -4]]]


for i, m in enumerate(ms):
    print(f'({chr(ord("e") + i)})')
    m = Matrix(m)
    d = f(3, m).det()
    for t in [m, f(3, m), d.expand(), d.simplify(), d.factor()]:
        pprint(t)
        print()
    print()

入出力結果(Terminal, Jupyter(IPython))

$ ./sample6.py
5.
(e)
⎡2  4   1 ⎤
⎢         ⎥
⎢0  -1  -3⎥
⎢         ⎥
⎣0  0   0 ⎦

⎡x - 2   -4    -1⎤
⎢                ⎥
⎢  0    x + 1  3 ⎥
⎢                ⎥
⎣  0      0    x ⎦

 3    2      
x  - x  - 2⋅x

x⋅(x - 2)⋅(x + 1)

x⋅(x - 2)⋅(x + 1)


(f)
⎡0  0  1⎤
⎢       ⎥
⎢1  0  0⎥
⎢       ⎥
⎣0  1  0⎦

⎡x   0   -1⎤
⎢          ⎥
⎢-1  x   0 ⎥
⎢          ⎥
⎣0   -1  x ⎦

 3    
x  - 1

 3    
x  - 1

        ⎛ 2        ⎞
(x - 1)⋅⎝x  + x + 1⎠


(g)
⎡1   0  0 ⎤
⎢         ⎥
⎢-2  2  -3⎥
⎢         ⎥
⎣0   3  2 ⎦

⎡x - 1    0      0  ⎤
⎢                   ⎥
⎢  2    x - 2    3  ⎥
⎢                   ⎥
⎣  0     -3    x - 2⎦

 3      2            
x  - 5⋅x  + 17⋅x - 13

             2            
9⋅x + (x - 2) ⋅(x - 1) - 9

        ⎛ 2           ⎞
(x - 1)⋅⎝x  - 4⋅x + 13⎠


(h)
⎡5   -6  -6⎤
⎢          ⎥
⎢-1  4   2 ⎥
⎢          ⎥
⎣3   -6  -4⎦

⎡x - 5    6      6  ⎤
⎢                   ⎥
⎢  1    x - 4   -2  ⎥
⎢                   ⎥
⎣ -3      6    x + 4⎦

 3      2          
x  - 5⋅x  + 8⋅x - 4

 3      2          
x  - 5⋅x  + 8⋅x - 4

       2        
(x - 2) ⋅(x - 1)


$

0 コメント:

コメントを投稿