7

I understand that the reason why sin(pi) is not equal to zero is because of the fact that there is not enough bits to store all the significant digits of "pi", but what does that have to do with machine epsilon?

I read online what machine epsilon was, but after an hour of reading various definitions worded differently I got confused and did not understand the concept of epsilon. I ended up getting really frustrated in my own foolishness...

This following example was given in the MATLAB documentation and I don't understand it, can someone explain to me what the example is trying to show?

Find the distance from 10.0 to the next largest double-precision number.

d = eps(10.0)

d =

   1.7764e-15

http://www.mathworks.com/help/matlab/ref/eps.html

dasdingonesin
  • 1,347
  • 1
  • 10
  • 16
Belphegor
  • 1,683
  • 4
  • 23
  • 44
  • 2
    don't be frustrated. you are **not** foolish. this is not an easy subject to grasp. – Shai Jan 11 '17 at 07:40
  • 1
    I'm not sure how that question can be considered a duplicate. – Simon Byrne Jan 11 '17 at 09:10
  • @Shai I agree with Simon. OP explicitly asks for an explanation of the machine epsilon, specifically the `eps` function, which is not the topic of the other question. – dasdingonesin Jan 11 '17 at 09:57
  • Maybe this explanation of the machine epsilon is helpful: http://stackoverflow.com/a/27511886/3871918 – dasdingonesin Jan 11 '17 at 09:58
  • Ask yourself something: What's the next number after 1.0? Is it 1.00001? 1.000000001? 1.000000000000001? As you see you cannot have ALL numbers represented, so the step between one number and the next one is `eps` (which as you can see is a pretty small number (1.7764e-15) –  Jan 11 '17 at 14:47

2 Answers2

1

At first order, sin(pi-epsilon)=epsilon+O(epsilon^3)

So, if we have an approximated value of pi instead of pi (with an error up to 1/2 unit of least precision), then we expect this error to be transferred directly to the sine result.

Machine epsilon is definitely related to the error we make with approximated value of pi.

aka.nice
  • 9,100
  • 1
  • 28
  • 40
1

There are a couple of different definitions of machine epsilon, but Matlab eps is fairly typical, being the gap between 1.0 and the next largest double precision floating point number.

We can actually make this more general: for any floating point number between 2kx < 2k+1, the gap between x and the next largest floating point number is 2k × eps (i.e. eps(x) in Matlab). Moreover, the gap between any real number and its nearest floating point approximation is half this.

Since 2 ≤ π < 4;, this means that the gap between pi (the numerical approximation) and π (the exact irrational number) is bounded by eps. In actual fact, it is just over half that:

eps &approx; 2.22 × 10-16

|pi - π| &approx; 1.22 × 10-16

Now using the result from @aka.nice answer, and that sin(π) = 0, we have that

sin(pi) = | sin(pi) - sin(π) | &approx; |pi - π| < eps

i.e. it is also bounded by eps.

Note: there is also some slight rounding between sin(pi) (the numeric result) and sin(pi) (the exact result), but this is of order eps2, so can be ignored in this case.

Simon Byrne
  • 7,694
  • 1
  • 26
  • 50