Best Programming Languages for Math

When it comes to solving math problems, programming languages aren't always used by the average mathematician. They can be utilized for assistance, but it completely depends on the scope of the problem and whether or not there's even a need for a programming language in the first place.

The Best Programming Languages for Math

More often, the act of programming involves problem-solving in itself, where you then take your answers and apply them to build a program.

However, mathematicians sometimes require some programming languages for assistance, and some of the best programming languages for math work wonders when you're trying to hone your skills and train yourself in a particular mathematical field.

Therefore, keep reading to learn about the most popular programming languages for math, along with what's so special about them, and what makes them good for writing about and solving math problems.

MATLAB

MATLAB is a high-level computing environment from MathWorks. Its name is short for Matrix Laboratory. It was originally a system for solving matrices — quickly and accurately. But in its over three decades of existence, it has grown greatly to become a general environment for solving math, scientific, and engineering problems.

What Can MATLAB Do?

Although at its base, MATLAB is still a system for solving linear algebra problems, an enormous amount has been built on top of this. Here are just a couple of cool things from the MATLAB Examples pages:

  • Data Acquisition: by simply dragging and dropping components, it is possible to take data from a connected device, process it, and output it in a user friendly form.
  • Differentiation: using the Symbolic Math Toolbox, MATLAB can perform calculus and many other forms of mathematics.
  • RNA Structure: this is an application that predicts and displays the structure of RNA based on its sequence.
  • Face Detection: this is just one of many face detection algorithms. MATLAB is used especially widely in image processing.

How Does MATLAB Work?

MATLAB uses its own development environment. Most people simply work inside of it. It uses its own proprietary language. However, it can be used with external programs and functions in languages like C++ and Fortran. What's more, applications that you create inside of MATLAB can be output to the C programming language so that they can be included in outside programs.

Regardless of all the bells and whistles, however, MATLAB is still at base about linear algebra. It thinks in terms of matrices. And the MATLAB scripting language shows this.

Basic Concepts

MATLAB is weakly typed like Perl and JavaScript. So it figures out what simple variables are based upon how you use them. For example, if you tell it x = 15.7, it knows that x is a floating point number. On the other hand, if you tell it x = 'help' it knows that x is a string. If you start using numbers like strings or vise versa, then it will deal with them on the binary level, much like Perl.

You can manipulate variables the same way you can in any programming language. Similarly, strings are really arrays of characters and can be managed thusly.

Matrices

The real power of MATLAB is in its easy manipulation of matrices. A matrix is defined within square brackets with columns separated by spaces and rows by semicolons. Here is a simple example from the MATLAB documentation:


A = [1 1 0 0];
B = [1; 2; 3; 4];
C = A*B

The first line defines a 1-by-4 A matrix. The second line defines a 4-by-1 B matrix. By basic matrix algebra, we know that the result is: 1*1 + 1*2 + 0*3 + 0*4 = 3. Obviously, far more complicated calculations can be performed.

Toolboxes

In addition to all the mathematical tools that MATLAB offers, there are many additions to it. In particular, there are toolboxes. We've already mentioned the Symbolic Math Toolbox. But there are many others in various areas:

  • Parallel Computing
  • Math, Statistics, and Optimization
  • Control Systems
  • Signal Processing and Communications
  • Image Processing and Computer Vision
  • Test and Measurement
  • Computational Finance
  • Computational Biology

As you can see, the uses that MATLAB is put to are broad, and they provide specialized tools for all of them.

Getting MATLAB

MATLAB is a relatively expensive product. The price for the base program is over $2,000. Simulink is $3,000 extra. And toolboxes are $1,000 minimum, and often much more. Generally, people use MATLAB under two circumstances. First, it is used in academia a great deal. As a result, MathWorks offers student versions of MATLAB and Simulink for less than a hundred dollars.

The second way people normally get access to MATLAB is through their employers. MATLAB is so powerful that it is often easily worth its price.

Free MATLAB Alternatives

