4 ms·
The author's not talking about doing math, but about porting math into code. Counting turns is the same as counting cycles. People do that all the time. It work
by oh_my_goodness 27d ago
The author's not talking about doing math, but about porting math into code. Counting turns is the same as counting cycles. People do that all the time. It works fine.
And this math is kind of a mess. exp(x) is its own derivative but the log is not. (d/dx)log(x) = 1/x
But, agreed, if you're going to do calculus, use radians.
- wyager 27d ago> The author's not talking about doing math, but about porting math into code. If your code doesn't look like the math it's "ported" from, the odds of it being bad code go up like 100x
- bee_rider 27d agoI tried to make my code exactly match the math it came from, but I didn’t have enough memory to store sqrt(2)
- titzer 27d agoIf you look at the implementation of sqrt for a computer, it's usually implemented with Newton's algorithm, which is an iterative numerical method with high speed convergence. It is computationally efficient and looks approximately zero how √ looks.
- bee_rider 27d agoRight. I was hoping to highlight that difference with a joke.
- tigen 27d agoSometimes a person will tell a story which is untrue, with the purpose of bringing levity to a conversation. This may be termed a joke. These stories may also be used to illustrate a point. It's important to note that such cases are not always clearly signaled as being humor or untrue. It is a part of the joke's effect that the reader or listener will not at first know it is a joke, but will realize it after noticing an absurdity. A related concept is "dry humor".
- kazinator 27d agoIt is important that they not be clearly signaled.
- kazinator 27d agoWhat? "sqrt(2)" is literally 7 bytes. :)
- dhosek 27d agoI’ve been writing code for 46 years. Not once have I had to code a derivative. And for all the people who are concerned about how sin' 2πx = 2π cos 2πx, in actual code, it doesn’t matter. Let’s say that I’m writing a basic graphing function and I want to be able to display the slope of the sin curve at any point. I am not going to expose the turn-based units to the user. Caring about slopes implies that I’m doing calculus and thus assuming radians. So even though my internal values are [0,1], I will label them as [0, 2π] (and the actual numeric values on the display may actually be something like [50,450] which is yet another numeric value we don’t display). So to get the slope at π/4, I’ll calculate cos_t 0.125 and display that value. We do all kinds of unit translations in computing without worrying about it. This is just another case of that which observes that numerically speaking, using turns is better aligned with the underlying numerical algorithm for calculating trig values.
- srean 27d ago> I’ve been writing code for 46 years. Not once have I had to code a derivative. Haha ! I have been coding for much shorter time but having done some ML on orientations and on spheres in my time, I have had to take their derivatives all the time. It will be interesting to consider folks who do machine learning on robot trajectories or analysing dynamics of robotic arms.
- kazinator 27d ago> Caring about slopes implies that I’m doing calculus You could be using the results of calculus, which became frazzled with gratuitous constants because of poor angle units before anyone wrote any code. You want to keep all the math in radians until you code the calculations; then figure out how to optimize it with turns where possible.
- wyager 27d ago> I’ve been writing code for 46 years. Not once have I had to code a derivative. It sounds like discussions about "porting from math" do not pertain to you then?
- kazinator 27d agoThe derivative of log x being 1/x is "clean", free of arbitrary constants. If we change away from e being the base, we lose that. The derivative of log_b x is 1/(x ln b), where ln b is 1 if b is e. The computational aspect of it is totally compelling. The library routines are already using turns internally, so it is wasteful to go from/to radians when the caller doesn't require it, and many callers can be rewritten not to. Plus the part argument about common angles like multiples of the right angle having to be irrational numbers under radians is also compelling. Assume people have read the article and understood it.