Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Are there any open source math programs out there that have an interactive terminal and that work on linux?

So for example you could enter two matrices and specify an operation such as multiply and it would then return the answer or a error message specifying why an answer can't be computed? I am just looking for something that can perform basic matrix operations and modular arithmetic.

share|improve this question
10  
How about using R? –  Wonder Aug 3 '12 at 10:00
1  
The (computer science) tag should be removed, as it's not a mathematical question about computer science. –  somebody Aug 3 '12 at 10:04
7  
Should be community wiki! –  user641 Aug 3 '12 at 11:09

14 Answers 14

up vote 49 down vote accepted

Sage is basically a Python program/interpreter that aims to be an open-source mathematical suite (ala Mathematica and Magma etc.). There are many algorithms implemented as a direct part of Sage, as well as wrapping many other open-source mathematics packages, all into a single interface (the user never has to tell which package or algorithm to use for a given computation: it makes the decisions itself). It includes GP/Pari and maxima, and so does symbolic manipulations and number theory at least as well as them.

It has a command-line mode, as well as a web notebook interface (as an example, a public server run by the main developers).

And, although this might not be relevant since your use-case sounds very simple, the syntax is just Python with a small preprocessing step to facilitate some technical details and allow some extra notation (like [1..4] which expands to [1,2,3,4]), so many people already know it and, if not, learning it is very easy.

As a slight tangent, Sage is actually the origin of the increasingly popular Cython language for writing fast "Python", and even offers an easy and transparent method of using Cython for sections of code in the notebook.