There is no free version of MATLAB. However, there are two free alternatives to it. These are both powerful tools that will at very least provide you with an easy way to get started in the right direction: GNU Octave and Scilab, both of which we will discuss below.

Learning MATLAB

There are a lot of online resources to help you learn MATLAB. But we recommend that you start with a book. What can ultimately be done with MATLAB is so vast that it is good to get a thorough overview of the subject.

Books

The following are all very good basic introductions to MATLAB.

Online Tutorials

Because of MATLAB's use at academic institutions, there are a lot of free tutorials that will get you started.

Other Online Resources

Here are a few resources for once you learn the basics of MATLAB:

Online Forums

MATLAB doesn't have the kind of user base that, say, C++ has. But there is still a very active community of coders. As always on forums, be aware that spam gets through. But all of these are solid forums.

  • MATLAB Answers: this is the MathWorks community forum where you can ask questions and look for answers.
  • MATLAB Subreddit: this is the very active MATLAB forum on Reddit. You might also find the math subreddit useful.
  • Stack Overflow: when it comes to just about anything computer related, Stack Overflow is the place. This link takes you to all the discussions that have been taged as having to do with MATLAB.
  • <dream.in.code> Other Languages: this is not specific to MATLAB, but it is very active with a lot of knowledgeable people around.
  • Drexel University Forum: this is the MATLAB section of their Math Forum. It's very active, but obviously with an academic bent.

MATLAB Summary

MATLAB is a high-level computing environment used throughout academia and in industries as varied as physics and finance. We've only touched on its capabilities here. With these resources, you can start learning the system. It could eventually take you just about anywhere.

GNU Octave

GNU Octave is a high-level programming environment for doing numerical calculations for science and engineering. It is the most obvious free alternative to MATLAB, because its programming language is compatible with it.

In addition to the base programming language, GNU Octave features a large set of tools for performing common numerical calculations. What's more, Octave can use functions written in C++ and Fortran.

The History of GNU Octave

GNU Octave was originally developed (starting around 1988) as an aid to teach college students about chemical reactor design. The designers were dissatisfied with using Fortran because their students were spending too much time debugging coding and thus not learning the subject. So they wanted an interactive tool.

GNU Octave was first released in alpha form at the beginning of 1993. The first official release (Version 1.0) came the following year. In May 2015, Version 4.0 of Octave was released. It has a full graphical user interface and is available on all major operating systems.

Features

GNU Octave is far more than an equation solver.

  • Matrices are utilized as a standard data type.
  • The use of complex numbers is supported.
  • It includes a large mathematics function library.
  • It includes file name, variable, and function completion.
  • Unlimited command undo is available.
  • There are various options for organizing data into structures.
  • It provides support for argument and return lists as well as short-circuit Boolean, decrement, and increment operators.

Online Resources

  • GNU Octave: the official website for the application. It includes download links to all major operating systems.
  • GNU Octave Reference: the complete documentation provided for the software. You can also download an 800 page PDF of the reference.
  • GNU Octave Wiki: this is similar to the documentation, but as a wiki it is constantly changing based on moderators and contributors.
  • Programming Differences between Octave and MATLAB: this article is part of the MATLAB Programming wikibook. It provides a good overview of the differences between these very similar products.

Books

  • GNU Octave Primer for Beginners (2016) by S Nakamura: this beginner guide has exercise problems and answers for running through the software. Chapters include topics such as commands, programming, branch statements, how to plot, bar charts, and much more.
  • GNU Octave Beginner's Guide (2011) by Jesper Schmidt Hansen: a good choice for visual learners. It's similar to the Nakamura book, but filled with more screenshots and step-by-step examples, making it perfect for the total beginner.
  • GNU Octave 4.0 Reference Manual: Free Your Numbers (2015) by Eaton, et al: for those who want the official reference in book form. Volume 1 starts with simple Octave examples and goes on to cover topics like the Java interface and packages. Volume 2 contains information on everything from creating permutation matrices to managing explicit and implicit conversions.
  • Foundation of Numerical Analysis: Implementation with GNU Octave/MATLAB (2016) by S Nakamura: this book covers areas like linear algebra, polynomials, polynomial interpolations, and numerical integrations.

