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

Edit detail for numerical linear algebra revision 1 of 5

1 2 3 4 5
Editor: 127.0.0.1
Time: 2007/11/15 20:17:51 GMT-8
Note: transferred from axiom-developer

changed:
-
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:

\begin{axiom}
m := matrix([[random()$Integer for i in 1..10] for j in 1..10]); sm := m + transpose(m); smf:Matrix Float := sm
\end{axiom}

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):
\begin{axiom}
)set messages time on
-- eigenvalues(smf)
\end{axiom}

Try this::
\begin{axiom}
eigen:=eigenvalues(sm)
solve(rhs(eigen.1),15)
\end{axiom}

Thank you!  This helps, but doesn't answer everything.  Since interestingly:
\begin{axiom}
charpol := reduce(*, [ rhs(x) - lhs(x) for x in % ])
\end{axiom}
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 {\tt solve: (Polynomial Fraction Integer, PositiveInteger)->List Equation Polynomial Integer}
solves the equation over the integers, so it is {\it not} accurate. For example:

\begin{axiom}
solve(x+11/10,3)
ev:= solve(rhs(eigen.1),1.0*10^(-50))
cp:= reduce(*, [rhs(x)-lhs(x) for x in ev])
\end{axiom}

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}
  

From unknown Fri Jun 24 04:48:11 -0500 2005
From: unknown
Date: Fri, 24 Jun 2005 04:48:11 -0500
Subject: test
Message-ID: <20050624044811-0500@page.axiom-developer.org>

\begin{axiom}
A:=[[a,b],[c,d]]
\end{axiom}

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}

From unknown Fri Jun 24 04:55:05 -0500 2005
From: unknown
Date: Fri, 24 Jun 2005 04:55:05 -0500
Subject: test
Message-ID: <20050624045505-0500@page.axiom-developer.org>

\begin{axiom}
A:=matrix[[cos(x),-sin(x)],[sin(x),cos(x)]]
eigen:=eigenvalues(A)
\end{axiom}

From unknown Fri Jun 24 07:57:44 -0500 2005
From: unknown
Date: Fri, 24 Jun 2005 07:57:44 -0500
Subject: test
Message-ID: <20050624075744-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: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>

\begin{axiom}
A:=matrix[[cos(x),-sin(x)],[sin(x),cos(x)]]
A(1,1)
\end{axiom}

From unknown Fri Jun 24 08:05:16 -0500 2005
From: unknown
Date: Fri, 24 Jun 2005 08:05:16 -0500
Subject: test
Message-ID: <20050624080516-0500@page.axiom-developer.org>

\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>

\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: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}

From unknown Fri Jun 24 08:16:56 -0500 2005
From: unknown
Date: Fri, 24 Jun 2005 08:16:56 -0500
Subject: test
Message-ID: <20050624081656-0500@page.axiom-developer.org>

\begin{axiom}
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}
sqrt(2)
\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}
solve(x^2=4,x)
\end{axiom}

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}

From unknown Fri Oct 7 16:14:35 -0500 2005
From: unknown
Date: Fri, 07 Oct 2005 16:14:35 -0500
Subject: 
Message-ID: <20051007161435-0500@www.axiom-developer.org>

\begin{axiom}
P:=matrix[[a, b], [1.0 - a, 1.0 - b]]
eigenvectors(P)

\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:

axiom
m := matrix([[random()$Integer for i in 1..10] for j in 1..10]); sm := m + transpose(m); smf:Matrix Float := sm
LatexWiki Image(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):

axiom
)set messages time on

Try this::

axiom
eigen:=eigenvalues(sm)
LatexWiki Image(2)
Type: List Union(Fraction Polynomial Integer,SuchThat?(Symbol,Polynomial Integer))
axiom
Time: 0.55 (EV) + 0.15 (OT) + 0.30 (GC) = 1.00 sec solve(rhs(eigen.1),15)
LatexWiki Image(3)
Type: List Equation Polynomial Fraction Integer
axiom
Time: 0.02 (IN) + 0.48 (EV) + 0.02 (OT) + 0.35 (GC) = 0.87 sec

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

axiom
charpol := reduce(*, [ rhs(x) - lhs(x) for x in % ])
LatexWiki Image(4)
Type: Polynomial Fraction Integer
axiom
Time: 0 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:

axiom
solve(x+11/10,3)
LatexWiki Image(5)
Type: List Equation Polynomial Fraction Integer
axiom
Time: 0.02 (IN) + 0.01 (EV) + 0.01 (OT) = 0.04 sec ev:= solve(rhs(eigen.1),1.0*10^(-50))
LatexWiki Image(6)
Type: List Equation Polynomial Float
axiom
Time: 0.01 (IN) + 0.49 (EV) + 0.07 (OT) + 0.28 (GC) = 0.85 sec cp:= reduce(*, [rhs(x)-lhs(x) for x in ev])
LatexWiki Image(7)
Type: Polynomial Float
axiom
Time: 0 sec

axiom
A:=[[cos(x),-sin(x)],[sin(x),cos(x)]]
LatexWiki Image(8)
Type: List List Expression Integer
axiom
Time: 0.02 (IN) + 0.02 (EV) + 0.08 (OT) = 0.12 sec

axiom
A:=[[a,b],[c,d]]
LatexWiki Image(9)
Type: List List Symbol
axiom
Time: 0.01 (OT) = 0.01 sec

axiom
A:=matrix[[cos(x),-sin(x)],[sin(x),cos(x)]]
LatexWiki Image(10)
Type: Matrix Expression Integer
axiom
Time: 0.01 (EV) = 0.01 sec

axiom
A:=matrix[[cos(x),-sin(x)],[sin(x),cos(x)]]
LatexWiki Image(11)
Type: Matrix Expression Integer
axiom
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.

axiom
A:=matrix[[cos(x),-sin(x)],[sin(x),cos(x)]]
LatexWiki Image(12)
Type: Matrix Expression Integer
axiom
Time: 0 sec \end{axiom Line 2: \end{axiom ....AB Error A: Missing mate. Error B: syntax error at top level Error B: Possibly missing a } 3 error(s) parsing <div class="commentsheading"><a name="msg20050624075917-0500@page.axiom-developer.org"></a><b>test</b> --unknown, <a href="http://axiom-wiki.newsynthesis.org/NumericalLinearAlgebra#msg20050624075917-0500@page.axiom-developer.org">Fri, 24 Jun 2005 07:59:17 -0500</a> <a href="http://axiom-wiki.newsynthesis.org/NumericalLinearAlgebra?subject=test&in_reply_to=%3C20050624075917-0500%40page.axiom-developer.org%3E#bottom">reply</a></div>\begin{axiom} There are no library operations named < having 1 argument(s) though there are 4 exposed operation(s) and 1 unexposed operation(s) having a different number of arguments. Use HyperDoc Browse, or issue )what op < to learn what operations contain " < " in their names, or issue )display op < to learn more about the available operations. Cannot find a definition or applicable library operation named < with argument type(s) Variable b Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. A:=matrix[[cos(x),-sin(x)],[sin(x),cos(x)]]
LatexWiki Image(13)
Type: Matrix Expression Integer
axiom
Time: 0.01 (IN) = 0.01 sec

axiom
A:=matrix[[cos(x),-sin(x)],[sin(x),cos(x)]]
LatexWiki Image(14)
Type: Matrix Expression Integer
axiom
Time: 0.01 (OT) = 0.01 sec A(1,1)
LatexWiki Image(15)
Type: Expression Integer
axiom
Time: 0 sec

axiom
A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]
LatexWiki Image(16)
Type: Matrix Expression Integer
axiom
Time: 0.01 (IN) = 0.01 sec A(1,1)*A(2,2)-A(2,1)*A(1,2)
LatexWiki Image(17)
Type: Expression Integer
axiom
Time: 0 sec

axiom
A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]
LatexWiki Image(18)
Type: Matrix Expression Integer
axiom
Time: 0 sec A(1,1)*A(2,2)
LatexWiki Image(19)
Type: Expression Integer
axiom
Time: 0 sec A(2,1)*A(1,2)
LatexWiki Image(20)
Type: Expression Integer
axiom
Time: 0 sec

