4 ms·
The use of the rational numbers I was referring to was more in the equations than in the running code. In fact, part of the appeal I find in rational trigonome
by grondilu 10y ago
The use of the rational numbers I was referring to was more in the equations than in the running code.
In fact, part of the appeal I find in rational trigonometry is that it should be easier to adapt for computing, since as you pointed out, computers can not represent irrational numbers. Yet trigonometric functions usually return irrational numbers, and a computer can't do better than approximate them.
On the contrary, it is possible to do exact arithmetic on rational numbers. Granted, you can't do that with floating points, though.
PS. To be clear: although the numbers actually used in the code are floating point numbers, the equations have a purely algebraic form (no sine, cosine or sqrt), so it should at least in principle be possible to use a Rational number type instead, and the computation would then be exact. The only approximation would be due to the Runge-Kutta algorithm.
- daniel-levin 10y agoOn the contrary - computers certainly can represent irrational numbers - but not with floating points.
- jacobolus 10y agoComputers, like humans, can only represent a vanishingly tiny proportion of “real numbers”, either by giving specific ones a name, or some kind of symbolic formula by which to compute with them. To do practical computations we need to break everything down into basic arithmetic operations, which ultimately means we have a concrete multiplication/addition(/other operation) table encoded somewhere, e.g. in silicon. One that I like for doing exact arithmetic on numbers represented by black-box functions is a continued fraction representation, see http://perl.plover.com/yak/cftalk/INFO/gosper.txt http://perl.plover.com/yak/cftalk/INFO/gosper.txt (Note: floating point is successful because trying to use irrational numbers in computations is most of the time a huge waste of computational resources compared to approximating with a binary fraction.)
- evincarofautumn 10y agoHere’s an interesting precise representation of algebraic numbers as roots of integer polynomials: http://twistedoakstudios.com/blog/Post6871_impractical-experiments-1-representing-numbers-as-polynomials http://twistedoakstudios.com/blog/Post6871_impractical-exper...
- conistonwater 10y agoThat's pretty much how a typical CAS represents algebraic numbers, I don't think there's much impractical about that idea.
- tgb 10y agoNo, but algebraic numbers are only a tiny portion of all irrational numbers and importantly misses key ones like e and pi, so the original point still stands.