FAQ: Difference between revisions

Jump to navigation Jump to search
60 bytes added ,  8 May 2020
→‎Why is Octave's floating-point computation wrong?: Grammatical errors & spelling mistakes
(→‎Why is Octave's floating-point computation wrong?: Grammatical errors & spelling mistakes)
Line 124: Line 124:
Floating-point arithmetic is an approximation '''in binary''' to arithmetic on real or complex numbers.  Just like you cannot represent 1/3 exactly in decimal arithmetic (0.333333... is only a rough approximation to 1/3), you cannot represent some fractions like <math>1/10</math> exactly in base 2.  In binary, the representation to one tenth is <math>0.0\overline{0011}_b</math> where the bar indicates that it repeats infinitely (like how <math>1/6 = 0.1\overline{6}_d</math> in decimal).  Because this infinite repetition cannot be represented exactly with a finite number of digits, rounding errors occur for values that appear to be exact in decimal but are in fact approximations in binary, such as for example how 0.3 - 0.2 - 0.1 is not equal to zero.
Floating-point arithmetic is an approximation '''in binary''' to arithmetic on real or complex numbers.  Just like you cannot represent 1/3 exactly in decimal arithmetic (0.333333... is only a rough approximation to 1/3), you cannot represent some fractions like <math>1/10</math> exactly in base 2.  In binary, the representation to one tenth is <math>0.0\overline{0011}_b</math> where the bar indicates that it repeats infinitely (like how <math>1/6 = 0.1\overline{6}_d</math> in decimal).  Because this infinite repetition cannot be represented exactly with a finite number of digits, rounding errors occur for values that appear to be exact in decimal but are in fact approximations in binary, such as for example how 0.3 - 0.2 - 0.1 is not equal to zero.


In addition, some advanced operations are computed by approximation and are not guaranteed to be accurate, see [https://en.wikipedia.org/wiki/Rounding#Table-maker.27s_dilemma Table-maker's dilemma]. Their results are system-dependent.
In addition, some advanced operations are computed by approximation and there is no guarantee for them to be accurate, see [https://en.wikipedia.org/wiki/Rounding#Table-maker.27s_dilemma Table-maker's dilemma] for further references . Their results are system-dependent.


This isn't an Octave bug.  It happens with any program that uses [https://en.wikipedia.org/wiki/IEEE_754 IEEE 754 floating-point arithmetic].  To be fair, IEEE 754 also specifies decimal floating-point arithmetic, which has never seen wide adoption.  The reason why Octave and other programs using IEEE 754 binary floating-point numbers is that they are ''fast'', because they are implemented in hardware or system libraries.  Unless you are using very exotic hardware, Octave will use your computer's processor for basic floating-point arithmetic.
This isn't a bug that is limited to GNU-Octave & it happens with any program that uses [https://en.wikipedia.org/wiki/IEEE_754 IEEE 754 floating-point arithmetic].  To be fair, IEEE 754 also specifies decimal floating-point arithmetic, which has never seen wide adoption.  The reason why Octave and other programs using IEEE 754 binary floating-point numbers is that they are ''fast'', because they are implemented in hardware or system libraries.  Unless you are using very exotic hardware, Octave will use your computer's processor for basic floating-point arithmetic.


Another approach to deal with rounding errors is interval arithmetic with the [[Interval package]] or symbolic computatons with the [[Symbolic package]].  These approaches are likely to be slower, since not all operations can be performed on Hardware like pure floatin-point arithmetic.
Another approach to deal with rounding errors is interval arithmetic with the [[Interval package]] or symbolic computations with the [[Symbolic package]].  These approaches are likely to be slower, since not all operations can be performed on Hardware like pure floating-point arithmetic.


To learn more about floating-point arithmetic, consult the [https://en.wikipedia.org/wiki/Floating-point_arithmetic Wikipedia article] or the classical reference by David Goldberg [http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html What Every Computer Scientist Should Know About Floating-Point Arithmetic].
To learn more about floating-point arithmetic, consult this [https://en.wikipedia.org/wiki/Floating-point_arithmetic Wikipedia article] or the classical reference by David Goldberg [http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html What Every Computer Scientist Should Know About Floating-Point Arithmetic].


==Missing lines when printing under Windows with OpenGL toolkit and Intel integrated GPU==
==Missing lines when printing under Windows with OpenGL toolkit and Intel integrated GPU==

Navigation menu