[comp.windows.ms.programmer] Actor: bad numerical precision?

pcb@cacs.usl.edu (Peter C. Bahrs) (12/05/90)

Was: arghh!

I just wrote an inverse method for a matrix class using simple row
reduction.  
   a:=inverse(c);
   b:=a*c;

Most of the time b is  1. 0. 0.
                       0. 1. 0.
                       0. 0. 1.
for a 3x3 matrix.
But sometimes, using different values for c, b is
                       1. 3.343434343-e20 1.2323-316
                       0.  1. 0.
                       0.  0. 1.

???What gives, I am confident the algorithm is correct.  It works most
of the time.  But this is a terrible error factor here that will build
up in time.  Is Actor weak in numerical precison?

/*----------- Thanks in advance... --------------------------------------+
| Peter C. Bahrs                                                         |
| The USL-NASA Project                                                   |
| Center For Advanced Computer Studies      INET: pcb@swamp.cacs.usl.edu |
| 2 Rex Street                                                           |
| University of Southwestern Louisiana      ...!uunet!dalsqnt!gator!pcb  | 
| Lafayette, LA 70504                                                    |
+-----------------------------------------------------------------------*/

hughes@maelstrom.Berkeley.EDU (Eric Hughes) (12/05/90)

This question is really about numerical analysis, not Actor, and even
less Windows.

In article <20060@rouge.usl.edu> pcb@cacs.usl.edu (Peter C. Bahrs) writes:
>I just wrote an inverse method for a matrix class using simple row
>reduction.  
>
[gets non-zero values off-axis]

>???What gives, I am confident the algorithm is correct.  It works most
>of the time.  But this is a terrible error factor here that will build
>up in time.  Is Actor weak in numerical precison?

No more so than all computers are.  Simple row-reduction schemes do
not work well in all cases when the determinant of the matrix is very
close to zero.  The round-off errors become significant and large.

Ask this same question in sci.math.num-analysis.  It's a basic question.

Eric Hughes
hughes@ocf.berkeley.edu

gyugyi@earthsea.stanford.edu (Paul Gyugyi) (12/06/90)

In article <20060@rouge.usl.edu>, pcb@cacs.usl.edu (Peter C. Bahrs) writes:
|> Was: arghh!
|> 
|> I just wrote an inverse method for a matrix class using simple row
|> reduction.  
...
|>                        1. 3.343434343-e20 1.2323-316
...
|> ???What gives, I am confident the algorithm is correct.  It works most
|> of the time.  But this is a terrible error factor here that will build
|> up in time.  Is Actor weak in numerical precison?

First, check out _Numerical Recipes_ in C to make sure your algorithm
is _numerical analysis-wise correct_, not just logically correct.
You`re always going to have round off errors due to the finite precision
of floats.  So the round off errors are something you're going to be
stuck with unless you go to an infinite precision package (for example
the bc command under unix).  The above book is very good in presenting
numerically stable algorithms.

On the other hand, Actor doesn't support the math coprocessor, so the
handling of some of the more obscure IEEE error states (similar to
NaN and Inf) won't work for the same reasons the Microsoft math-emulator
library doesn't support them.  The added precision of using the math
coprocessor will still not keep you from your round off errors.

Be aware that there are many ways to take a matrix inverse, and row
reduction is subject to some of the most rounding errors.  Again,
_Numerical Recipies in C_ will have a sufficient discussion, but
it's one of the reasons the IMSL math libraries became such a
standard on large computers.

I guess what we really need is an IMSL Math Library DLL for windows.

--
Paul Gyugyi
gyugyi@earthsea.stanford.edu