Memory allocation is expected for rationals because BigInt
isn’t a machine type.
You can think of BigInt
s as pointers to dynamically-sized numbers of bits which hold the information for how big that integer is. So as with anything with pointers involved (arrays), you’ll be allocating a lot of memory to make it work. That’s why most math is not done with arbitrary precision arithmetic (of which Rational{BigInt}
is as far as it gets): it’s very expensive and there’s no way for it to not be (unless you have an idea… that would be a great Julia library!)
If you want fast arbitrary precision arithmetic, the best setup is likely to use ArbFloats.
They will be much faster than BigFloats until you get up to some absurd levels of precision. They also allow for doing interval arithmetic to show uncertainties, but as @stevangj has already mentioned, interval arithmetic is known to have very pessimistic error bounds and so it is really only applicable in some domains.
For Rational{Int}
performance, see issue #11522. These changes could probably be made soon, if someone is keen.
@dpsanders, Thanks for the tip, I transformed the problem to use ValidatedNumerics!
Great! Let me know if you have any questions. I’d be very interested to see your code.
@dpsanders
Paper describing what we did is here:
Relevant code is located here:
https://git.wmi.amu.edu.pl/kalmar/PropertyT.jl/src/master/src/checksolution.jl
comments, questions are welcome!
btw. how can I cite ValidatedNumerics package?
Great, thanks, I’ll take a look.
Good question about citing VN, I’ll get back to you about that.