Courses

Communities

  • Help-Octave: this is an active mailing list for contributing developers. But you can sign up for it if you'd like to send in your own thoughts or learn from the this very experience community.
  • Freenode Channel: if you're looking to chat with GNU Octave developers from all over the world, this is the place to do it. Freenode covers all sorts of categories, so you'll need to go to the #octave channel.
  • Google Plus: while this community isn't meant for direct support, it's good for finding out about updates and other news.

Should You Learn GNU Octave?

GNU Octave is not a complete replacement for MATLAB. But it is close. What's more, GNU Octave code is mostly MATLAB compatible. So moving from GNU Octave to MATLAB should be easy. If your future involves science or engineering, GNU Octave is a great tool to learn.

Scilab

Scilab is a software package for mathematical computing. Like Matlab, Excel, or GNU Octave, it is used for numeric computing. It includes hundreds of mathematical functions and provides a powerful computing environment for math, science, and engineering applications.

The beauty of the program is its open-source nature. It is released under the CeCILL license which means it can be downloaded, used, modified, and even re-distributed free of charge. On top of that, it can be installed on any computer running one of the operating systems GNU/Linux, Mac OS X, or Windows.

History

Scilab's origin dates back to the 1980s when a couple of researchers working at the French Institute for Research in Computer Science and Control (IRIA until 1979, then INRIA) developed Blaise, a CACSD (Computer Aided Control System Design) software application. François Delebecque and Serge Steer wanted to provide a tool in Automatic Control for researchers and thus Blaise was born.

In 1984, Blaise became Basile and was distributed for a few years by Simulog, the first INRIA startup.

This ended in the 1990s when Simulog stopped distributing Basile. The software was renamed Scilab and was further developed by INRIA within its own group.

1994 became a turning point when INRIA decided to release Scilab as open-source software. The original development group continued working on it until 2002.

At the beginning of 2003, INRIA created the Scilab Consortium to ensure its future, development, maintenance, and support.

Five years later, Scilab Consortium integrated into Digiteo, which continued working on the program. That also marked the year that Scilab became completely free software, distributed under the CeCILL license.

Finally, in 2010, Inria founded Scilab Enterprises as a means of guaranteeing the program's future. Since 2012, Scilab Enterprises is completely in charge of development. It also provides professional services and support.

Features

Scilab includes hundreds of mathematical functions. Since its matrix-oriented, you can perform matrix manipulations, 2D/3D plotting, create your own functions and libraries, and much more. It also provides its own dynamic systems modeler and simulator called Xcos.

Scilab:

  • Mathematics and Simulation: for engineering and scientific applications which include mathematical operations and data analysis.
  • 2D and 3D Visualization: visualize, annotate, and export data. Create and customize various types of plots and charts.
  • Optimization: algorithms for solving constrained and unconstrained continuous and discrete optimization problems.
  • Statistics: perform data analysis and modeling.
  • Control System Design and Analysis: standard algorithms and tools for control system study.
  • Signal Processing: visualize, analyze, and filter signals in time and frequency domains.
  • Application Development: increase the program's native functionalities and manage data exchanges with external tools.

Xcos:

  • Standard Palettes and Blocks
  • Model Building and Edition
  • Models Customization
  • Simulation.

Online Resources

Since Scilab is actively developed and maintained, there are plenty of resources available to get you started on the right foot. From the official website to thorough documentation, wiki, and an active community — you are bound to find a resource that best suits your learning methods.

  • Scilab: the official website for the program with download links, documentation, and access to professional help and support.
  • Wiki: a public wiki with information on documentation, examples of use, and installation/compilation instructions for specific platforms and operating systems.
  • Help: an online help system for the program's functions with use examples listed by modules.
  • Matlab/Scilab Dictionary: a very useful dictionary to compare it and Matlab and examples of use for each function.
  • YouTube Channel: with plenty of videos on the program's features and various applications of the software.
  • Tutorials: a number of tutorials are offered by partner website Openeering which range from beginner to more advanced topics.

