Search code examples
sage

Sage math numerical evaluation


I'm using Sage math to do some calculation where I found the numerical evaluation quite different from that of python's.

For example, the evalf() nolonger works, instead it uses n() and gp().

My questions are:

  1. what are different ways of numerical evaluation in Sage and what's their difference?

  2. what's difference between n() and gp()? why the later seemed to be much slower?


Solution

  • I assume you are referring to Sympy when you say evalf. Anyway, n() or numerical_approx() is the equivalent. See the documentation. The default is 53 bits of accuracy.

    You shouldn't be thinking of gp() though, unless you really want to use the GP/Pari interpreter or convert something to GP.