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

Precision of square eq solver can be improved for a->0 #3

Closed
stiv-yakovenko opened this issue Sep 1, 2017 · 2 comments
Closed

Precision of square eq solver can be improved for a->0 #3

stiv-yakovenko opened this issue Sep 1, 2017 · 2 comments

Comments

@stiv-yakovenko
Copy link

HI! Instead of using (-b+-sqrt(d))/2/a you can use this formulae to get rid of 0/0 division in case a->0:

    sqD = sqrt(d);
    x1 = b > 0 ? (2 * c / (-b - sqD)) : (2 * c / (-b + sqD));
    x2 = -b / a - x1;

Thanx.

@vorot
Copy link
Owner

vorot commented Sep 1, 2017

A good point indeed, thank you. There are even more things to take into account as described in https://people.csail.mit.edu/bkph/articles/Quadratics.pdf

I am not sure when I have time time for this change but I shall accept a pull request if you dare to change the code yourself (tests are welcome too).

@vorot
Copy link
Owner

vorot commented Sep 4, 2017

Fixed in v0.0.4

@vorot vorot closed this as completed Sep 4, 2017
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