Books

Various books have been published on Scilab in different languages. You can find books in English, French, German, Japanese, Chinese, and more. The books range from introductory topics to more specific and advanced topics of how it can be used.

  • Scilab from Theory to Practice (2016) by Roux, Mathieu, and Gomez: aimed at an audience of new users as well as at people who want to improve their knowledge of it. It's a comprehensive, hands-on introduction to the program and covers all the basic concepts you need for computing, analyzing, and visualizing data, developing algorithms, and creating models.
  • Scilab by Example (2012) by M Affouf: a short and easy to use introduction covering brief explanations of commands, programming, and graphing capabilities.
  • Engineering and Scientific Computing with Scilab (1999) by Gomez et al: best suited for those with a strong background in matrix and differential equation theory. It covers the program in-depth with thorough explanations of applications in linear algebra, polynomials, and more advanced subjects.
  • Simulation of ODE/PDE Models with MATLAB, OCTAVE and SCILAB (2014) by Wouwer, Saucez, and Fernández: this book is aimed at those experienced in the program and other numeric computation applications. It shows the reader how to exploit a fuller array of numerical methods for the analysis of complex scientific and engineering systems.

Courses

For those of you who prefer a more guided approach to learning, a couple of courses are available.

Community

Scilab has a very active community which includes a mailing list, an IRC channel, and a file exchange website. There are also communities active on various social media networks.

  • Google+ Group: a public group with more than 400 members discussing everything related to it.
  • Scilab and Xcos: a LinkedIn group dedicated to all the professionals who want to exchange information.

Summary

Scilab offers an excellent free alternative to Matlab and we just barely scratched the surface of what it can do. These resources will provide you with a great head start on mastering the software and the rest is up to you so go forth and learn!

Maxima

Maxima is a computer algebra system. But it is also a programming language: sort of a combination of ALGOL and Lisp. It is such an important piece of software that we've gone a little further here than just telling you about it.

Whether you're just getting to grips with it or you're furthering your studies in this subject, this epic list of Maxima resources is sure to help you on the way. From programming with Maxima to using its graphical interface, wxMaxima, you'll find everything you need to excel with this great resource here:

Maxima: Playing

Maxima Resources

  1. Acquiring, Installing, and Testing Maxima

    A handy guide that shows you how to acquire Maxima, the best ways of installing it, and how to start testing it once you've downloaded it. This detailed walkthrough should help you get started in no time at all. Furthermore, at the bottom, you can select a number of other tutorials that have been produced by Paul Lutus, including Creating Sets of Functions and Fourier Analysis.

  1. Maxima Manual

    Put together by the Maxima team, this manual (via the Wayback Machine) is a fantastic overview that'll prove incredibly useful when you start using Maxima. It also gives you a list of the capabilities and packages that are built into Maxima — but these are at the end of the 1,000-page document so you'll need to do plenty of scrolling to find them!

  1. An Introduction to Maxima (PDF)

    This resource has been put together by the people at Stanford University and features 245 online pages of information about all things Maxima. The guide includes step-by-step instructions along with handy pictures and example formulas.

  1. A Shorter Introduction to Maxima (PDF)

    If the above guide seems too large, Richard Rand from Cornell University has created a shorter, 14-page guide that's available to read online. It features a brief introduction to Maxima before moving on to explain writing programs/scripts/subroutines for Maxima.

  1. The Maxima Book (PDF)

    Another incredibly in-depth guide, this book was produced in February 2003 and provides you with a well-organized, comprehensive look at Maxima. Although it's not the most up-to-date guide you can read, it's still a valuable reference due to its comprehensiveness and easy-to-follow organization.

  1. Maxima by Example

    These tutorial-style notes were originally written by Edwin L Woollett, but have been updated by California State University (Long Beach) to include tips for working with Maxima software — which are particularly useful if you use Windows.

  1. A 10 Minute Tutorial for Solving Math Problems with Maxima

    If you want a quick introduction to Maxima or need to refresh some old studies, this 10-minute tutorial is ideal. It covers areas such as using Maxima as a calculator, constants and common functions, defining functions and variables, symbolic calculations, and much, much more.

