every number in computer is rational?

Started by
10 comments, last by alvaro 10 years, 8 months ago

You may answer right away with, yes, rounding to limited amount of digits means a rational number. My question is rather, wheather a number defined as a pair of two integrated numbers, would be sufficient datatype for real numbers computations. As I believe there is no sets of operations in a computer that would provide a real number without first deviding some numbers, or, defining a constant. If this is true, wouldnt this be a data type faster to operate on than IEEE floatings? I believe that even sqrt(2) is doing operations that would relate in this datatype. Put simply, +,-,*,/ operations cannot provide irrational number.

Advertisement

My question is rather, wheather a number defined as a pair of two integrated numbers, would be sufficient datatype for real numbers computations.

If you mean a pair of numbers that are taken as a quotient such as the pair {p, q} used to implicitly represent the value (p / q)...this is still considered a rational number. There are indeed math libraries that use such a representation. An irrational number is one that requires an infinite amount of precision to store exactly. As far as I know it is not possible to build a computing device that is not limited to rational numbers.

You may answer right away with, yes, rounding to limited amount of digits means a rational number. My question is rather, wheather a number defined as a pair of two integrated numbers, would be sufficient datatype for real numbers computations. As I believe there is no sets of operations in a computer that would provide a real number without first deviding some numbers, or, defining a constant. If this is true, wouldnt this be a data type faster to operate on than IEEE floatings? I believe that even sqrt(2) is doing operations that would relate in this datatype. Put simply, +,-,*,/ operations cannot provide irrational number.

There are libraries and systems for working with things in exact precision. Rational numbers can be represented as a/b (where a and b are integers), and irrational numbers can be represented as functions on rational numbers (so for your example, instead of calculating sqrt(2) immediately, you could store the number as the operation "sqrt(2)", and then when you do the math you work with sqrt(2) instead of 1.41...).

The most common examples of this type of computing and calculating is Wolfram and Mathematica stuff. Take WolframAlpha for example. It can work with equations and known constants (like pi, for example) and produce exact results. It can also give you a decimal form of the exact result (and you can request an arbitrary number of digits from this irrational result). Here's an example of a computation done using irrational numbers that it computes the exact result for. If you want a decimal value instead of a the exact result (10 * sqrt(2) * pi), it can compute an arbitrary number of decimal points (and with the pro version of Wolfram's software, it can be as long as you want). If you click the answer, it'll give you this, and you can just keep requesting more and more digits.

Operating on IEEE floats is faster because you can have hardware do it and it's much less complex than exact precision (there are extra computations and "book keeping" you have to do with exact precision). Of course, with the speed increase comes a precision decrease. Modern computers have FPUs, hardware specifically built to operate on IEEE floating point numbers. Chances are your custom data type doesn't have custom hardware for doing computations.

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

The most common examples of this type of computing and calculating is Wolfram and Mathematica stuff. Take WolframAlpha for example. It can work with equations and known constants (like pi, for example) and produce exact results. It can also give you a decimal form of the exact result (and you can request an arbitrary number of digits from this irrational result). Here's an example of a computation done using irrational numbers that it computes the exact result for. If you want a decimal value instead of a the exact result (10 * sqrt(2) * pi), it can compute an arbitrary number of decimal points (and with the pro version of Wolfram's software, it can be as long as you want). If you click the answer, it'll give you this, and you can just keep requesting more and more digits.

Indeed but does this really count? It's essentially a form a symbolic manipulation where your input is algebraically simplified as much as possible, the simplified form can then be queried for an arbitrarily precise results...the underlying number crunching still uses a finite representation.

Indeed but does this really count? It's essentially a form a symbolic manipulation where your input is algebraically simplified as much as possible, the simplified form can then be queried for an arbitrarily precise results...the underlying number crunching still uses a finite representation.

The only limits are 1) how long you want to wait for a result and 2) how much memory you have, pretty much. The thing is, it's impossible to compute some numbers without doing some mathematical function (division, for example, or erf). Heck, we can't even truly write the value of 1/3 in decimal, and it's a rational number. If you want decimal digits (and no mathematical function, like division), you have to approximate it (or else you'll run out of atoms in the universe before you can represent the exact value).

So if you want exact results, you have to do things symbolically. Even storing numbers in memory as a/b (where a and b are integers in some structure) is a form of symbolic algebra (to a degree, at least).

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

Indeed but does this really count? It's essentially a form a symbolic manipulation where your input is algebraically simplified as much as possible, the simplified form can then be queried for an arbitrarily precise results...the underlying number crunching still uses a finite representation.

