4 ms·
Context: I'm looking at Norman Wildberger's rational trigonometry[1], and here I was wondering how useful it is in physics. So I thought about testing it with
by grondilu 10y ago
Context: I'm looking at Norman Wildberger's rational trigonometry[1], and here I was wondering how useful it is in physics. So I thought about testing it with the famous simple pendulum exercise.
It's not obvious we get any FPS gain, but still I find it cool to even be able to get the same result differently.
1. https://en.wikipedia.org/wiki/Rational_trigonometry https://en.wikipedia.org/wiki/Rational_trigonometry
- chombier 10y agoThe rational parametrization looks like the Cayley transform, which IIRC does not cover the whole circle (you can't reach (-1, 0) with a finite mu). Does this happen here as well?
- grondilu 10y agoIndeed, (-1, 0) can not be reached. I'm thinking of ways to improve it that regard.
- jacobolus 10y agoThis is a stereographic projection representation of an angle. The number should be seen as a point on the real projective line, which includes a point at infinity. If you’re using floating point, you can use the number ∞ for this. You’ll need some special cases in the code for it. Cf. https://en.wikipedia.org/wiki/Stereographic_projection https://en.wikipedia.org/wiki/Stereographic_projection https://en.wikipedia.org/wiki/Tangent_half-angle_substitution https://en.wikipedia.org/wiki/Tangent_half-angle_substitutio... https://en.wikipedia.org/wiki/Real_projective_line https://en.wikipedia.org/wiki/Real_projective_line
- daniel-levin 10y agoIf you are using floating point numbers, you are using rationals. You cannot represent an irrational number using a floating point variable. There is no getting around the fact that the real number system is an abstraction, and floating points model a very small segment of the reals (the rationals are of measure zero, and hence so are all the reals representable as floating points). There are only so many bits with which to do computations, according to the IEEE 754 scheme. Edit: addendum How exactly does one do ordinary calculus with only rational numbers?
- grondilu 10y agoThe 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...
- noobermin 10y agoPlease change the name then to "rational trigonometry", not rational numbers. I was thinking that the only numbers you were using involved the ratio of integers, but I did not see this explicitly here. That or I don't read it correctly. There's a specific definition of the set of rational numbers which doesn't quite mean what I think you meant when you include it in your title. I mean, it's your code, you decide what you call it but it will most likely confuse others.
- dang 10y agoOk, we s/numbers/trigonometry/'d the title.