Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
significant digits

Subject: significant digits

From: sunil vaidya

Date: 7 Aug, 2007 13:06:23

Message: 1 of 5

i'm running a prog in matlab which uses two matrix
inversions and one roots function. i have some inconsistency
in my results. does matlab truncate numbers beyond 16
significant digits? and if it does, is they any way around
this problem----can the accuracy be increased or something?
TIA

Subject: significant digits

From: Rick Rosson

Date: 7 Aug, 2007 13:14:45

Message: 2 of 5


Hi Sunil,

It's not so much that there is a fixed number of significant figures, but
rather that MATLAB (and almost all other computer languages) uses floating
point representations based on the IEEE standards.

The absolute precision of a floating point variable depends on the absolute
magnitude of the variable's current value. For example:

    x = 1.5;
    y = 1.5e-9;
    e = eps(x);
    f = eps(y);

Notice that 'e' and 'f' are about 9 orders of magnitude apart.

On the other hand, the relative precision is approximately constant:

    a = e/x;
    b = f/x;

Notice that 'a' and 'b' are approximately equal.


For more information, type

   doc eps

at the MATLAB command prompt. Also, take a look at Technical Note 1108:

   http://www.mathworks.com/support/tech-notes/1100/1108.html


I hope that helps. Thanks.

Rick



"sunil vaidya" <sunil.vaidya@gmail.com> wrote in message
news:f99qoe$h6e$1@fred.mathworks.com...
> i'm running a prog in matlab which uses two matrix
> inversions and one roots function. i have some inconsistency
> in my results. does matlab truncate numbers beyond 16
> significant digits? and if it does, is they any way around
> this problem----can the accuracy be increased or something?
> TIA

Subject: significant digits

From: Rick Rosson

Date: 7 Aug, 2007 13:16:46

Message: 3 of 5

Typo: it should say...

    b = f/y;

        instead of

    b = f/x;


Sorry.





"Rick Rosson" <rrosson@mathworks.com> wrote in message
news:f99r87$rff$1@fred.mathworks.com...
>
> Hi Sunil,
>
> It's not so much that there is a fixed number of significant figures, but
> rather that MATLAB (and almost all other computer languages) uses floating
> point representations based on the IEEE standards.
>
> The absolute precision of a floating point variable depends on the
> absolute magnitude of the variable's current value. For example:
>
> x = 1.5;
> y = 1.5e-9;
> e = eps(x);
> f = eps(y);
>
> Notice that 'e' and 'f' are about 9 orders of magnitude apart.
>
> On the other hand, the relative precision is approximately constant:
>
> a = e/x;
> b = f/x;
>
> Notice that 'a' and 'b' are approximately equal.
>
>
> For more information, type
>
> doc eps
>
> at the MATLAB command prompt. Also, take a look at Technical Note 1108:
>
> http://www.mathworks.com/support/tech-notes/1100/1108.html
>
>
> I hope that helps. Thanks.
>
> Rick
>
>
>
> "sunil vaidya" <sunil.vaidya@gmail.com> wrote in message
> news:f99qoe$h6e$1@fred.mathworks.com...
>> i'm running a prog in matlab which uses two matrix
>> inversions and one roots function. i have some inconsistency
>> in my results. does matlab truncate numbers beyond 16
>> significant digits? and if it does, is they any way around
>> this problem----can the accuracy be increased or something?
>> TIA
>
>

Subject: significant digits

From: John D'Errico

Date: 7 Aug, 2007 13:34:20

Message: 4 of 5

"sunil vaidya" <sunil.vaidya@gmail.com> wrote in message
<f99qoe$h6e$1@fred.mathworks.com>...
> i'm running a prog in matlab which uses two matrix
> inversions and one roots function. i have some inconsistency
> in my results. does matlab truncate numbers beyond 16
> significant digits? and if it does, is they any way around
> this problem----can the accuracy be increased or something?
> TIA

I'll just add a few extra comments to what
Rick has ably explained. Very often we see
people looking for additional precision in a
numerical computation. They think, if only
I could just throw more digits at this, I could
solve my problem simply, without actually
investing any thought in it.

The flaw is, that logic never ends. We would
see people trying to use 100 digits of
precision to solve a problem where their
data only has 2 significant digits. (Yes, it
is easy enough to formulate a nasty
problem.) Garbage in, garbage out.

You will benefit far more from some study
of your problem, learning how to compute
efficiently and accurately what you need to
do in a reasonable amount of precision, than
you will from just throwing a few extra digits
at it.

HTH,
John

Subject: significant digits

From: Randy Poe

Date: 7 Aug, 2007 13:45:07

Message: 5 of 5

On Aug 7, 9:06 am, "sunil vaidya" <sunil.vai...@gmail.com> wrote:
> i'm running a prog in matlab which uses two matrix
> inversions and one roots function. i have some inconsistency
> in my results. does matlab truncate numbers beyond 16
> significant digits? and if it does, is they any way around
> this problem----can the accuracy be increased or something?
> TIA

You could use the VPA tools to do your calculation
symbolically, in variable-precision arithmetic, but you will find
that slows down your calculation enormously.

Better, as people have said, to learn to deal with round-off error,
to use imprecision in your floating-point comparisons, to
expect "real" values to possibly have imaginary components
on the order of 10^-16, etc. This is part of numerical
computation, the price we pay for the computation power.

                    - Randy

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us