On 07/21/2017 02:39 AM, Giovanni Di Ilio wrote:
> 
> So, let's just consider the coordinate y1. If we approximate the value to 
> 0.49999999999882*2* the mapping will be ok. However, if we try one of the 
> following, as example:
> 
> y1 = 0.49999999999882*1*
> y1 = 0.49999999999882*21
> 
> *interesting enough, the mapping will fail again.
> Another test: I add say two random digits to each vertex coordinate:
> 
> x1 = 5.399999999999241*21* , y1 = 0.4999999999988218*21*
> x2 = 5.499999999999598*21* , y2 = 0.499999999998822*21*
> x4 = 5.399999999999546*21* , y4 = 0.59999999999853*21*
> x5 = 5.499999999999902*21* , y5 = 0.59999999999853*21*
> 
> Now it works again...this is mind-blowing.
No, this is round-off error in action :-) Floating point numbers have only 
approximately 16 digits of accuracy. The differences between the numbers you 
have are at approximately at the level of round-off, and any computation you 
do with these numbers will add to the effect of round-off.
If you have numbers where you depend on differences at the level of round-off, 
arithmetic works very differently than for regular real numbers. They behave 
more like integers because every operation involves rounding to the next 
representable floating point number, and this rounding operation changes the 
number significantly (relative to the differences between numbers you are 
considering).
There is nothing you can do about this other than not rely on differences that 
are this small relative to the absolute size of the numbers. One way you can 
avoid this is if you have a small domain somewhere in R^2, move it to the 
origin so that the relative distance between points is no longer small 
compared to the distance from the origin.