I would like to know if there is a way to determine/recognize a irrational number by computers. Let me explain it a little more. I know that, in computer science, a computable number "a" is a number that can be approximated by two rational number, i.e. (k-1)/n<=a<=(k+1)/n where k&n are in N. Also, due to the limitation of floating point, all numbers in computers have limited number of significant figures. So, I was wondering if there is a way (more like an algorithm) to define irrational number for computers and consequently detect irrational number? Off course, I'm talking about an approximation with some adjustable level of accuracy. Thanks
$\begingroup$
$\endgroup$
1
-
3$\begingroup$ "...floating point, all numbers in computers..." Floating point is not the only way to represent numbers. Integers are naturally there (up to some limiting size), rationals can be handled with infinite precision as a pair of integers, quadratic irrationals can be handled by their continued fraction, algebraic numbers can be handled by manipulating their minimal polynomials, etc. Programs like Sage and Mathematica can handle e, pi, and many other common transcendentals formally, thereby maintaining infinite precision. $\endgroup$– Kevin O'BryantCommented Mar 22, 2012 at 17:15
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
Generate the continued fraction for the number. If it has a suspiciously* large number, truncate just before it: it's probably rational. Otherwise it's either irrational or rational with a large denominator; you can't easily tell the two apart.
Of course since both rationals and irrationals are dense in the reals you can never know for sure with just an approximation, but this is a useful technique that often works in practice.
* This can be made more precise using the Gauss-Kuzmin distribution. But you can probably just eyeball it.