share|improve this answer
1  
+1. A single program which will do both matrix computations and modular arithmetic as per OP request. –  user2468 Aug 3 '12 at 12:29
2  
@J.D. As is Pari/GP - as single program that will do both matrix computations and modular arithmetic as per OP request :) –  Old John Aug 3 '12 at 12:40
1  
This is very suitable considering it's about a linux program - Sage under linux is really convenient. However under Windows Sage is a complete nightmare. –  Peter Sheldrick Aug 3 '12 at 15:24
1  
@PeterSheldrick Under windows, you might want to give Spyder (there's also a Linux version) a try, it's part of PythonXY –  Tobias Kienzler Aug 4 '12 at 7:43
2  
I feel it's a bit disingenuous to say that Sage is just a wrapper for a bunch of packages. It's certainly this, but Sage also sports a wide variety of algorithms implemented in Sage by the developers. –  JSchlather Aug 5 '12 at 19:30

I am aware of two packets that might help You:

  1. Octave - free clone of Matlab,
  2. maxima - a packet for symbolic computations.

Octave is good when you want to do numerical calculations and you can accept numerical errors. Especially good for matrix/vector operations. I think this is what you want. Maxima is rather for symbolic computations. Both of them have text interface. If you want more user-friendly interface for the latter one, try wxMaxima.

share|improve this answer
    
what type of syntax does maxima use? –  Magpie Aug 3 '12 at 16:38
1  
Maxima requires multiplication to be explicitly expressed (so xx is always one variable/symbol with a two-letter name instead of being x*x). You can assign expressions or equations to variable names with the colon operator ':', and certain matrix operations like cross-product '~' require an extra package to be loaded and must be passed as an argument to the express() function to get an actual result. Other than that, the syntax and functionality is similar to most CAS software or calculators. It's useful for dealing with differential equations, but I'd use something else for numerical work. –  James O'Doherty Aug 4 '12 at 7:22

For modular arithmetic and much more by way of number theory, I would strong recommend GP/Pari from here.

It does a huge variety of operations mostly relevant to number theory, but not limited to that area. It should be easily installable on most versions of Linux.

Added: just checked, and it also does a wide variety of vector/matrix and linear algebra stuff.

share|improve this answer
5  
Pari is also extremely fast IME –  user641 Aug 3 '12 at 11:08

I recommend numpy and scipy, which are packages for Python. The advantage over many dedicated mathematical packages is that they are packages for a well established language, meaning that they may easily integrated with all the other things you do with computers, such as generating images, reports, web pages, or interacting with a desktop application.

The ipython program provides a very useful shell for direct interaction with the packages. What's more, matplotlib is integrated with ipython through the command line switch

ipython --pylab

Look seriously at numpy, if you're interest is in matrices there are tools here which make your life very easy.

share|improve this answer
1  
I second this. If the "terminal" can be in an IDE, spyder is a great addition to this suggestion –  Tobias Kienzler Aug 3 '12 at 17:50
    
I second numpy/ipython. Also in the future if you need more advanced data visualization you can get inline graphical plotting of data using ipython/qtconsole –  Trevor Boyd Smith Aug 3 '12 at 20:55

Yes, GNU Octave, the open source terminal equivalent of MATLAB. Most MATLAB code can be used in Octave directly, and their computation times are roughly equivalent. Octave can plot but does not have a GUI terminal.

share|improve this answer
2  
I think QOctave is a gui for it. –  Magpie Aug 3 '12 at 16:53
2  
@Magpie Its QtOctave –  Jayesh Badwaik Aug 4 '12 at 16:24

Scilab is a good opensourced Matlab-like software. If you know Matlab, Scilab is very similar.

share|improve this answer

I suggest a computer algebra system, maxima, whose license is GPL, therefore it's entirely FREE. It specializes in symbolic operations but also offers numerical capablities.

If you hate command line interface, you can choose wxmaxima. It's just a good frontend of maxima.

And if you're a common lisp programmer, you can choose embeddable maxima. It provides the freedom of mixture between common lisp programs and maxima functions. I got this from an answer to my post

share|improve this answer

Depending on my use-case I either use Calc; the C-style arbitrary precision calculator or bc.

(Both are available on Linux/OSX/Windows)

Calc

Example matrix assignment:

mat [2][3] = {{1,2,3},{4,5,6}}

Documentation for multiplication of matrices:

A * B

Multiplication is defined provided certain conditions by the dimensions and shapes of A and B are satisfied. If both have dimension 2 and the column-index-list for A is the same as the row-index-list for B, C = A * B is defined in the usual way so that for i in the row-index-list of A and j in the column-index-list for B,

                     C[i,j] =  Sum A[i,k] * B[k,j]

the sum being over k in the column-index-list of A. The same formula is used so long as the number of columns in A is the same as the number of rows in B and k is taken to refer to the offset from matmin(A,2) and matmin(B,1), respectively, for A and B. If the multiplications and additions required cannot be performed, an execution error may occur or the result for C may contain one or more error-values as elements.

If A or B has dimension zero, the result for A * B is simply that of multiplying the elements of the other matrix on the left by A[] or on the right by B[].

If both A and B have dimension 1, A * B is defined if A and B have the same size; the result has the same index-list as A and each element is the product of corresponding elements of A and B. If A and B have the same index-list, this multiplication is consistent with multiplication of 2D matrices if A and B are taken to represent 2D matrices for which the off-diagonal elements are zero and the diagonal elements are those of A and B. the real and complex numbers.

If A is of dimension 1 and B is of dimension 2, A * B is defined if the number of rows in B is the same as the size of A. The result has the same index-lists as B; each row of B is multiplied on the left by the corresponding element of A.

If A is of dimension 2 and B is of dimension 1, A * B is defined if number of columns in A is the same as the size of A. The result has the same index-lists as A; each column of A is multiplied on the right by the corresponding element of B.

The algebra of additions and multiplications involving both one- and two-dimensional matrices is particularly simple when all the elements are real or complex numbers and all the index-lists are the same, as occurs, for example, if for some positive integer n, all the matrices start as mat [n] or mat [n,n].

share|improve this answer
    
Can either of them deal with matrices? It doesn't look like it. –  Rahul Aug 3 '12 at 21:35
1  
Calc most certainly can. I'll edit the answer by providing the documentation. –  Samuel Marks Aug 4 '12 at 6:29

In addition to the various heavy-weight tools already named, you should also take a look at Euler Math Toolbox. It is a free, portable, and open source math environment that supports both matrix operations and symbolic manipulation.

It has a straightforward notebook page usage model, with results, plots, and graphics interspersed with the commands and equations that produce them. It is also extensible via Python for those so inclined.

An interesting alternative for some applications is Geogebra. It is an interactive geometry, algebra, and calculus application, intended for teachers and students.

Another interesting alternative to the well known tools is GSL Shell. This is a tool that wraps the Lua language around the Gnu Scientific Library. It supports a wide array of numeric methods on vectors and scalars. Being based on Lua, the syntax is distinctly different in flavor from the MATLAB inspired Octave or any of the tools based on Python. But that flavor might be to your liking.

share|improve this answer

The Julia language is an interesting up and coming numerical mathematics language that's been getting a lot of attention in recent months. It's sort of a mix of Matlab, R, and common Lisp.

share|improve this answer

A simple but quite functional alternative would be Genius. It has various numerical and plotting capabilities and a programming language (GEL).

share|improve this answer

Its already a feature of your terminal. Simply encapsulate your equation in $(( )) , for example ...

bash> echo $((1 + 1))
2

I only know this coz Im a programmer not a mathematician. :)

Have fun, Eugene.

share|improve this answer

freemat

FreeMat is a free environment for rapid engineering and scientific prototyping and data processing. It is similar to commercial systems

share|improve this answer

Take a look at PARI/GP. But it's rather specific.

share|improve this answer
1  
This has already been mentioned in Old John's answer. –  Rahul Aug 3 '12 at 21:35
    
Oops. My fault. Havn't noticed. –  Ximik Aug 3 '12 at 23:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.