axiom
A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]
LatexWiki Image(21)
Type: Matrix Expression Integer
axiom
Time: 0.01 (OT) = 0.01 sec solve(A(1,1)*A(2,2)-A(2,1)*A(1,2)=0,L)
LatexWiki Image(22)
Type: List Equation Expression Integer
axiom
Time: 0.02 (IN) + 0.10 (EV) + 0.03 (OT) + 0.07 (GC) = 0.22 sec

axiom
A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]
LatexWiki Image(23)
Type: Matrix Expression Integer
axiom
Time: 0 sec solve(A(1,1)*A(2,2)-A(2,1)*A(1,2)=0,L)
LatexWiki Image(24)
Type: List Equation Expression Integer
axiom
Time: 0.01 (IN) = 0.01 sec L
LatexWiki Image(25)
Type: Variable L
axiom
Time: 0 sec

axiom
A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]
LatexWiki Image(26)
Type: Matrix Expression Integer
axiom
Time: 0.01 (OT) = 0.01 sec B=solve(A(1,1)*A(2,2)-A(2,1)*A(1,2)=0,L) There are 3 exposed and 0 unexposed library operations named equation having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op equation 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 equation with argument type(s) Variable B List Equation Expression Integer Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

axiom
A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]
LatexWiki Image(27)
Type: Matrix Expression Integer
axiom
Time: 0.01 (OT) = 0.01 sec solve(A(1,1)*A(2,2)-A(2,1)*A(1,2)=0,L)
LatexWiki Image(28)
Type: List Equation Expression Integer
axiom
Time: 0 sec L(1) There are no library operations named L Use HyperDoc Browse or issue )what op L to learn if there is any operation containing " L " in its name. Cannot find a definition or applicable library operation named L with argument type(s) PositiveInteger Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

axiom
A:=matrix[[cos(x)-L,-sin(x)],[sin(x),cos(x)-L]]
LatexWiki Image(29)
Type: Matrix Expression Integer
axiom
Time: 0 sec solve(A(1,1)*A(2,2)-A(2,1)*A(1,2)=0,L)
LatexWiki Image(30)
Type: List Equation Expression Integer
axiom
Time: 0.01 (OT) = 0.01 sec L.1 There are no library operations named L Use HyperDoc Browse or issue )what op L to learn if there is any operation containing " L " in its name. Cannot find a definition or applicable library operation named L with argument type(s) PositiveInteger Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

axiom
solve(x^2,x)
LatexWiki Image(31)
Type: List Equation Fraction Polynomial Integer
axiom
Time: 0.01 (IN) = 0.01 sec

axiom
sqrt(2)
LatexWiki Image(32)
Type: AlgebraicNumber?
axiom
Time: 0 sec

axiom
solve(x^2=4,x)
LatexWiki Image(33)
Type: List Equation Fraction Polynomial Integer
axiom
Time: 0.02 (IN) + 0.01 (OT) = 0.03 sec

axiom
solve(x^2=4,x)
LatexWiki Image(34)
Type: List Equation Fraction Polynomial Integer
axiom
Time: 0 sec x
LatexWiki Image(35)
Type: Variable x
axiom
Time: 0 sec

axiom
e=vector[1,2] There are 3 exposed and 0 unexposed library operations named equation having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op equation 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 equation with argument type(s) Variable e Vector PositiveInteger Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. e=solve(x^2=4,x) There are 3 exposed and 0 unexposed library operations named equation having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op equation 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 equation with argument type(s) Variable e List Equation Fraction Polynomial Integer Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

axiom
e=solve(x^2=4,x) There are 3 exposed and 0 unexposed library operations named equation having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op equation 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 equation with argument type(s) Variable e List Equation Fraction Polynomial Integer Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

axiom
P:=matrix[[a, b], [1.0 - a, 1.0 - b]]
LatexWiki Image(36)
Type: Matrix Polynomial Float
axiom
Time: 0.01 (IN) = 0.01 sec eigenvectors(P)
LatexWiki Image(37)
Type: List Record(eigval: Union(Fraction Polynomial Float,SuchThat?(Symbol,Polynomial Float)),eigmult: NonNegativeInteger?,eigvec: List Matrix Fraction Polynomial Float)
axiom
Time: 0.01 (EV) + 0.01 (OT) = 0.02 sec