Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exp/log implementation burden ? #7

Closed
lrnv opened this issue Dec 7, 2020 · 7 comments
Closed

Exp/log implementation burden ? #7

lrnv opened this issue Dec 7, 2020 · 7 comments
Assignees

Comments

@lrnv
Copy link
Contributor

lrnv commented Dec 7, 2020

Hey,

In my application, I only require exponentials and logarithms uppon what is already implemented.

How hard would it be to add those two functions ? Do you know how it should be done ? I would be happy to contribute.

Edit: Could a temporary fix be introduced by convertion to BigFloat back and forth ? I know this is highly sub-optimal, but it'll allow code to at least run. Since exp/log are not the most part of my workflow, it might still provide a huge performance gain over bigfloat for me.

@dzhang314
Copy link
Owner

Hey @lrnv ! Thanks for your interest in my project. It's been a while since I've worked on MultiFloats,jl, so my apologies in getting back to you.

You're absolutely right that a conversion to/from BigFloat would be the easiest stop-gap solution. I'll go ahead and introduce this change for exp, log, and the trigonometric functions.

For a proper Float64xN implementation of exp, what we will want to do is argument reduction followed by a Taylor series approximation. We can then obtain log by using Newton's method to calculate the inverse of exp.

Since interest in MultiFloats.jl is picking back up, I'll commit some time to working on it again. You can expect a stop-gap BigFloat conversion in a day or so, and a proper MultiFloat implementation sometime next week!

@dzhang314 dzhang314 self-assigned this Dec 18, 2020
@lrnv
Copy link
Contributor Author

lrnv commented Dec 19, 2020 via email

@dzhang314
Copy link
Owner

@lrnv Yes, I would be happy to accept such a PR! Do go ahead.

@lrnv
Copy link
Contributor Author

lrnv commented Dec 28, 2020

I'm not sure about argument reduction, but the taylor expension of exp() is easy to take: inverse factorials can even be stored in a fixed array, initialised at package loading time. Just store enough so that the approimation is better than Float64x8 precision.

For the log(), the taylor serie of the logarithm might be a faster alternative than the newton inversion.

@dzhang314
Copy link
Owner

Hey @lrnv , I appreciate the suggestion but that is not going to work. The Taylor series of the logarithm converges exponentially slowly. In order to get a result that is accurate to n bits, you need something like e^n terms. In contrast, Newton iteration doubles the number of correct digits in each step, so you only need log(n) iterations.

@lrnv
Copy link
Contributor Author

lrnv commented Jan 4, 2021

Now that i read a little about it, you are right. I think it's the same used there : https://github.com/JuliaMath/DoubleFloats.jl/blob/master/src/math/elementary/explog.jl#L236
But maybe in our case, dependending on N, more newton iterations should be done.

@dzhang314
Copy link
Owner

I've just released MultiFloats.jl verison 1.0, which includes exp and log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants