From: Elaheh on
I have two matrices (a,b). if I show determinant of matrix with ‘det’,
I will have:
Det([transpose(a)][b]) = Det([transpose(b)][a])
I have written a code with Fortran90 to calculate above term, but
values of both sides of equation are different in some digits (scalar
information takes 8 byte). This inequality makes error. How can I get
same values?

Thanks in advance
From: Arjen Markus on
On 27 mei, 09:24, Elaheh <elaheh.ad...(a)gmail.com> wrote:
> I have two matrices (a,b). if I show determinant of matrix with ‘det’,
> I will have:
> Det([transpose(a)][b]) = Det([transpose(b)][a])
> I have written a code with Fortran90 to calculate above term, but
> values of both sides of equation are different in some digits (scalar
> information takes 8 byte). This inequality makes error. How can I get
> same values?
>
> Thanks in advance

You can't. Not in general, that is. This is fundamental to the finite
precision arithmetic we have to deal with. You can get close, but that
is not the same.

Here is a simple example:

Mathematically, (1.0e20 + 1.0) - 1.0e20 = (1.0e20 - 1.0e20) + 1.0 =
1.0
But due to the finite precision (take 10 digits for instance):

(1.0e20 + 1.0) - 1.0e20 = (approximately) 1.0e20 - 1.0e20 = 0.0
and
(1.0e20 - 1.0e20) + 1.0 = 0.0 + 1.0 = 1.0

Things get worse if you have many computations, like with
determinants.

Hope this clarifies the problem.

Regards,

Arjen

(1.0

From: mecej4 on
Elaheh wrote:

> I have two matrices (a,b). if I show determinant of matrix with 'det',
> I will have:
> Det([transpose(a)][b]) = Det([transpose(b)][a])
> I have written a code with Fortran90 to calculate above term, but
> values of both sides of equation are different in some digits (scalar
> information takes 8 byte). This inequality makes error. How can I get
> same values?
>
> Thanks in advance
On your electronic calculator, carry out the following calculation exactly
as shown, see what the result is, and try to explain why it came out that
way:

(4.0/3.0 - 1.0)*3.0 - 1.0

--mecej4

From: Gib Bogle on
mecej4 wrote:
> Elaheh wrote:

> On your electronic calculator, carry out the following calculation exactly
> as shown, see what the result is, and try to explain why it came out that
> way:
>
> (4.0/3.0 - 1.0)*3.0 - 1.0

My electronic calculator (Aurora SC190) gave the answer 0. I can't explain why
it came out this way.
From: JWM on
On Sun, 30 May 2010 22:29:38 -0600, Gib Bogle
<g.bogle(a)auckland.no.spam.ac.nz> wrote:

> mecej4 wrote:
>> Elaheh wrote:
>
>> On your electronic calculator, carry out the following calculation
>> exactly
>> as shown, see what the result is, and try to explain why it came out
>> that
>> way:
>> (4.0/3.0 - 1.0)*3.0 - 1.0
>
> My electronic calculator (Aurora SC190) gave the answer 0. I can't
> explain why it came out this way.

Maybe because it's set to display the answer in fixed-point format?