Depends on whether you choose to count algebraic simplification as number crunching or not.

A maths tool like wolfram alpha can tell me that sqrt(2) * sqrt(2) is exactly equal to two. A numerical library using floats will tell me that it's 1.9999999.
Using some definitions, the first hasn't done "number crunching", but that doesn't matter, as it's damn well more intelligent, and actually correct! It's also done a hell of a lot more "number crunching" using other definitions, such as the amount of compute time consumed in finding that answer wink.png

Also, with that Pi example, you can construct other equations where instead of trying to give you a finite decimal answer, wolfram will give you an exact irrational answer, like Pi/3.

e.g. integrate sin(x) Pi dx where x is 0 to Pi == exactly 2Pi or approximately 6.28319...

[edit]

I didn't realize that cornstalk's example already did give a precise irrational answer of 10*Pi*Sqrt(2)... There would have been significant calculation involved in it finding that exact answer. Yes, if you want to view it as a decimal fraction, you'll get an approximate finite representation, but there's no reason that you have to choose to request that representation...

Numbers can be represented in infinitely different ways. "2*Pi" is no lesser than "6.28319", simply because it uses different symbols. They're both numbers just different ways of writing down the same number. The former is an exact specification of that number, and the latter is an approximation of it.

There's nothing special about base-10, or base-2, or base-16 (decimal/binary/hex) as ways of writing numbers. E.g. 1/3rd cannot be precisely written in decimal (0.3...), 1/10th cannot be precisely written in binary (0.000110011...), etc...

You are still limited to representing computable numbers (i.e. numbers for which there is an algorithm which will output the nth digit of the number [in some base] in a finite number of steps).

There are only a countably infinite number of algorithms (since you can give each algorithm a Godel numbering, which maps an algorithm to an integer), however there are an uncountably infinite amount of real numbers, therefore:

almost all real numbers are not computable numbers (i.e. if you picked a real number completely at random, the probability that there is an algorithm that will be able to produce the nth digit in a finite number of steps is zero).

EDIT: In other words, if you have any interval [a, b] of real numbers, where a < b, then the interval contains only countably many [although infinite] computable numbers, but an uncountably infinite number of uncomputable numbers.

The following sets are all countably infinite:

Natural numbers {1, 2, 3, ...}

Integers {..., -2, -1, 0, 1, 2, ...}

Rational numbers {p/q: p, q integers}

Algebraic numbers {x: x is a root of a polynomial with rational coefficients} (e.g. sqrt(2) which is a root of y = x2 - 2) EDIT: Note, not all roots of polynomials can be generated using +, -, *, / and extracting of nth roots, e.g. x5 - x + 1 = 0, see Abel-Ruffini Theorem http://en.wikipedia.org/wiki/Abel%E2%80%93Ruffini_theorem

Computable numbers

Each set in that list is a subset of the sets below it in the list. Computable non-algebraic numbers include e, pi. A number is called transcendental if it is not algebraic.

The set complement of those sets in the reals (or the complement of those sets in any real interval) are all uncountably infinite.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

My question is rather, wheather a number defined as a pair of two integrated numbers, would be sufficient datatype for real numbers computations.


Regardless of what "integrated numbers" means, the answer is no. Any representation of data in a computer is a finite string of bits. There are only countably many finite strings of bits, but there are many more real numbers (as Paradigm Shifter said, and Cantor before him), so nothing you can do in a computer can be "sufficient datatype for real numbers computations".

Well you could use an analogue computer but then you wouldn't be able to extract a numeric representation of the number without rounding, and when you round a number you convert it to the nearest rational number to the actual number within some arbitrary small interval.

EDIT: Regarding the opening post,

Put simply, +,-,*,/ operations cannot provide irrational number.

this is correct, given rational inputs you cannot produce an irrational number as output since the rational numbers are closed under the operations of +, -, * and division by a non-zero rational (they form a field). You can form a field of fractions from any integral domain (which is a ring which does not have proper divisors of zero i.e. if a, b are members of an integral domain then ab = 0 if and only if a = 0 or b = 0).

There are operations which can produce irrational numbers from rational numbers e.g. taking nth roots, and operations involving limits being 2 examples.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Well you could use an analogue computer but then you wouldn't be able to extract a numeric representation of the number without rounding, and when you round a number you convert it to the nearest rational number to the actual number within some arbitrary small interval.


There is a more fundamental objection to using any computer to represent real numbers: We know from quantum mechanics that the amount of information in the observable universe is finite, which means that a single real number contains more information than what can be held in any computer you may ever build.

This topic is closed to new replies.

Advertisement