Maxima: Dreaming
  1. Using Maxima's Symbolic Math Capabilities

    Here you'll find a table that develops the sophisticated use of Maxima as a symbolic math tool. This provides you with a great reference point you can keep referring to, finding the Maxima Input and Output required at each stage.

  1. Tensor Algebra in Maxima

    This resource demonstrates the three different ways you can look at tensors using Maxima and its add-on packages.

  1. Maxima and the Calculus

    You'll need to view this through the Wayback Machine, but once loaded, this PDF provides you with an introduction to the basics of Maxima before exploring precalculus, integration, vector calculus, graphing, programming, and a range of other topics.

  1. Mathematica/Maxima Conversion Chart

    Familiar with Mathematica? Then this conversion chart will help you understand Maxima quickly and efficiently.

Maxima: Playing
  1. Plotting Direction Fields for 1st Order ODEs

    This short tutorial delves into how you can get the "plotdf" function up and running in Maxima, using it for plotting direction trajectories/fields for 1st order ODEs.

  1. wxMaxima

    This is the homepage for a Windows GUI for Maxima. The document-based interface for Maxima provides you with dialogs and menus for many common inline plots, autocompletion, Maxima commands, and simple animations.

  1. wxMaxima for Calculus I and II

    These two guides introduce wxMaxima in relation to single variable calculus, with each book serving as a lab manual, a tutorial reference for students, or a source of CAS exercises.

Maxima: Doing
  1. The Computer Algebra Program Maxima — A Tutorial

    A great introduction into the world of Maxima (via Wayback Machine), this tutorial offers you some useful tips for your first steps with Maxima, before moving on to provide worked examples and advice on programming with Maxima. It also includes some content on the use of Lisp (the language Maxima is programmed in), with some interesting facts about Lisp added to this section, too.

  1. Minimal Maxima (PDF)

    Produced by Robert Dodier, this breaks down the data, evaluation, and syntactical structures underlying Maxima. Having an understanding of this is good when you're trying to use Maxima as more than just a powerful calculator — or when you're writing your own subroutines/functions in Maxima.

  1. 22 Sessions of Maxima for Solving Real-World Engineering Problems

    Again, you need to view this through the Internet Archive Wayback Machine, this is a reference that's still hailed by many math experts as a go-to guide. Initially run by Youngstown State University College of Engineering & Technology, it's perfect if you want to use Maxima for engineering-related issues.

Maxima: Graduating

Other Resources

This list of resources will provide students of maxima as well as professionals with all the information they need, whether they're looking for basic help with maxima or they're wanting to use advanced maxima techniques for programming. If you are looking for more resources, check out the following guides. You can never learn too much.

Mexima: Working

Maxima Conclusion

These resources will allow you to master Maxima — and more important — mathematics itself. Math is a more important skill today than ever. While in the past it was enough to know your multiplication tables and how to do long division, today's jobs require that you understand advanced mathematics and how to apply it to real-world problems. Maxima will help you to master these skills and solve those real-world problems.

Python

Python is sometimes considered a programming language meant for math, with a wide variety of users writing programs with Python's assistance. Mathematicians are rather fond of it for some interesting reasons. First of all, Python doesn't actually serve much of a mathematical purpose, but when it comes to general programming, Python shines. That general programming often includes mathematical programs, so it does eventually come in handy for the field.

Finally, some argue that the popularity of so many other programs and programming languages comes from the fact that they are based on Python. For example, Sage is based on Python and it's a wonderful solution for when you're addressing a problem from scratch.

Mathematica

Mathematica is another commercial program utilized by mathematicians on occasion. Although you'll have to pay to use it (it's not open-source,) Mathematica comes in handy when attempting things like plotting and symbolic measures.

