Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!jato!csi!sam
From: sam@csi.jpl.nasa.gov (Sam Sirlin)
Subject: Re: Matrix Inverse in APL2
Message-ID: <1993Jan15.183816.29350@csi.jpl.nasa.gov>
Originator: sam@kalessin
Sender: usenet@csi.jpl.nasa.gov (Network Noise Transfer Service)
Nntp-Posting-Host: kalessin
Organization: Jet Propulsion Laboratory, Pasadena, CA
References: <C0puI4.Mv6@undergrad.math.waterloo.edu> <726871483snz@apl.demon.co.uk> <1476@kepler1.rentec.com>
Date: Fri, 15 Jan 1993 18:38:16 GMT
Lines: 58


In article <1476@kepler1.rentec.com>, andrew@rentec.com (Andrew Mullhaupt) writes:

|> double precision arithmetic, (which is not too shabby at all). Then we
|> ask for the inverse (or even just the QR decomposition) of the 10x10
|> Hilbert matrix, i.e. the matrix a with entries
|> 
|> 		a[i,j] = 1/(i+j-1)
|> 
|> which in (quadIO = 1) APL can be given by
|> 
|>  h10 gets divide negative 1 + t jot dot + t gets iota 10
|> 
|> or something much like it.

Good idea to bring up this nice matrix. In J it can be built by:
   hilbert=. %@(_1&+@([ +/ [))@(1&+@(i.@[))
...
|> This is an example you can try on your interpreter's quad-divide to see
|> how far it can get without puking. I seem to remember that APL2/PC can
|> get to 11 but not 12, i.e. quad divide of the 12x12 Hilbert matrix
|> returns a DOMAIN ERROR.

Trying this in J6/sun sparc, using

   test=. ('x. +/ . * %. x. ' : 11) @ hilbert

(the result should be the identity matrix) I haven't seen a domain
error yet. Though of course you get more and more garbage for higher
orders. For example this looks pretty useless:

   a=. test 200
   4{. 4{."1 a
6.44446   2.9165  4.28394 _0.629028
2.44617  5.94781  _1.7135  _0.13623
3.04517 _2.39673  12.8352  _2.49487
0.20813 0.533752 _1.31238   9.49023

For 9th order the errors in the result are about 10^_3. So you need to
be careful using matrix inverse in J since it may not give you warning
about bad conditioning. While an acceptable condition number is a
matter of choice, it's too bad the interpreter doesn't return a boxed
result (structure) including a condition number estimate as well as
it's answer, as such estimates are available in good low-level code.
Interestingly at some point the interpreter does decide there is no
good answer and fills the result with "indeterminate":

   %. 0
_.
   %. 2 2$1 0 0 0
_. _.
_. _.

But I didn't see this even for hilbert 400.
-- 
Sam Sirlin
Jet Propulsion Laboratory         sam@kalessin.jpl.nasa.gov

