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

Edit detail for numerical linear algebra revision 3 of 5

1 2 3 4 5
Editor: test1
Time: 2013/05/23 17:40:25 GMT+0
Note:

removed:
-From unknown Fri Jun 24 04:47:02 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 04:47:02 -0500
-Subject: test
-Message-ID: <20050624044702-0500@page.axiom-developer.org>
-
-\begin{axiom}
-A:=[[cos(x),-sin(x)],[sin(x),cos(x)]]
-\end{axiom}
-  
-

removed:
-
-From unknown Fri Jun 24 04:54:14 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 04:54:14 -0500
-Subject: test
-Message-ID: <20050624045414-0500@page.axiom-developer.org>
-
-\begin{axiom}
-A:=matrix[[cos(x),-sin(x)],[sin(x),cos(x)]]
-\end{axiom}

removed:
-\begin{axiom}
-A:=matrix[[cos(x),-sin(x)],[sin(x),cos(x)]]
-eigen:=eigenvalues(A)
-\end{axiom}
-
-From unknown Fri Jun 24 07:59:17 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 07:59:17 -0500
-Subject: test
-Message-ID: <20050624075917-0500@page.axiom-developer.org>
-
-\begin{axiom}
-A:=matrix[[cos(x),-sin(x)],[sin(x),cos(x)]]
-\end{axiom}
-
-From unknown Fri Jun 24 07:59:52 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 07:59:52 -0500
-Subject: test
-Message-ID: <20050624075952-0500@page.axiom-developer.org>

added:
eigen:=eigenvalues(A)

added:
Unfortunately, currently eigenvalues does not work for general expressions,
which causes the failure above.

removed:
-\begin{axiom}
-A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]
-A(1,1)*A(2,2)-A(2,1)*A(1,2)
-\end{axiom}
-
-From unknown Fri Jun 24 08:06:31 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 08:06:31 -0500
-Subject: test
-Message-ID: <20050624080631-0500@page.axiom-developer.org>
-

added:
A(1,1)*A(2,2)-A(2,1)*A(1,2)
B := solve(A(1,1)*A(2,2)-A(2,1)*A(1,2)=0,L)
B(1)

removed:
-
-
-From unknown Fri Jun 24 08:07:40 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 08:07:40 -0500
-Subject: test
-Message-ID: <20050624080740-0500@page.axiom-developer.org>
-
-\begin{axiom}
-A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]
-solve(A(1,1)*A(2,2)-A(2,1)*A(1,2)=0,L)
-\end{axiom}
-
-
-From unknown Fri Jun 24 08:10:32 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 08:10:32 -0500
-Subject: test
-Message-ID: <20050624081032-0500@page.axiom-developer.org>
-
-\begin{axiom}
-A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]
-solve(A(1,1)*A(2,2)-A(2,1)*A(1,2)=0,L)
-L
-\end{axiom}
-
-From unknown Fri Jun 24 08:11:21 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 08:11:21 -0500
-Subject: test
-Message-ID: <20050624081121-0500@page.axiom-developer.org>
-
-\begin{axiom}
-A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]
-B=solve(A(1,1)*A(2,2)-A(2,1)*A(1,2)=0,L)
-\end{axiom}
-
-From unknown Fri Jun 24 08:13:01 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 08:13:01 -0500
-Subject: test
-Message-ID: <20050624081301-0500@page.axiom-developer.org>
-
-\begin{axiom}
-A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]
-solve(A(1,1)*A(2,2)-A(2,1)*A(1,2)=0,L)
-L(1)
-\end{axiom}
-
-From unknown Fri Jun 24 08:13:40 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 08:13:40 -0500
-Subject: test
-Message-ID: <20050624081340-0500@page.axiom-developer.org>
-
-\begin{axiom}
-A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]
-solve(A(1,1)*A(2,2)-A(2,1)*A(1,2)=0,L)
-L.1
-\end{axiom}

changed:
-solve(x^2,x)
-\end{axiom}
-
-From unknown Fri Jun 24 08:17:43 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 08:17:43 -0500
-Subject: test
-Message-ID: <20050624081743-0500@page.axiom-developer.org>
-
-\begin{axiom}
solve(x^2 - 2,x)

removed:
-\end{axiom}
-
-From unknown Fri Jun 24 08:18:43 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 08:18:43 -0500
-Subject: 
-Message-ID: <20050624081843-0500@page.axiom-developer.org>
-
-\begin{axiom}