Quite a few mathematicians will state that Mathematica is one of those programs best suited for checking an idea or verifying a thought. However, when it comes to writing something that's going to be professional, stable, and effective, they'd most likely go with another program.

R

R offers a comprehensive graphics toolset for designing and implementing beautiful imagery. The majority of the time, you're going to find that statisticians are the ones utilizing R for its incredible statistical computing power. R is an open-source programming language, which makes it even more appealing. Mathematical data miners are also known for using R because you can make all sorts of programs for running through data quickly and mining data without any extra work involved. Because of this, the popularity of R has increased quite a bit in recent years.

Mathematical data miners are also known for using R because you can make all sorts of programs for running through data quickly and mining data without any extra work involved. Because of this, the popularity of R has increased quite a bit in recent years.

Haskell

Haskell is a general programming language that has a wide range of uses, including mathematics. Category theorists like using Haskell. Similar to Mathematica, Haskell does the trick for checking out ideas as opposed to writing a completely new program. One of the main reasons Haskell stands strong among its alternatives is because it's a functional language, making it more natural for mathematicians to understand.

Another argument for Haskell is that more combinatorial problems with other programs like C and C++ can come out rather complicated. On the other hand, Haskell often delivers similar problems with one line.

Ruby

Ruby falls in a similar category as Haskell, allowing math students and mathematicians to prototype different types of code and make their own scripts. Mathematica also falls in this category, where both plotting and symbolic functions are required. The mathematical uses are somewhat limited with Ruby, but people use it all the time for general programming. That said, it does have a more powerful mathematical setup for many other languages.

The mathematical uses are somewhat limited with Ruby, but people use it all the time for general programming. That said, it does have a more powerful mathematical setup for many other languages.

PostScript

As a rather unique math program, PostScript probably won't come up in conversation if you ever ask a mathematician about Matlab alternatives. However, PostScript comes into play when you're trying to make mathematical illustrations in a more precise manner.

The average user would most likely consider PostScript a little too ugly to be used consistently, but it does offer elegant syntax, making it a fun and interesting solution for those who want to make illustrations and mathematical constructions. However, some other areas are lacking, such as handling strings and user interaction.

C

C and C++ provide multiple uses, so you're not only going to find these in the math field. In fact, they are more general in terms of programming, but they stand strong for mathematical programs.

Overall, C has a solid reputation when you're trying to get something done quickly. The processing speed is one of its best qualities, seeing as how many students are known to write small C programs in order to process repetitious problems.

Fortran

Fortran was the first widely used high-level programming language. And since most coders at that time were doing math and science, it was adopted early by them and is still widely used by scientists and mathematicians.

If you've had experience with Fortran in the past, you should prepare yourself for a shock. It's been continually updated over the years. The code is free floating (no manditory 7 spaces at the beginning of lines), it's object-oriented, and is largely interoperable with C. In other words, the oldest language is very new.

Lisp

There are some tools for advanced math in Lisp, but the main reason you'll find it used in the math field is because of its design. Mathematicians enjoy cleanliness and beauty in both math and design, so it makes sense for them to at least include Lisp in their toolbox.

Maple

Maple has a fairly strong advantage when it comes to combinatorial math problems. It's also known for its functional programming constructs, making it extremely interesting to play around with.

Plotting is a breeze when working with Maple, and advanced symbolic functions aren't bad either. Keep in mind that Maple, similar to that of Mathematica and Matlab, is a commercial program, meaning that you'll have to pay for it.

Choosing the Right Math Language

As you can see, the type of mathematics programming language you go with primarily depends on the problem, idea, or program you're trying to work on. For example, Matlab looks strong for symbolic computation, while R does the trick for statistics.

Overall, you're more likely to see mathematicians and students taking advantage of a handful of these programming languages. Best of luck making a decision!


What Code Should You Learn?

Confused about what programming language you should learn to code in? Check out our infographic, What Code Should You Learn? It not only discusses different aspects of the languages, it answers important questions such as, "How much money will I make programming Java for a living?"