These are chat archives for symengine/symengine

17th
Jul 2014
Ondřej Čertík
@certik
Jul 17 2014 16:46
@thilinarmtb, @sushant-hiray what do you think is the best way to integrate floating point numbers in csympy?
Ondřej Čertík
@certik
Jul 17 2014 16:52
What I am thinking is the following: for some applications (e.g. fast plotting), we should allow just double precision evaluation of symbolic expressions. However, the obvious problem with that is that we have no idea about the accuracy of the result, in fact it can be completely wrong due to numerical cancellations. For arbitrary precision floating point, I would use Arb (https://github.com/fredrik-johansson/arb), where each number contains accuracy, so you know exactly how accurate the final result is.
The question is, should we create a new class Float (for Arb numbers), and the double precision would be just C++ double, so we would create virtual functions eval_double() and eval_float(), the first would return just double, the second would return Float. The Float class would be a very tiny C++ wrapper around Arb. For efficiency, what I am thinking is that we should have some low level C++ wrapper for Arb, similar to mpz_class for GMP, not subclass of Basic. And just make the eval_float() return that. And if we want to integrate it more tightly with csympy, e.g. to allow it to be used in expressions, then we need a Float class, that would be a subclass of Basic. Let me know what you think.