The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » sci.math.* » sci.math.symbolic

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: interesting case where CAS computation makes a large numerical difference
Replies: 4   Last Post: Jun 9, 2012 10:16 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Nasser Abbasi

Posts: 6,677
Registered: 2/7/05
interesting case where CAS computation makes a large numerical difference
Posted: Jun 7, 2012 8:09 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Interesting article on Cleve's corner today:

On floating points issue and his analysis why it happened.

But wanted to show here that doing the same thing using a CAS
removed the problem (as would be expected, nothing surprising,
since using pure integers). Ofcourse one can argue about speed
and performance in real large numerical problems and all of this.

But I just thought some here might like to see it.

It is finding the Determinant of 2 by 2 matrix of integers.
The correct answer is 1.

I tried the example shown on some software I have, here is
the result. I run in on matlab 2112a,matlab 2112a/symbolic,octave,

---- matlab 2112a --------------
EDU>> X = [ 63245986, 102334155
102334155, 165580141];

EDU>> det(X)


---- matlab 2112a/Symbolic -------------
EDU>> syms X
EDU>> X=sym([ 63245986, 102334155;102334155, 165580141])

[ 63245986, 102334155]
[ 102334155, 165580141]

EDU>> det(X)


----- GNU Octave, version 3.2.4 on Linux -------
octave:3> X
X =
63245986 102334155
102334155 165580141

octave:4> det(X)
ans = 0.99950

---- Mathematica 8.04------
a=63245986; b=102334155; c=102334155;d=165580141;
mat={{a,b},{ c,d}};

Out[25]= 1

--------Maple 14-----------

[ 63245986 102334155]
M := [ ]
[102334155 165580141]


But before we go celebrate, justed wanted to point that even the
CAS programs do not generate 1 when the numbers are made to be
floating points. Interesting also to see now the results:

---- Mathematica 8.04------

Out[22]= 1.5249

--------Maple 14-----------

> with(LinearAlgebra):
> M:=Matrix([[63245986.0,102334155.0],[102334155.0,165580141.0]]);

[ 8 9]
[0.632459860 10 0.1023341550 10 ]
M := [ ]
[ 9 9]
[0.1023341550 10 0.1655801410 10 ]

> Determinant(M);


Mathematica result now agrees with Matlab's. I am not sure
why Maple gives zero. May be I need to use an option somewhere
for the Matrix construtor. Not a Maple expert.

I guess it is true then that God made the integers and the
rest is the work of man :)


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.