Matlab sin(pi) and its relation to machine epsilon

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


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 2k ≤ x < 2k+1, the gap between x and the next largest floating point number is 2k × eps (ie 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

ie 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 eps 2, so can be ignored in this case.


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.

链接地址: http://www.djcxy.com/p/37930.html

上一篇: 如何从ffmpeg管道直播视频帧到PIL?

下一篇: Matlab sin(pi)及其与机器epsilon的关系