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
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:
"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
"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
>
>
"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.
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.
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.