printbr(A:eq(eig.R * eig.Lambda * eig.L))
printbr('permuting to', A:eq(eig.R * eig.Lambda * eig.L))local A = Matrix({-6, 3}, {4, 5})
local ch = A:charpoly(lambda)
printbr(ch)
local solns = table{ch:solve(lambda)}
printbr(solns:mapi(tostring):concat',')
simplifyAssertEq(ch, (lambda^2 + lambda - 42):eq(0))
local eig = A:eigen()
if Constant.isValue(eig.Lambda[1][1], 6) then local P = Matrix({0,1},{1,0}) eig.R = (eig.R * P)() eig.Lambda = (P * eig.Lambda * P)() eig.L = (P * eig.L)() end
simplifyAssertEq(eig.L, Matrix({-frac(4,13), frac(1,13)}, {frac(4, 13), frac(12,13)}))
simplifyAssertEq(eig.R, Matrix({-3, frac(1,4)}, {1, 1}))
simplifyAssertEq(eig.Lambda, Matrix.diagonal(-7, 6))
|
${-{\left({{12} + {{{\left({{5}{-{\lambda}}}\right)}} {{\left({{6} + {\lambda}}\right)}}}}\right)}} = {0}$
${\lambda} = {6}$,${\lambda} = {-{7}}$ ${{-{\left({{12} + {{{\left({{5}{-{\lambda}}}\right)}} {{\left({{6} + {\lambda}}\right)}}}}\right)}} = {0}} = {{{{{\lambda}^{2}} + {\lambda}}{-{42}}} = {0}}$ ${\left[\begin{array}{cc} -{\frac{4}{13}}& \frac{1}{13}\\ \frac{4}{13}& \frac{12}{13}\end{array}\right]} = {\left[\begin{array}{cc} -{\frac{4}{13}}& \frac{1}{13}\\ \frac{4}{13}& \frac{12}{13}\end{array}\right]}$ ${\left[\begin{array}{cc} -{3}& \frac{1}{4}\\ 1& 1\end{array}\right]} = {\left[\begin{array}{cc} -3& \frac{1}{4}\\ 1& 1\end{array}\right]}$ ${\left[\begin{array}{cc} -{7}& 0\\ 0& 6\end{array}\right]} = {\left[\begin{array}{cc} -7& 0\\ 0& 6\end{array}\right]}$ GOOD |
time: 63.789000ms stack: size: 7
|
printbr('permuting to', A:eq(eig.R * eig.Lambda * eig.L))local A = Matrix({2, 0, 0}, {0, 4, 5}, {0, 4, 3})
local ch = A:charpoly(lambda)
printbr(ch)
local solns = table{ch:solve(lambda)}
printbr(solns:mapi(tostring):concat',')
local eig = A:eigen()
printbr(A:eq(eig.R * eig.Lambda * eig.L))
if Constant.isValue(eig.Lambda[1][1], 6) then local P = Matrix({0,1},{1,0}) eig.R = (eig.R * P)() eig.Lambda = (P * eig.Lambda * P)() eig.L = (P * eig.L)() printbr('permuting to', A:eq(eig.R * eig.Lambda * eig.L)) end
simplifyAssertEq(eig.R, Matrix({1, 0, 0}, {0, -1, 1}, {0, frac(5,4), 1}):T())
simplifyAssertEq(eig.L, Matrix({1, 0, 0}, {0, -frac(4,9), frac(4,9)}, {0, frac(5,9), frac(4,9)}):T())
simplifyAssertEq(eig.Lambda, Matrix.diagonal(2, -1, 8))
|
${{{\left({{-{20}} + {{{\left({{3}{-{\lambda}}}\right)}} {{\left({{4}{-{\lambda}}}\right)}}}}\right)}} {{\left({{2}{-{\lambda}}}\right)}}} = {0}$
${\lambda} = {2}$,${\lambda} = {-{1}}$,${\lambda} = {8}$ ${\left[\begin{array}{ccc} 2& 0& 0\\ 0& 4& 5\\ 0& 4& 3\end{array}\right]} = {{{\left[\begin{array}{ccc} 1& 0& 0\\ 0& -{1}& \frac{5}{4}\\ 0& 1& 1\end{array}\right]}} {{\left[\begin{array}{ccc} 2& 0& 0\\ 0& -{1}& 0\\ 0& 0& 8\end{array}\right]}} {{\left[\begin{array}{ccc} 1& 0& 0\\ 0& -{\frac{4}{9}}& \frac{5}{9}\\ 0& \frac{4}{9}& \frac{4}{9}\end{array}\right]}}}$ ${\left[\begin{array}{ccc} 1& 0& 0\\ 0& -{1}& \frac{5}{4}\\ 0& 1& 1\end{array}\right]} = {\left[\begin{array}{ccc} 1& 0& 0\\ 0& -1& \frac{5}{4}\\ 0& 1& 1\end{array}\right]}$ ${\left[\begin{array}{ccc} 1& 0& 0\\ 0& -{\frac{4}{9}}& \frac{5}{9}\\ 0& \frac{4}{9}& \frac{4}{9}\end{array}\right]} = {\left[\begin{array}{ccc} 1& 0& 0\\ 0& -{\frac{4}{9}}& \frac{5}{9}\\ 0& \frac{4}{9}& \frac{4}{9}\end{array}\right]}$ ${\left[\begin{array}{ccc} 2& 0& 0\\ 0& -{1}& 0\\ 0& 0& 8\end{array}\right]} = {\left[\begin{array}{ccc} 2& 0& 0\\ 0& -1& 0\\ 0& 0& 8\end{array}\right]}$ GOOD |
time: 53.722000ms stack: size: 7
|
printbr(A:eq(eig.R * eig.Lambda * eig.L))
OK HERE ... what about lambda, and their associations with R and L in the generalized system?local A = Matrix({1, 1}, {0, 1})
printbr'without generalization:'
local eig = A:eigen()
for k,v in pairs(eig) do
printbr(k, '=', v)
end
assert(eig.defective)
assertEq(eig.R, Matrix{1, 0}:T())
simplifyAssertAllEq(eig.allLambdas, {1})
printbr'with generalization:'
eig = A:eigen{generalize=true, verbose=true}
for k,v in pairs(eig) do
printbr(k, '=', v)
end
printbr('#allLambdas', #eig.allLambdas)
printbr('#lambdas', #eig.lambdas)
printbr('lambdas', eig.lambdas:mapi(function(l) return '{mult='..l.mult..', expr='..l.expr..'}' end):concat',')
simplifyAssertEq(eig.L, Matrix.identity(2))
simplifyAssertEq(eig.R, Matrix.identity(2))
|
without generalization:
allLambdas = table: 0x70b33a63cf50 lambdas = table: 0x70b33a63ce68 R = $\left[\begin{array}{c} 1\\ 0\end{array}\right]$ defective = true charPoly = ${{\left({{1}{-{λ}}}\right)}^{2}} = {0}$ Lambda = $\left[\begin{array}{c} 1\end{array}\right]$ ${\left[\begin{array}{c} 1\\ 0\end{array}\right]} = {\left[\begin{array}{c} 1\\ 0\end{array}\right]}$ ${1} = {1}$ ${1} = {1}$ ${1} = {1}$ with generalization: ${A} = {\left[\begin{array}{cc} 1& 1\\ 0& 1\end{array}\right]}$ ${I} = {\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]}$ ${{A}{-{{{λ}} \cdot {{I}}}}} = {\left[\begin{array}{cc} {1}{-{λ}}& 1\\ 0& {1}{-{λ}}\end{array}\right]}$ charPoly ${{{\left({{1}{-{λ}}}\right)}} {{\left({{1}{-{λ}}}\right)}}} = {0}$ after simplify(), charPoly ${{\left({{1}{-{λ}}}\right)}^{2}} = {0}$ ${λ} = {1}$, ${λ} = {1}$ $λ$ $= \{$ $1$, $1$ $\}$ mult 2 expr $1$ finding nullspace for $1$ $\left[\begin{array}{c} 1\\ 0\end{array}\right]$ ...is defective, gathering more generalized eigenvectors trying again for generalized eigensystem... finding nullspace of (A - I λ)^2 = $\left[\begin{array}{cc} 0& 0\\ 0& 0\end{array}\right]$ which is $\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]$ nullspace dim of (A - I λ)^2 = 2 ...times (A - λ I) is $\left[\begin{array}{cc} 0& 1\\ 0& 0\end{array}\right]$ checking new potential vector product $\left[\begin{matrix} 0 \\ 0\end{matrix}\right]$ ...and it's all zeroes so we already considered this vector checking new potential vector product $\left[\begin{matrix} 1 \\ 0\end{matrix}\right]$ adding col 2 right eigenvector of λ= $1$ is $\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]$ ${R} = {\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]}$ ${L} = {\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]}$ ${Λ} = {\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]}$ verify: ${{{\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]}} {{\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]}} {{\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]}}} = {\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]}$ allLambdas = table: 0x70b33a51bd18 lambdas = table: 0x70b33a51ba28 L = $\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]$ R = $\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]$ defective = true charPoly = ${{\left({{1}{-{λ}}}\right)}^{2}} = {0}$ Lambda = $\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]$ #allLambdas 2 #lambdas 1 lambdas {mult=2, expr=$1$} ${\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]} = {\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]}$ ${\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]} = {\left[\begin{array}{cc} 1& 0\\ 0& 1\end{array}\right]}$ GOOD |
time: 13.345000ms stack: size: 7
|