samhocevar / lolremez

📈 Polynomial Approximations using the Remez Algorithm
Do What The F*ck You Want To Public License
396 stars 36 forks source link

Higher precision for log(x) #24

Closed ApparentlyPlus closed 1 year ago

ApparentlyPlus commented 1 year ago

First of all, let me give props to the devs for this one, it's truly an incredible project. Secondly, whenever I try to approximate log(x) with the weight function being itself (lolremez -d 16 -r 1:2 "log(x)" "log(x)"), the program gets (seemingly?) stuck on iteration 1. The range seems normal, and so do the rest of the parameters. So what exactly is going on here?

samhocevar commented 1 year ago

This happens because $log(1)$ is zero, which causes a division by zero when applying the weight. Depending on your actual need you may want to try and adapt one of these variations:

ApparentlyPlus commented 1 year ago

Oh I see, thanks!

samhocevar commented 1 year ago

I have added a new feature that warns you about a zero in the weight function. This is what happens now:

% lolremez -d 16 -r 1:2 "log(x)" "log(x)"
Error: weight function is zero at x = 1.
%

I will therefore close this bug, as I believe everything has been covered! Thanks for the report.