5 ms·
And sorry for spelling this out for you, but maybe it is you who is "accusing of making elementary mistakes without actually understanding what he's doing." He
by tagrun 11y ago
And sorry for spelling this out for you, but maybe it is you who is "accusing of making elementary mistakes without actually understanding what he's doing."
Here is why:
1)
> Your polynomial, since it doesn't get it exactly right at 1/4 & 1/2, will have an enormous relative error when you use it for computing logs of numbers very close to 1.
In case you missed, Mathematica's (not mine) polynomial gives
a maximum 0.00334047 relative error. And the points with 0.00334047 error are actually edge points (which does not include 1).
The important point is, it is not enormous. In fact, his polynomial gives 10 times larger error at certain points, so it is he who has an enormous error. And Mathematica's polynomial is continuous, so even when you slightly get outside of the intended range, you're still getting an error of the order 10^-3.
2)
> Your (2,2) rational approximant will be much more expensive to compute than the polynomial and won't yield the speed gains Goldberg is looking for.
Again, since you apparently missed it, the (2,2) approximant I gave is for [0.25,0.5] interval with t=1/4, so yes, bad things can and will happen if you use that polynomial outside of that range (same things happens with his polynomials too, obviously). Instead, what one should do is to move that 1/4 part into the exponent and stick to [0.25,0.5].
(About the speed vs accuracy trade-off, I already pointed that out in my original post by saying "if the division isn't too expensive"; I'm not sure why you are emphasizing it again here.)
Going back to your statement, when compute logs very close to 1, you subtract 2 from the exponent and instead compute between [0.25,0.5] using that polynomial.
3.
> "Imposing that errors should vanish at certain points" is not a mistake, it's a necessity if you're implementing log by argument reduction plus local approximation and you care about relative error in the resulting approx_log function, and you are getting better numbers than Goldberg by solving the wrong problem.
"argument reduction plus local approximation" means range reduction to [t,2t) for log function and this has nothing to do with the behavior of approximation polynomial at the edges; you may very well have non-zero errors at t and 2t and there is nothing wrong or alarming about it (see Handbook of Floating Point Arithmetic, Chapter 11, for example).
The point is, the max rel error should be kept small, which Mathematica does, 10 times better.
Such an artificial condition is necessary only when the relative error function becomes discontinuous and starts making sudden jumps (see Figs 6-7 from the top in the write up.) He is trying to remedy a problem which appeared due to his choice of t, at the cost of losing degrees of freedom in the polynomial (see also the comments here http://reference.wolfram.com/language/FunctionApproximations/tutorial/FunctionApproximations.html http://reference.wolfram.com/language/FunctionApproximations... about when the function becomes zero in the interval, in which case you need to deal with these points by making them special --note from the example that this doesn't have to mean you lose 2 degrees of freedom to avoid a single point).
So, in short, I am solving the right problem.
4. Which brings me to the other unspelled problem in some of his polynomials; the derivative is very bumpy and discontinuous, which spells out disaster in general math applications.
(Clearly, the derivative of his function will have enormous minimax (L^\infty) and RMS (L^2) errors, unlike Mathematica's polynomial.)
Summary: 1) Mathematica's polynomial gives ~10 times smaller maximum error than the write up within the range 2) Mathematica's polynomial gives 10x smaller RMS error within the range 3) Mathematica's polynomial is smooth. (I hope by now, you are clear that Mathematica's polynomial nowhere gives any enormous error and quite the oppoisite, the error is much lower) 4) If you use approximant polynomials only within their intended range and move the remaining factors into the exponent, everything works out.
5) My pointing out a bad mathematical practice wasn't personal, so please don't steer the discussion into that direction. I understand that you respect him which may motivate this, my credentials in maths aren't shabby at all (I have more peer-reviewed research papers than him, and in higher impact journals etc etc) (and if Mathematica says one thing and a human says another, in most cases Mathematica is correct) but credentials don't matter in front of solid results. In fact, accepting a scientific result (partly-)based on credentials is considered to be toxic in science. Which brings me back to my original point. I stand by what I said earlier: I don't recommend using the polynomials in the write up.
- gjm11 11y ago> a maximum 0.0033407 relative error On the interval from 1/4 to 1/2. But the whole point of this exercise is to make an approximation for the log function over its whole domain. If you take Mathematica's/your polynomial and do that with it, you get an infinitely large relative error at 1 because log(1)=0 but your approx_log(1) is not 0. (This is the central point I was trying to make in my comment, and the fact that you missed it suggests I wasn't clear enough. I'm sorry about that; in particular, clearly I should have made it more explicit that I understand how argument reduction works -- it hadn't occurred to me that that was in question, since it's a standard technique, described perfectly adequately in the article we're discussing.) > if you use the polynomial outside of that range I never for an instant suggested using the polynomial outside that range. I am assuming the obvious argument-reduction scheme where you say log2(2^a.b) = a + log2(b) and arrange for b to lie within some interval [t,2t). In other words, I am assuming the same thing that Goldberg described and the same thing that you are assuming (but apparently missing a key consequence of). So. Suppose you compute log2(1) using your polynomial. You argument-reduce: log2(1) = 2 + log2(0.25). Then you use your polynomial: log2(1) = 2 + (-3.64631 + 7.9376/4 - 5.30406/16) ~= 0.0066. The actual value you are looking for is log2(1) = 0. Your relative error is infinite. (You can use the other end of the interval instead. Then you get -0.0035; again, the relative error is infinite.) Goldberg avoids having this happen by forcing the absolute error to be zero at the endpoints (when he uses a polynomial on [1,2)) or at the relevant point in the middle (when he uses one on [0.75,1.5)). This extra constraint is what forces him to accept larger relative errors on his [t,2t) interval; that's the price he has to pay for finite relative error on the whole domain of the log2 function. > and this has nothing to do with the behaviour of approximation polynomial at the edges Indeed, the fact that the point where you run into trouble is at the end of the interval is irrelevant, and it would be an interior point that mattered if you did as Goldberg did and used an interval like [0.75,1.5). > So, in short, I am solving the right problem. No, really, you're not. Goldberg wants his relative error for the approx log2 function not to blow up when computing log2(1), which requires that it evaluate to exactly 0 when fed exactly 1. Your polynomial doesn't have that property. (Of course it's questionable whether relative error is what one ought to care about for an approximate logarithm function. Maybe it isn't. I don't know what applications Goldberg actually has in mind, and quite possibly he isn't at liberty to tell us. But the problem he's stated is to compute an approximation to log2 with reasonable relative error, and it's simply incorrect to say he's done that badly because you can get reasonable relative error on a smaller interval, if your relative error goes to infinity elsewhere. Which it does.) > the derivative is very bumpy and discontinuous Yeah, I dislike that too. Again, how much this matters depends on the applications you have in mind. > My pointing out a bad mathematical practice wasn't personal, so please don't steer the discussion into that direction. [...] accepting a scientific result (partly-)based on credentials is considered to be toxic in science. I never said anything even slightly personal; I have made no comment on either Goldberg's credentials or yours (or for that matter mine); only one person in this discussion has appealed to credentials, and it's you. Twice. (Once earlier: "Unless you are an expert in numerical methods ...". Once just now, comparing your credentials with Goldberg's.) Anyway: of course I strongly agree: credentials are less important than results. In this case, Goldberg made an approximation to log2 whose relative error is bounded on its entire domain of applicability, and you didn't. In particular, #4 from your summary is flatly incorrect.