```python
# https://colab.research.google.com/github/kassbohm/wb-snippets/blob/master/ipynb/HTM_03/Selbst/4.2.ipynb

from sympy import *
from sympy.physics.units import kilogram as kg
from sympy.physics.units import meter as meter

# 1:
mu, l = var("mu, l")

(l1, l2, l3) = (2*l, l, 2*l/3)
(m1, m2, m3) = (mu*l1, mu*l2, mu*l3)
(xi1, xi2, xi3) = (m1*l1**2/12, m2*l2**2/12, m3*l3**2/12)

# 2:
IC1 = xi1 * Matrix([
    [1,0,0],
    [0,0,0],
    [0,0,1],
    ])

IC2 = xi2 * Matrix([
    [0,0,0],
    [0,1,0],
    [0,0,1],
    ])

IC3 = xi3 * Matrix([
    [1,0,0],
    [0,1,0],
    [0,0,0],
    ])

pprint("\nIC1, IC2, IC3 / ( μl³ ):")
for x in [IC1, IC2, IC3]:
    tmp = x / (mu*l**3)
    pprint(tmp)

# 3:
M, dx, dy, dz = var("M, dx, dy, dz")

(dx1, dy1, dz1) = (0, l1/2, 0)
(dx2, dy2, dz2) = (l2/2, l1, 0)
(dx3, dy3, dz3) = (l2, l1, l3/2)

tmp = Matrix([
    [dy**2 + dz**2,0,0],
    [0,dx**2 + dz**2,0],
    [0,0,dx**2 + dy**2],
    ])
tmp+= Matrix([
    [     0,-dx*dy,-dx*dz],
    [-dy*dx,     0,-dy*dz],
    [-dz*dx,-dz*dy,     0],
    ])
tmp*=M

# 4:
pprint("\nI01, I02, I03 / ( μl³ ):")
I01 = IC1 + tmp.subs([(M,m1), (dx, dx1), (dy, dy1), (dz, dz1)])
I02 = IC2 + tmp.subs([(M,m2), (dx, dx2), (dy, dy2), (dz, dz2)])
I03 = IC3 + tmp.subs([(M,m3), (dx, dx3), (dy, dy3), (dz, dz3)])
for x in [I01, I02, I03]:
    tmp = x / (mu*l**3)
    pprint(tmp)

# 5:
pprint("\nI0 / ( μl³ ):")
I0 = I01 + I02 + I03
I0 /= mu*l**3
pprint(I0)

pprint("\nEigenvalues of I0 / (kg m²):")
f = lambda x: N(x,3)
lam = var("lambda")
eq = Eq(det(I0 - lam*eye(3,3)))
sol = solve(eq, lam)

mu_quant = 4*kg/meter
l_quant = 4*meter/10
for s in sol:
    tmp = N(s,5, chop=True)
    tmp = tmp*mu_quant*l_quant**3
    tmp /= kg * meter**2
    pprint(tmp)


pprint("\nb:")
b = Matrix([1, 2, S(2)/3])
b /= b.norm()
pprint(b)
pprint(N(b,4))

pprint("\nI0b / ( μl³ ):")
tmp = I0*b
pprint(tmp)
pprint("\nJ / ( μl³ ):")
J = b.transpose()*I0*b
J = J[0]
pprint(J)
pprint("\nJ / (kg m²):")
tmp = J
tmp *= mu_quant*l_quant**3
tmp /= kg
tmp /= meter*meter
pprint(N(tmp,4))

# IC1, IC2, IC3 / ( μl³ ):
# ⎡2/3  0   0 ⎤
# ⎢           ⎥
# ⎢ 0   0   0 ⎥
# ⎢           ⎥
# ⎣ 0   0  2/3⎦
# ⎡0   0     0  ⎤
# ⎢             ⎥
# ⎢0  1/12   0  ⎥
# ⎢             ⎥
# ⎣0   0    1/12⎦
# ⎡2/81   0    0⎤
# ⎢             ⎥
# ⎢ 0    2/81  0⎥
# ⎢             ⎥
# ⎣ 0     0    0⎦
#
# I01, I02, I03 / ( μl³ ):
# ⎡8/3  0   0 ⎤
# ⎢           ⎥
# ⎢ 0   0   0 ⎥
# ⎢           ⎥
# ⎣ 0   0  8/3⎦
# ⎡4   -1    0  ⎤
# ⎢             ⎥
# ⎢-1  1/3   0  ⎥
# ⎢             ⎥
# ⎣0    0   13/3⎦
# ⎡224             ⎤
# ⎢───   -4/3  -2/9⎥
# ⎢ 81             ⎥
# ⎢                ⎥
# ⎢       62       ⎥
# ⎢-4/3   ──   -4/9⎥
# ⎢       81       ⎥
# ⎢                ⎥
# ⎣-2/9  -4/9  10/3⎦
#
# I0 / ( μl³ ):
# ⎡764             ⎤
# ⎢───   -7/3  -2/9⎥
# ⎢ 81             ⎥
# ⎢                ⎥
# ⎢       89       ⎥
# ⎢-7/3   ──   -4/9⎥
# ⎢       81       ⎥
# ⎢                ⎥
# ⎣-2/9  -4/9  31/3⎦
#
# Eigenvalues of I0 / (kg m²):
# 2.5627
# 2.6593
# 0.11929
#
# b:
# ⎡3/7⎤
# ⎢   ⎥
# ⎢6/7⎥
# ⎢   ⎥
# ⎣2/7⎦
# ⎡0.4286⎤
# ⎢      ⎥
# ⎢0.8571⎥
# ⎢      ⎥
# ⎣0.2857⎦
#
# I0b / ( μl³ ):
# ⎡ 374 ⎤
# ⎢ ─── ⎥
# ⎢ 189 ⎥
# ⎢     ⎥
# ⎢-5/27⎥
# ⎢     ⎥
# ⎢ 52  ⎥
# ⎢ ──  ⎥
# ⎣ 21  ⎦
#
# J / ( μl³ ):
# 88
# ──
# 63
#
# J / (kg m²):
# 0.3576

```

473cd534d9ba8016209e50e09e37703ae1d9c04d
ipynb
Jupyter Notebook
ipynb/HTM_03/Selbst/4.2.ipynb
kassbohm/wb-snippets
f1ac5194e9f60a9260d096ba5ed1ce40b844a3fe
MIT
ipynb/HTM_03/Selbst/4.2.ipynb
kassbohm/wb-snippets
f1ac5194e9f60a9260d096ba5ed1ce40b844a3fe
MIT
ipynb/HTM_03/Selbst/4.2.ipynb
kassbohm/wb-snippets
f1ac5194e9f60a9260d096ba5ed1ce40b844a3fe
MIT
Qwen/Qwen-72B
1. YES
2. YES