Ask Your Question

Revision history [back]

As you can see in the list of standard packages, numpy is included in Sage, but is only a small part of it.

Hence Sage is much more versatile than numpy. In particular, a number has more representations in Sage than in numpy. For example, if you want to deal with floating-point approximations of real numbers, in Sage you have the choice between RealDoubleField, RealField and RealIntervalField. The first one (corresponding to machine doubles), is very close to numpy.float64, so there will not be much difference in this case. But there is no equivalent of RealField or RealIntervalField in numpy.

Basically, for a given task, Sage makes choices among available softwares. So, when numpy is the most appropriate, it will be used transparently. This is the case for dense matrices over RealDoubleField, so even in this case (numpy is a specialist in matrices), you do not have to specifically use numpy since Sage does it for you.

That said, the choice is more important between Sage representations than between a Sage representaton and its numpy equivalent (when it exists). For example, some computations are much faster in matrices over RealDoubleField than over RealField(53). Also, the computation of eignevalues over RealDoubleField is more accurate than the naive algorithm over RealField.

However, Sage is monolithic and much bigger than numpy, hence, it may be suitable to use numpy if you want to distribute your piece of software as a standalone application.

As you can see in the list of standard packages, numpy is included in Sage, but is only a small part of it.

it. Hence Sage is much more versatile than numpy. In particular, a number has more representations in Sage than in numpy. For example, if you want to deal with floating-point approximations of real numbers, in Sage you have the choice between RealDoubleField, RealField and RealIntervalField. RealIntervalField, so there is no "normal one". The first one (corresponding to machine doubles), is very close to numpy.float64, so there will not be much difference in this case. But there is no equivalent of RealField or RealIntervalField in numpy.

Basically, for a given task, Sage makes choices among available softwares. So, when numpy is the most appropriate, it will be used transparently. This is the case for dense matrices over RealDoubleField, so even in this case (numpy is a specialist in matrices), you do not have to specifically use numpy since Sage does it for you.

That said, the choice is more important between Sage representations than between a Sage representaton and its numpy equivalent (when it exists). For example, some computations are much faster in matrices over RealDoubleField than over RealField(53). Also, the computation of eignevalues over RealDoubleField is more accurate than the naive algorithm over RealField.

However, Sage is monolithic and much bigger than numpy, hence, it may be suitable to use numpy if you want plan to distribute your piece of software as a standalone application.