removed:
-
-From unknown Fri Jun 24 08:20:13 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 08:20:13 -0500
-Subject: test
-Message-ID: <20050624082013-0500@page.axiom-developer.org>
-
-\begin{axiom}
-solve(x^2=4,x)
-x
-\end{axiom}
-
-From unknown Fri Jun 24 08:21:50 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 08:21:50 -0500
-Subject: 
-Message-ID: <20050624082150-0500@page.axiom-developer.org>
-
-\begin{axiom}
-e=vector[1,2]
-e=solve(x^2=4,x)
-\end{axiom}
-
-From unknown Fri Jun 24 08:22:22 -0500 2005
-From: unknown
-Date: Fri, 24 Jun 2005 08:22:22 -0500
-Subject: 
-Message-ID: <20050624082222-0500@page.axiom-developer.org>
-
-\begin{axiom}
-e=solve(x^2=4,x)
-\end{axiom}

I'm new to Axiom, so maybe I'm doing things in a stupid way.

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

fricas
m := matrix([[random()$Integer for i in 1..10] for j in 1..10]); sm := m + transpose(m); smf:Matrix Float := sm

\label{eq1}\left[ 
\begin{array}{cccccccccc}
{19101368.0}&{61278041.0}&{70995855.0}&{34982229.0}&{73454712.0}&{3
3749409.0}&{43151276.0}&{56873386.0}&{36952224.0}&{71646262.0}
\
{61278041.0}&{2968650.0}&{85736917.0}&{24332967.0}&{4553241.0}&{6
3473373.0}&{20558912.0}&{92297086.0}&{54375004.0}&{83468790.0}
\
{70995855.0}&{85736917.0}&{15829350.0}&{1_19704936.0}&{365228
09.0}&{39703630.0}&{6801050.0}&{36762682.0}&{42794759.0}&{353
93317.0}
\
{34982229.0}&{24332967.0}&{1_19704936.0}&{26538740.0}&{489820
62.0}&{89215221.0}&{64457881.0}&{15519476.0}&{57773751.0}&{29
448891.0}
\
{73454712.0}&{4553241.0}&{36522809.0}&{48982062.0}&{46207882.0}&{4
4673466.0}&{1_00571933.0}&{60490393.0}&{96108269.0}&{59277125.0}
\
{33749409.0}&{63473373.0}&{39703630.0}&{89215221.0}&{44673466.0}&{1
826916.0}&{1_19858422.0}&{67603577.0}&{82798875.0}&{76291926.0}
\
{43151276.0}&{20558912.0}&{6801050.0}&{64457881.0}&{1_0057193
3.0}&{1_19858422.0}&{1_28173768.0}&{91100645.0}&{74438999.0}&{6
8433103.0}
\
{56873386.0}&{92297086.0}&{36762682.0}&{15519476.0}&{60490393.0}&{6
7603577.0}&{91100645.0}&{53378192.0}&{36023315.0}&{94404719.0}
\
{36952224.0}&{54375004.0}&{42794759.0}&{57773751.0}&{96108269.0}&{8
2798875.0}&{74438999.0}&{36023315.0}&{1_28828432.0}&{30785633.0}
\
{71646262.0}&{83468790.0}&{35393317.0}&{29448891.0}&{59277125.0}&{7
6291926.0}&{68433103.0}&{94404719.0}&{30785633.0}&{91534560.0}
(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
eigen:=eigenvalues(sm)

\label{eq2}\left[ \left(\%A \mid{{{\%A}^{10}}-{{514387858}\ {{\%A}^{9}}}-{{81063769717750363}\ {{\%A}^{8}}}+{{186174851844360357608590
98}\ {{\%A}^{7}}}+{{1995237067328519443299986185143419}\ {{\%A}^{6}}}-{{196489116329546029723739477630207952322692}\ {{\%A}^{5}}}-{{17713684304188911913775711272171401718653930456014}\ {{\%A}^{4}}}+{{56122609706355950813933443516197394131149130564764128
1838}\ {{\%A}^{3}}}+{{399896551509446465317296211063275390420
68724401313082575314065916}\ {{\%A}^{2}}}-{{45738107297399937
0254434039690959701937607418001547553700564621454196664}\  \%A}-{123950107976044776612898516638225104195271993434900035759953
61443410961398217808}}\right) \right](2)
Type: List(Union(Fraction(Polynomial(Integer)),SuchThat?(Symbol,Polynomial(Integer))))
fricas
Time: 0.01 (EV) + 0.09 (OT) = 0.10 sec
solve(rhs(eigen.1),15)

\label{eq3}\begin{array}{@{}l}
\displaystyle
\left[{\%A = -{14233140}}, \:{\%A = -{54892644}}, \:{\%A = -{9
3438316}}, \: \right.
\
\
\displaystyle
\left.{\%A = -{104131052}}, \:{\%A = -{139552428}}, \:{\%A ={5
90433868}}, \: \right.
\
\
\displaystyle
\left.{\%A ={136341412}}, \:{\%A ={118357956}}, \:{\%A ={5185
2748}}, \: \right.
\
\
\displaystyle
\left.{\%A ={23649452}}\right] 
(3)
Type: List(Equation(Polynomial(Fraction(Integer))))
fricas
Time: 0.01 (IN) + 0.03 (EV) = 0.04 sec

Thank you! This helps, but doesn't answer everything. Since interestingly:

fricas
charpol := reduce(*, [ rhs(x) - lhs(x) for x in % ])

\label{eq4}\begin{array}{@{}l}
\displaystyle
{{\%A}^{10}}-{{514387856}\ {{\%A}^{9}}}-{{81063768099338128}\ {{\%A}^{8}}}+ 
\
\
\displaystyle
{{18617484846001637830908928}\ {{\%A}^{7}}}+ 
\
\
\displaystyle
{{1995236975166117972408075311659520}\ {{\%A}^{6}}}- 
\
\
\displaystyle
{{196489116089160028107106986738280672256000}\ {{\%A}^{5}}}- \
\
\displaystyle
{{
\begin{array}{@{}l}\displaystyle
17713683140651728063324774167477194777834644447 \
232
(4)
Type: Polynomial(Fraction(Integer))
fricas
Time: 0.01 (OT) = 0.01 sec

we cannot recover the characteristic polynomial from this solution: Even if a large number is passed to solve, accuracy does not increase.

Why would you expect to be able to recover the characteristic polynomial? There is always round off error for finite precision arithmetic. For integer approximations, it would be worse. The command solve: (Polynomial Fraction Integer, PositiveInteger)->List Equation Polynomial Integer solves the equation over the integers, so it is {\it not} accurate. For example:

fricas
solve(x+11/10,3)

\label{eq5}\left[{x = - 1}\right](5)
Type: List(Equation(Polynomial(Fraction(Integer))))
fricas
Time: 0.01 (IN) = 0.01 sec
ev:= solve(rhs(eigen.1),1.0*10^(-50))

\label{eq6}\begin{array}{@{}l}
\displaystyle
\left[{\%A = -{14233142.7839271088_23}}, \: \right.
\
\
\displaystyle
\left.{\%A = -{54892641.0998019923_75}}, \: \right.
\
\
\displaystyle
\left.{\%A = -{93438314.6687504400_27}}, \: \right.
\
\
\displaystyle
\left.{\%A = -{104131052.5421902803_1}}, \: \right.
\
\
\displaystyle
\left.{\%A = -{139552430.7909528369_9}}, \: \right.
\
\
\displaystyle
\left.{\%A ={590433871.2921979769_2}}, \: \right.
\
\
\displaystyle
\left.{\%A ={136341415.0492967303_4}}, \: \right.
\
\
\displaystyle
\left.{\%A ={118357957.8969694609_4}}, \: \right.
\
\
\displaystyle
\left.{\%A ={51852746.7256929047_26}}, \: \right.
\
\
\displaystyle
\left.{\%A ={23649448.9214655855_95}}\right] 
(6)
Type: List(Equation(Polynomial(Float)))
fricas
Time: 0.07 (EV) = 0.07 sec
cp:= reduce(*, [rhs(x)-lhs(x) for x in ev])

\label{eq7}\begin{array}{@{}l}
\displaystyle
{{\%A}^{10}}-{{514387858.0}\ {{\%A}^{9}}}-{{8106376_971775036
3.001}\ {{\%A}^{8}}}+ 
\
\
\displaystyle
{{0.1861748518_4436035761 E 26}\ {{\%A}^{7}}}+ 
\
\
\displaystyle
{{0.1995237067_3285194434 E 34}\ {{\%A}^{6}}}- 
\
\
\displaystyle
{{0.1964891163_2954602973 E 42}\ {{\%A}^{5}}}- 
\
\
\displaystyle
{{0.1771368430_4188911913 E 50}\ {{\%A}^{4}}}+ 
\
\
\displaystyle
{{0.5612260970_6355950813 E 57}\ {{\%A}^{3}}}+ 
\
\
\displaystyle
{{0.3998965515_0944646532 E 65}\ {{\%A}^{2}}}- 
\
\
\displaystyle
{{0.4573810729_7399937026 E 72}\  \%A}- 
\
\
\displaystyle
{0.1239501079_7604477661 E 80}
(7)
Type: Polynomial(Float)
fricas
Time: 0 sec

fricas
A:=[[a,b],[c,d]]

\label{eq8}\left[{\left[ a , \: b \right]}, \:{\left[ c , \: d \right]}\right](8)
Type: List(List(Symbol))
fricas
Time: 0.01 (OT) = 0.01 sec

fricas
A:=matrix[[cos(x),-sin(x)],[sin(x),cos(x)]]

\label{eq9}\left[ 
\begin{array}{cc}
{\cos \left({x}\right)}& -{\sin \left({x}\right)}
\
{\sin \left({x}\right)}&{\cos \left({x}\right)}
(9)
Type: Matrix(Expression(Integer))
fricas
Time: 0.01 (EV) + 0.03 (OT) = 0.04 sec
A(1,1)

\label{eq10}\cos \left({x}\right)(10)
Type: Expression(Integer)
fricas
Time: 0 sec
eigen:=eigenvalues(A)
There are 1 exposed and 0 unexposed library operations named eigenvalues having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op eigenvalues to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named eigenvalues with argument type(s) Matrix(Expression(Integer))
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

Unfortunately, currently eigenvalues does not work for general expressions, which causes the failure above.

fricas
A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]

\label{eq11}\left[ 
\begin{array}{cc}
{{\cos \left({x}\right)}- L}& -{\sin \left({x}\right)}
\
{\sin \left({x}\right)}&{{\cos \left({x}\right)}- L}
(11)
Type: Matrix(Expression(Integer))
fricas
Time: 0 sec
A(1,1)*A(2,2)

\label{eq12}{{\cos \left({x}\right)}^{2}}-{2 \  L \ {\cos \left({x}\right)}}+{{L}^{2}}(12)
Type: Expression(Integer)
fricas
Time: 0 sec
A(2,1)*A(1,2)

\label{eq13}-{{\sin \left({x}\right)}^{2}}(13)
Type: Expression(Integer)
fricas
Time: 0 sec
A(1,1)*A(2,2)-A(2,1)*A(1,2)

\label{eq14}{{\sin \left({x}\right)}^{2}}+{{\cos \left({x}\right)}^{2}}-{2 \  L \ {\cos \left({x}\right)}}+{{L}^{2}}(14)
Type: Expression(Integer)
fricas
Time: 0 sec
B := solve(A(1,1)*A(2,2)-A(2,1)*A(1,2)=0,L)

\label{eq15}\left[{L ={{{\sqrt{- 1}}\ {\sin \left({x}\right)}}+{\cos \left({x}\right)}}}, \:{L ={-{{\sqrt{- 1}}\ {\sin \left({x}\right)}}+{\cos \left({x}\right)}}}\right](15)
Type: List(Equation(Expression(Integer)))
fricas
Time: 0.01 (IN) + 0.01 (EV) + 0.01 (OT) = 0.03 sec
B(1)

\label{eq16}L ={{{\sqrt{- 1}}\ {\sin \left({x}\right)}}+{\cos \left({x}\right)}}(16)
Type: Equation(Expression(Integer))
fricas
Time: 0 sec

fricas
solve(x^2 - 2,x)

\label{eq17}\left[{{{{x}^{2}}- 2}= 0}\right](17)
Type: List(Equation(Fraction(Polynomial(Integer))))
fricas
Time: 0 sec
sqrt(2)

\label{eq18}\sqrt{2}(18)
Type: AlgebraicNumber?
fricas
Time: 0 sec
solve(x^2=4,x)

\label{eq19}\left[{x = 2}, \:{x = - 2}\right](19)
Type: List(Equation(Fraction(Polynomial(Integer))))
fricas
Time: 0 sec

fricas
P:=matrix[[a, b], [1.0 - a, 1.0 - b]]

\label{eq20}\left[ 
\begin{array}{cc}
a & b 
\
{-{{1.0}\  a}+{1.0}}&{-{{1.0}\  b}+{1.0}}
(20)
Type: Matrix(Polynomial(Float))
fricas
Time: 0.01 (IN) = 0.01 sec
eigenvectors(P)

\label{eq21}\begin{array}{@{}l}
\displaystyle
\left[{
\begin{array}{@{}l}
\displaystyle
\left[{eigval ={-{{1.0}\  b}+ a}}, \:{eigmult = 1}, \: \right.
\
\
\displaystyle
\left.{eigvec ={\left[{\left[ 
\begin{array}{c}
-{1.0}
\
{1.0}
(21)
Type: List(Record(eigval: Union(Fraction(Polynomial(Float)),SuchThat?(Symbol,Polynomial(Float))),eigmult: NonNegativeInteger?,eigvec: List(Matrix(Fraction(Polynomial(Float))))))
fricas
Time: 0 sec