# why using numpy

what is the advantage of using numpy arrays, matrices, integers, floats, ..etc. over the normal ones in sage ??

1

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, 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 plan to distribute your piece of software as a standalone application.

thank you so much for your reply. The problem is that i am dealing with very large numbers that exceed the ranges fro numpy integers and doubles, so i have to use sage.

Asked: **
2013-10-25 08:33:45 -0600
**

Seen: **138 times**

Last updated: **Oct 26 '13**

How to obtain elements from the matrix above the main diagonal?

convert sage complex matrix into numpy matrix

performing a higher resolution FFT

Random numbers in parallel calculations

Matrix dot multiplication slowness and BLAS versions

Using symbolic expressions with numpy arrays

Empty graph using implicit_plot3d with contour-option

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.