-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fixes the Sqrt accuracy (#97) #98
base: master
Are you sure you want to change the base?
Conversation
@@ -47,7 +48,7 @@ public void The_result_should_be_equal_to_Math_Sqrt(double value) { | |||
var expected = Math.Sqrt(value); | |||
var fraction = Fraction.FromDouble(value); | |||
// Act | |||
var actual = fraction.Sqrt(); | |||
var actual = fraction.Sqrt(15); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this test broke as it started actually using the default 30 digits accuracy..
As expected- the performance is now way worse:
but I think there are a couple of things that could make things a little better.. Let me setup a new benchmark.. |
TLDR: One way or another this fix would be a breaking change- you have to decide in what way. Right, so this is quite interesting: you know the So? What do we care about the significant digits? The xml-docs says "number of digits after the decimal point" and the comparison of the absolute difference with
Overall, no matter the numbers- the convergence is very fast (in terms of iterations), but there is a clear asymmetry with respect to the input scale. A typical number such as 1.234 would only take 1 iteration in order to reach an accuracy of 30, but the number 1234 would likely take 2, resulting in an accuracy that's between 56-58 decimal places (almost twice what we asked for). |
Fixes #97