Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: significant digits

Subject: significant digits

From: sunil vaidya

Date: 07 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: Re: significant digits

From: Rick Rosson

Date: 07 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: Re: significant digits

From: Rick Rosson

Date: 07 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: Re: significant digits

From: John D'Errico

Date: 07 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: Re: significant digits

From: Randy Poe

Date: 07 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

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
significant digits Rick Rosson 10 Jun, 2008 21:24:57
eps Rick Rosson 10 Jun, 2008 21:24:57
significant figures Rick Rosson 10 Jun, 2008 21:24:57
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics