-
Notifications
You must be signed in to change notification settings - Fork 167
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
Resolve decimal problem #11
Comments
Look at simpsonRecursive() in /numeric/calculus.js. It takes an epsilon argument, which is part of ensuring the result is in a certain error bound. |
I think we're going to need to use error bounds, because all the calc functions with limits are going to be a little off. To reliably convert them to the right answer seems impossible without vastly complicating things. |
@ethanresnick did you see the implementation I started putting in place? It's actually really only relevant for testing...but it also could just be used globally for any functions requiring an error bound. |
I like it. Going to make a few changes w/ explanations in the commit logs; let me know what you think. We can always revert them. |
Don't think this is really closed. Epsilon gets around the JS rounding errors, but it doesn't get around the other kind of error (i.e. that we're approximating "infinitely close" in derivatives and limits with fixed decimal distances). For example, if I do To fix this kind of issue, we could just cheat and make the decimal used in |
Yeah you're right, I just got overly excited. I am concerned that if you went with a recursive method, you might exceed max stack size. Maybe in addition to epsilon, you provide a max recursion count that limits how far that goes. Because if you wanted to get close enough, you might notice performance problems. But if you're fine with some level of error in hopes of gaining efficiency, then you can reduce it. The Thoughts? |
Hmm...thinking about this some more, maybe just replacing the decimal used in If we do decide to do something iterative/recursive, then I think (though correct me if I'm wrong) that using Re having a max recursion count exposed in the API: I have to think about it some more; could definitely be useful, but it seems like it might be overkill too. |
So I started writing tests for calculus.
Here's an example:
Now, the point derivative of 2x + 2 at any value is 2. The method returns the following: 1.9999999999242843
This is "basically" 2, but it won't pass tests. So I've considered two options:
I like two more, although it certainly is going to be a hassle to set up. But this way we can have an "acceptable" error bound, which is sustainable and acceptable for the browser, and has minimal effect in performance or large scale operations.
The text was updated successfully, but these errors were encountered: