6 ms·
> 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
by wyager 28d 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 28d 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 28d 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 28d agoRight. I was hoping to highlight that difference with a joke.
- tigen 28d 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 28d agoIt is important that they not be clearly signaled.
- kazinator 28d agoWhat? "sqrt(2)" is literally 7 bytes. :)
- dhosek 28d 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 28d 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 28d 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 28d 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?