-
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
Update mathjs to get bigint support #343
Comments
In fact, any version of mathjs from 13.0 on will have bigint support. |
Kate brought up a rounding issue in a Delft-related discussion:
|
I'm not sure if this is the right place for this bug report, but a bigint issue appears as follows, so this is something to test when this gets fixed. The following specimen fails when the integer produced by formula becomes too big: That uses formula |
There is a critical issue that will come up when we switch to a version of mathjs with bigint support: Presumably when we do so, then all numerical constants in the formula will be interpreted as bigints. When that's the case, how would we like (a) Swap sqrt for a function that only returns bigints, say the bigint that is the floor of the square root of its argument? Then (b) Choose some arbitrary specific precision, like say 100 decimal places, and have mathjs always compute real-valued functions to that precision, but throw errors in operations that may nevertheless return erroneous integer parts of results because of the magnitude of another operand? Once we allow OEIS sequences in formulas, (c) Try to arrange mathjs to defer its choice of precision when computing real-valued functions until it has analyzed the whole formula, and then use a precision sufficient to guarantee that the result it produces will have the same (d) Try to arrange mathjs to perform formula transforms to make an input formula "safe" for bigint computation. In other words, (e) Something else? It seems to me there is no obvious good method here, but perhaps I am not thinking clearly. So I would appreciate suggestions @katestange / @Vectornaut , and I am marking this for a future meeting. |
Implementing interval arithmetic would not be a significant burden. But it doesn't seem to be the whole answer here. We want to analyze the formula |
Kate and I discussed this a bit further today. We agreed that for beta, it's plenty to enable mathjs bigint and put in some safety checks that we're not doing questionable things like multiplying a float by a very large bigint, and if we do pops up a message and refuses to give an answer. Later if someone is running into lots of these popups, we could consider implementing interval arithmetic or just an approximate scheme that goes to higher-precision floating point numbers when the bigints are big. The difficulty with the second approach is that if we seem to be giving exact answers, we should probably only be giving answers that are guaranteed to be correct, which may be tricky to determine without some mechanism like interval arithmetic. |
PR josdejong/mathjs#3207 adds bigint support to mathjs. Once the Delft project is merged, update to a version of mathjs that includes that support, and remove code in frontscope working around mathjs' lack of bigint support.
The text was updated successfully, but these errors were encountered: