Path: news.mathworks.com!not-for-mail
From: "Steven_Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: round-off error
Date: Wed, 20 Apr 2011 09:20:22 -0400
Organization: MathWorks
Lines: 33
Message-ID: <iommi1$k50$1@fred.mathworks.com>
References: <iomh7h$j76$1@fred.mathworks.com>
NNTP-Posting-Host: ah-slord.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain;
	format=flowed;
	charset="utf-8";
	reply-type=response
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1303305601 20640 172.31.44.225 (20 Apr 2011 13:20:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 20 Apr 2011 13:20:01 +0000 (UTC)
In-Reply-To: <iomh7h$j76$1@fred.mathworks.com>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: news.mathworks.com comp.soft-sys.matlab:722916



"Grzegorz Knor" <gknor@o2.pl> wrote in message 
news:iomh7h$j76$1@fred.mathworks.com...
> Hi!
>
> Is there a way to avoid this type of errors in matlab:
>
> p = poly([1 1 1 1 1 1 1])
> p =
>     1    -7    21   -35    35   -21     7    -1
> r = roots(p)
> r =
>   1.0090         1.0056 + 0.0070i
>   1.0056 - 0.0070i
>   0.9980 + 0.0088i
>   0.9980 - 0.0088i
>   0.9919 + 0.0039i
>   0.9919 - 0.0039i

Not without using an arbitrary precision package like Symbolic Math Toolbox.

Welcome to the world of numerical analysis.

You might want to read the first question in the Mathematics section of the 
FAQ for more information about floating-point arithmetic.

-- 
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on 
http://www.mathworks.com