0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

「テンソルTの固有値と固有ベクトルについて教えて下さい。行列との違いを教えて下さい。」をsympyでAI先生に教えてもらいました。

0
Last updated at Posted at 2026-06-04

(本日の)ChatGPT先生へ

テンソルTの固有値と固有ベクトルについて教えて下さい。行列との違いを教えて下さい。

(表示を省略)

上記をsympyで教えて下さい。

以下では、
1.行列の固有値・固有ベクトル
2.テンソル(2階テンソル)の固有値・固有ベクトル
3.座標変換しても固有値が変わらないこと
を SymPy で確認します。

1. 行列の固有値・固有ベクトル

from sympy import *

A = Matrix([
    [2, 1],
    [1, 2]
])

print("A =")
pprint(A)

print("\n固有値")
pprint(A.eigenvals())

print("\n固有ベクトル")
for val, mult, vecs in A.eigenvects():
    print("\nλ =", val)
    for v in vecs:
        pprint(v)

実行結果

固有値

{3: 1, 1: 1}

固有ベクトル

λ = 3

⎡1⎤
⎢ ⎥
⎣1⎦

λ = 1

⎡-1⎤
⎢  ⎥
⎣ 1⎦

2. テンソルとして考える

from sympy import *

T = Matrix([
    [2, 1],
    [1, 2]
])

v = MatrixSymbol('v', 2, 1)
lam = symbols('lambda')

print("T =")
pprint(T)

print("\n固有方程式")

charpoly = factor(det(T - lam*eye(2)))
pprint(Eq(charpoly, 0))

実行結果

(λ - 3)(λ - 1) = 0

3. 固有値問題を添字表示で確認

from sympy import *

T11,T12,T21,T22 = symbols(
    'T11 T12 T21 T22'
)

vx,vy = symbols('vx vy')
lam = symbols('lambda')

T = Matrix([
    [T11,T12],
    [T21,T22]
])

v = Matrix([
    [vx],
    [vy]
])

eq = T*v - lam*v

print("Tv - λv =")
pprint(eq)

実行結果

⎡T₁₁⋅vx + T₁₂⋅vy - λ⋅vx⎤
⎢                      ⎥
⎣T₂₁⋅vx + T₂₂⋅vy - λ⋅vy⎦

4. 座標変換(相似変換)

from sympy import *

T = Matrix([
    [2,1],
    [1,2]
])

P = Matrix([
    [1,1],
    [0,1]
])

Tp = simplify(P.inv()*T*P)

print("T' =")
pprint(Tp)

実行結果

⎡1  0⎤
⎢    ⎥
⎣1  3⎦

5. 固有値が変わらないことを確認

from sympy import *

T = Matrix([
    [2,1],
    [1,2]
])

P = Matrix([
    [1,1],
    [0,1]
])

Tp = simplify(P.inv()*T*P)

print("T の固有値")
pprint(T.eigenvals())

print("\nT' の固有値")
pprint(Tp.eigenvals())

実行結果

T の固有値
{3: 1, 1: 1}

T' の固有値
{3: 1, 1: 1}

6. 応力テンソル(構造力学)

from sympy import *

sigma = Matrix([
    [100,30],
    [30,50]
])

print("応力テンソル")
pprint(sigma)

print("\n主応力")

for val, mult, vecs in sigma.eigenvects():
    print("\nσ =", N(val))
    pprint(vecs[0])

実行結果

σ = 114.051...
σ = 35.949...

7. SymPyで「テンソル」と「行列」の違いを実感する例

from sympy import *

T = Matrix([
    [2,1],
    [1,2]
])

P = Matrix([
    [1,1],
    [0,1]
])

Tp = simplify(P.inv()*T*P)

print("元の成分")
pprint(T)

print("\n座標変換後の成分")
pprint(Tp)

print("\n固有値")
pprint(T.eigenvals())

print("\n固有値(変換後)")
pprint(Tp.eigenvals())

実行結果

元の成分

⎡2  1⎤
⎢    ⎥
⎣1  2⎦

座標変換後の成分
⎡1  0⎤
⎢    ⎥
⎣1  3⎦

固有値
{1: 1, 3: 1}


固有値(変換後)
{1: 1, 3: 1}

いつもと違うおすすめです。

Qiita内

wikipedia内

sympy doc

  1. 行列の固有値・固有ベクトル
  2. 固有値が変わらないことを確認

eigenvals(
error_when_incomplete=True,
**flags,
)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?