Thread Subject:
Problem with machine precision

Subject: Problem with machine precision

From: Hermano Cappa

Date: 10 Aug, 2011 09:23:13

Message: 1 of 2

Hello,

I have a problem with the machine presion namely if I calculate 1+cosd(120) +cosd(240) than the result in Matlab is 5.5511e-017 instead of zero. This gives me a lot of problems later in my program. Why is this not equal to zero?

Thanks

Steven

Subject: Problem with machine precision

From: Walid Maghroum

Date: 10 Aug, 2011 10:24:10

Message: 2 of 2

Well Hermano, this is due to the representation of floating points in the computer. To learn more about this you can read this link:
http://www.mathworks.com/support/solutions/en/data/1-16FOQ/

actually you should program your code differently in state of using
if (a-b = 0)
you can use for example
if(a-b<eps)
or so

hope it helps
Walid

"Hermano Cappa" wrote in message <j1tim1$njb$1@newscl01ah.mathworks.com>...
> Hello,
>
> I have a problem with the machine presion namely if I calculate 1+cosd(120) +cosd(240) than the result in Matlab is 5.5511e-017 instead of zero. This gives me a lot of problems later in my program. Why is this not equal to zero?
>
> Thanks
>
> Steven

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
machine precision Hermano Cappa 10 Aug, 2011 05:24:13
cosd Hermano Cappa 10 Aug, 2011 05:24:13
rssFeed for this Thread

Contact us