• Create Account

# every number in computer is rational?

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

11 replies to this topic

### #1JohnnyCode  Members   -  Reputation: 236

Like
0Likes
Like

Posted 15 August 2013 - 09:12 PM

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.

### #2nonoptimalrobot  Members   -  Reputation: 408

Like
0Likes
Like

Posted 15 August 2013 - 09:52 PM

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.

### #3Cornstalks  Crossbones+   -  Reputation: 6807

Like
7Likes
Like

Posted 15 August 2013 - 10:04 PM

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.

Edited by Cornstalks, 15 August 2013 - 10:08 PM.

[ 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 ]

### #4nonoptimalrobot  Members   -  Reputation: 408

Like
0Likes
Like

Posted 15 August 2013 - 10:16 PM

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.

### #5Cornstalks  Crossbones+   -  Reputation: 6807

Like
0Likes
Like

Posted 15 August 2013 - 10:29 PM

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).

Edited by Cornstalks, 15 August 2013 - 10:30 PM.

[ 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 ]

### #6Hodgman  Moderators   -  Reputation: 19399

Like
1Likes
Like

Posted 15 August 2013 - 10:29 PM

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

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...

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...

Edited by Hodgman, 15 August 2013 - 11:48 PM.

### #7Paradigm Shifter  Crossbones+   -  Reputation: 3995

Like
2Likes
Like

Posted 16 August 2013 - 02:28 AM

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.

Edited by Paradigm Shifter, 16 August 2013 - 06:14 AM.

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

### #8Álvaro  Crossbones+   -  Reputation: 8051

Like
0Likes
Like

Posted 16 August 2013 - 04:28 AM

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".

### #9Paradigm Shifter  Crossbones+   -  Reputation: 3995

Like
0Likes
Like

Posted 16 August 2013 - 04:42 AM

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.

Edited by Paradigm Shifter, 16 August 2013 - 04:52 AM.

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

### #10Álvaro  Crossbones+   -  Reputation: 8051

Like
0Likes
Like

Posted 16 August 2013 - 05:15 AM

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.

### #11Paradigm Shifter  Crossbones+   -  Reputation: 3995

Like
0Likes
Like

Posted 16 August 2013 - 05:23 AM

Indeed. Getting the inputs to be exact is "challenging" for an analogue computer too ;) And there are issues with noise.

You could probably build a computer to do it if there are uncountably many parallel universes to exploit when you build it, I suppose.

I was going to mention an Oracle Machine being able to do stuff like that but then I saw this on wikipedia:

Oracles and halting problems

It is possible to posit the existence of an oracle which computes a non-computable function, such as the answer to the halting problem or some equivalent. A machine with an oracle of this sort is a hypercomputer.

Interestingly, the halting paradox still applies to such machines; although they determine whether particular Turing machines will halt on particular inputs, they cannot determine, in general, if machines equivalent to themselves will halt. This fact creates a hierarchy of machines, called the arithmetical hierarchy, each with a more powerful halting oracle and an even harder halting problem.

http://en.wikipedia.org/wiki/Oracle_machine

Edited by Paradigm Shifter, 16 August 2013 - 05:24 AM.

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

### #12Álvaro  Crossbones+   -  Reputation: 8051

Like
0Likes
Like

Posted 16 August 2013 - 06:55 AM

One more comment on the computable numbers that Paradigm Shifter was referring to: Using an algorithm to determine the n-th digit as the representation of a number might not be all that useful, because many simple things you may want to do (e.g., check if it is larger than 0) are not computable.

Edited by Álvaro, 16 August 2013 - 06:56 AM.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS