If you at all times whether exact numerical results, this is intrinsically impossible to achieve using computers or not. For example, what is the "exact" result of the square root of 2 ? The result is an irrational number, so it has no numerical representation exact. There are many other numbers like this, an infinite number actually. : ) (There are even rational numbers of infinite size, which are the periodic tithes.)
Specifically for computers, even for rational numbers it is not always possible to obtain an "exact" numerical representation. Just think of a big number, for example 1234567890[5 repetitions]. Cannot represent this number accurately in a variable double
of the language C, simply because it does not fit in a variable double
...
To my knowledge, there are (at least) three ways to partially circumvent the mathematical limitations of current computers and languages.
The first way is to use a mathematical library of "infinite precision". These libraries are widely used today because they are required for computational cryptography (mainly public key cryptography, used in "secure connections" on such websites https://
). Obviously these libraries continue to have limitations in numerical representation of irrational numbers, but use a method for storing numbers that makes it possible to calculate with "large" numbers, such as 1234567890[5 repetitions] which I quoted above, or as 1024 or 2048 bit keys widely used in public key cryptography.
The second way is to work with fractional number library. In this way, it is possible to work naturally with periodic tithes and with certain types of irrational numbers.
The other way is to work with symbolic mathematics, where symbols are used for known irrational numbers, like e, pi, etc. Usually you use some specific application for this, like "Wolfram Mathematica" (and similar open source programs), or specific languages, as (if I’m not mistaken) R, Julia, etc. Surely there are also libraries for symbolic mathematics for bindings like C, Python, etc., it’s just a matter of searching.
-1. #QNAN0 error is Negative Quiet Not a Number
– Tony