login  home  contents  what's new  discussion  bug reports help  links  subscribe  changes  refresh  edit

I want to get (estimates of) the eigenvalues of a 10x10 matrix of floats:

fricas
m := matrix([[random(1000)$Integer for i in 1..10] for j in 1..10]); sm := m + transpose(m); smf:Matrix Float := sm (1) Type: Matrix(Float) The problem is: If I now call eigenvalues(smf) on the symmetric float matrix smf Axiom 3.0 Beta (February 2005) runs for a very long time (uncomment code if you want to try it): fricas )set messages time on Try this:: fricas )set output tex off  fricas )set output algebra on eigen:=eigenvalues(sm) (2) [ %B | 10 9 8 7 6 %B - 9060 %B - 10221631 %B + 53692462934 %B + 32991488690592 %B + 5 4 - 103347836372632698 %B - 39496518001034749286 %B + 3 2 67792682723480658193502 %B + 13238675729925514491568164 %B + - 6411346841697177723823479672 %B - 777550587908816635397837762624 ] Type: List(Union(Fraction(Polynomial(Integer)),SuchThat?(Symbol,Polynomial(Integer)))) fricas Time: 0.07 (OT) = 0.07 sec solve(rhs(eigen.1),10.0^(-15)) (3) [%B = - 110.9548091175_7676212, %B = - 367.9868971146_480825, %B = - 1238.2551231278_173671, %B = - 1395.4394073487_777468, %B = - 1651.8389981628_01269, %B = 9515.9502244910_992075, %B = 1609.8532163864_54188, %B = 1401.1491995200_013201, %B = 980.4992467521_7715242, %B = 317.0233477218_8936052] Type: List(Equation(Polynomial(Float))) fricas Time: 0.01 (EV) + 0.01 (OT) = 0.02 sec Thank you! This helps, but doesn't answer everything. Since interestingly: fricas charpol := reduce(*, [ rhs(x) - lhs(x) for x in % ]) (4) 10 9 8 %B - 9060.0000000000_000009 %B - 10221630.9999999999_9 %B + 7 6 5_3692462934.000000007 %B + 3299_1488690591.999971 %B + 5 4 - 10334783_6372632698.02 %B - 3949651800_1034749284.0 %B + 3 2 0.6779268272_3480658214 E 23 %B + 0.1323867572_9925514525 E 26 %B + - 0.6411346841_6971777309 E 28 %B - 0.7775505879_0881663822 E 30 Type: Polynomial(Float) fricas Time: 0 sec we cannot recover the characteristic polynomial from this solution. To recover characteristic polynomial one needs good precision, which means very small second argument to solve. To have use of precise solution we also need to increase precision of other floating point computations using digits. Unfortunately, this leads to ugly display, so we only show final result: fricas digits(40) (5) 20 Type: PositiveInteger? fricas Time: 0 sec ev:= solve(rhs(eigen.1),1.0*10^(-35)); Type: List(Equation(Polynomial(Float))) fricas Time: 0.01 (EV) + 0.01 (OT) = 0.02 sec cp:= reduce(*, [rhs(x)-lhs(x) for x in ev]) (7) 10 9 8 %B - 9060.0 %B - 10221630.9999999999_9999999999_9999999999_98 %B + 7 5_3692462933.9999999999_9999999999_999999996 %B + 6 3299_1488690591.9999999999_9999999999_999998 %B + 5 - 10334783_6372632697.9999999999_9999999999_97 %B + 4 - 3949651800_1034749286.0000000000_0000000017 %B + 3 677_9268272348_0658193501.9999999999_9999964 %B + 2 132386_7572992551_4491568164.0000000000_002 %B + - 64113468_4169717772_3823479671.9999999999_53 %B + - 7775505879_0881663539_7837762624.0000000043 Type: Polynomial(Float) fricas Time: 0 sec rhs(eigen.1) - cp (8) 8 7 6 5 - 0.2 E -31 %B + 0.4 E -28 %B + 0.2 E -25 %B - 0.3 E -21 %B + 4 3 2 0.2 E -18 %B + 0.4 E -15 %B - 0.2 E -12 %B - 0.5 E -10 %B + 0.4 E -8 Type: Polynomial(Float) fricas Time: 0 sec fricas )set output algebra off  fricas )set output tex on For matrices of expressions one has to explicitly specify package: fricas A:=matrix[[cos(x),-sin(x)],[sin(x),cos(x)]] (2) Type: Matrix(Expression(Integer)) fricas Time: 0.05 (OT) = 0.05 sec A(1,1) (3) Type: Expression(Integer) fricas Time: 0 sec eigen:=eigenvalues(A)$InnerEigenPackage(EXPR(INT)) (4)
Type: List(Union(Expression(Integer),SparseUnivariatePolynomial?(Expression(Integer))))
fricas
Time: 0 sec

Unfortunatly, result is unsimplified, siplification is separate, for example

fricas
map(simplify, eigen(1)) (5)
Type: SparseUnivariatePolynomial?(Expression(Integer))
fricas
Time: 0.02 (OT) = 0.02 sec

fricas
A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]] (6)
Type: Matrix(Expression(Integer))
fricas
Time: 0 sec
A(1,1)*A(2,2) (7)
Type: Expression(Integer)
fricas
Time: 0 sec
A(2,1)*A(1,2) (8)
Type: Expression(Integer)
fricas
Time: 0 sec
A(1,1)*A(2,2)-A(2,1)*A(1,2) (9)
Type: Expression(Integer)
fricas
Time: 0 sec
B := solve(A(1,1)*A(2,2)-A(2,1)*A(1,2)=0,L) (10)
Type: List(Equation(Expression(Integer)))
fricas
Time: 0.01 (IN) + 0.01 (OT) = 0.02 sec
B(1) (11)
Type: Equation(Expression(Integer))
fricas
Time: 0 sec

fricas
solve(x^2 - 2,x) (12)
Type: List(Equation(Fraction(Polynomial(Integer))))
fricas
Time: 0 sec
sqrt(2) (13)
Type: AlgebraicNumber?
fricas
Time: 0 sec
solve(x^2=4,x) (14)
Type: List(Equation(Fraction(Polynomial(Integer))))
fricas
Time: 0.01 (IN) = 0.01 sec

fricas
P:=matrix[[a, b], [1.0 - a, 1.0 - b]] (15)
Type: Matrix(Polynomial(Float))
fricas
Time: 0 sec
eigenvectors(P)
There are 1 exposed and 1 unexposed library operations named
eigenvectors having 1 argument(s) but none was determined to be
applicable. Use HyperDoc Browse, or issue
)display op eigenvectors
or "\$" to specify which version of the function you need.