Mathematica versus Sage

Quick version:  If you want to learn math get Mathematica.  If you have access to Mathematica use it.  If you have the money, buy it.  If you want to study mathematics, pray that your school provides it for free.  It’s wonderful.  If you don’t believe me watch these videos or look at the Wolfram Demonstrations Project.  I believe if every K-12 kid or college student was taught math with Mathematica far more of them would becomes scientists and engineers.  Unfortunately, Mathematica costs a lot of money.  If you don’t have the dough, consider Sage, the open source alternative.  But if there’s any way to get Mathematica, go that route.  If you can’t, let me tell you about Sage in a roundabout way.

When I was a kid I wanted to be an astronomer.  I even took astronomy and physics courses when I started college, but I hit a math wall – I finished Calculus I, but then stayed out several semesters.  When I returned to Calculus II, my math knowledge was gone.  This was partly due the distraction of girls and getting high, but I mostly blame myself for being lazy.  I didn’t have whatever it took to focus and work hard.  I’ve always wondered how my life would have been different if I had taken school more seriously when I was young, and applied myself.

Now forty years later I fantasize about testing my aging brain by studying math again.  Could I go back and relearn math, catch up to what I had learned, and go further?  It’s the old question:  Can an old dog learn new tricks?  My regrets about life involve two kinds.  First, all the real jobs I wanted, astronomer, computer scientist, robot engineer, etc. involved mastering math.  Second, my fantasy ambitions were about writing science fiction or popular science, and those involved intense verbal skills.  I think I failed at both because I’m lazy or I can’t focus deeply enough.  Now that I’m older, with fewer distractions in my life, I wonder if I could break through those barriers.

Kids today should have a better time of it because of technology.  If young grade school kids could start out learning with Mathematica it could give them a tremendous edge.  It might make the abstract and boring subject of mathematics real and alive.

One test of my old brain would be to study math again.  I eventually finished college and went into computer programming, but with office applications and databases, not with computer science concepts.  I’ve wondered if I could take my computer programming skills and apply them to learning math.  Could programming a math problem teach me to understand how math works?

Searching the web, I looked for people who had already tried this, but what I thought of as an obvious match made in heaven doesn’t bring up many hits.  Then I found “Mathematical Software and Me: A Very Personal Recollection” by William Stein.  Sage is system for using dozens of mathematical programs that have evolved on Unix/Linux OS over the years and tying them together with a Web 2.0 front end and using the programming language Python as the underlying user input language.  It’s a free, open source alternative to Mathematica and similar expensive commercial programs.  From reading many blogs I had already decided that Python was probably the best programming language to use with learning math, so Sage intrigued me.

When I started out on this project I imagined myself finding a beginning math book, maybe just a 7th grade algebra book and seeing if I could write Python programs to do the problems.  But there’s another kind of problem – math has its own language and character set of symbols.   Programs like Sage and Mathematica have to create a way to enter formulas without using the traditional symbols of math.  Imagine putting this formula into code:


If I just used plain Python I’d have to develop my own subroutines of conversion and I didn’t want to do that.  Also, there is the problem of binary to decimal accuracy.  Often computer programs will produce 3.99999999 when I need 4.000.  Programs like Sage and Mathematic have already solved those problems with custom formula editors and built in subroutines that are time tested.  They created programming conventions for entering mathematical formula and subprograms to show that code with standard mathematical symbols.  Think of word processing for mathematicians.

What’s the difference between Mathematica and Sage?  For some people it’s thousands of dollars.  Sage has the goal of providing a free and open source alternative to the commercial Mathematica.  Since I work at a university I have access to Mathematica, and thus I’m offered a choice.  It’s an odd choice too!  Mathematica is gorgeous, elegant, refined and advanced.  Mathematica is like being at NASA with state of the art tools.  Sage is like a poor garage inventor who has to buy their own.

If I would retire from the university I would no longer have access to Mathematica.  Also, if I develop something cool and wanted to share it, with Sage I could, but if I used Mathematica, I could only share notebooks with other Mathematica users.  Mathematica is a black box, users don’t know how the results are calculated.  With Sage you can look at the source code.

Sage seems like an obvious choice, doesn’t it.  Well, there’s one huge stumbling block, you need Unix/Linux to run it – there’s no native Windows application.

Now anybody can go to the free online version of Sage called The Sage Notebook, create an account and start using it for free.  A lot of people do, and that’s the problem, sometimes processing is iffy because of demand.  Next in ease of use, is to get a Live boot CD with Sage installed on it.  Just put it in a PC, reboot and make sure the CD is the first drive to boot – this bypasses Windows on your hard drive and boots Linux instead, leaving Windows untouched.  This is a great solution so long as you don’t really get into Sage heavily.

If you happen to already use Linux or Mac OS X, you can get binaries to install on your machine, but that still leaves out all those Windows users.  The way to actually run Sage in Windows is to install a virtual machine on your Windows PC.  Currently the Sage docs recommend VirtualBox, but that solution seems to be on the way out, and you need to use the free VMWare Player because at the Sage mirrors all they offer is the sage-vmware distributions.

Sage constructed a VMware distribution that you can load directly and run – no installing Ubuntu and Sage in steps.  The VMware distro has been pre-customized with all the Sage utilities.  This works very slick.  You can run Sage from within the virtual machine, or get it running as a server app, minimize the VMware window and call Sage from your Windows browser (the Sage notebook is just a Web 2.0 app.).

I’ve used all four different methods, online, LiveCD, Linux box, and Windows with VMWare.  All work.  Depending on how heavy duty your math processing needs are, will determine which version you want.  However, you have to get used to using a program that’s running other programs under Linux, and that can be tricky.  If you are a math teacher and want to use Sage with your students you’ll want to set up a Linux box that has some horsepower and then run Sage as a server app to Windows and Mac machines in your lab.

If Mathematica was free like Sage, I’d just recommend everyone use it.  It’s much easier to set up and far more consistent in its use.  It’s a shame that Mathematica isn’t given to every K-12 and college kid in the world. Mathematica would be a fantastic teaching platform, but it’s just so damn expensive.  But if little kids were taught to use Mathematica (or Sage) when they got their first math lessons a far greater percentage of the population would think mathematically.

What William Stein offers is a free alternative to Mathematica.  It requires a bit more work and knowledge to set up and use.  In fact, its Unix/Linux origins will turn off most users, so I’d recommend to math teachers to set up a Sage server and just get the kids used to Sage Notebook online.

Sage doesn’t teach math.  Mathematica and Sage are like the ultimate graphing math calculator, but with the notebook feature, it can record and animate math and statistics.  To see the potential of Sage see “Exploring Mathematics with Sage” by P. Lutus, especially the pages that start with “Trapezoidal Storage Tanks.”  This is fairly advanced math, but it illustrates what math teachers could require of their students.  Set up a problem, illustrate how to break it down mathematically, and then show the formula working with Sage.

You can visit the Sage Notebook site where users have saved and posted their notebooks online for all to see.  Studying these notebooks show the diverse way mathematics is applied to many problems.  This is the language of math, science and engineering.  I’d like to think if I had access to Sage when I was in grade school my life would have been significantly different.

Like I said, it would be best if Mathematica was given to all kids.  If that isn’t practical, I would recommend trying Sage.

JWH – 8/1/10

34 thoughts on “Mathematica versus Sage”

  1. I think online math tutoring is a great help for the students. Since, the time has changed, the way of teaching too. Nowadays students are more internet-savvy and so inclined to online tutoring services. They like online tutors as they provide 1-to-1 tutoring to the students. Online tutoring is pocket-friendly too!

    1. It’s good to see a comparison of Sage vs Mathematica, but your article seems to spend an excessive amount of time considering platform availability. Given the time you spend on that issue, at least the fact these systems all run on Solaris was worth mentioning, and in fact Sage still runs on Solaris, where Mathematica 8 does not. But I agree the lack of decent support on Windows for Sage is a big issue, but that should be addressed in 2011 – there are only a few remaining issues to solve.

      However, the rest of the article does not seem to offer a useful comparison. I’ve been a Mathematica user since 1989 and a Sage developer since 2005, so know both systems reasonably well, though are not an expert in either.

      So lets be a bit more objective.

      Let’s consider is the programming language. Learn Sage and you learn Python, which is a popular language used in many projects. There are tons of jobs wanting Python programmers.

      Now consider the time you could spend learning Mathematica. Is it so useful? I suggest you search a web site like and you will see very few if any jobs wanting Mathematica skills. Sure Mathematica is common in university, but employers don’t seem to want it.

      For students to learn Mathematica seems almost a waste of time to me, as its use outside academia is close to zero. I know Wolfram Reserach claim differently, but personal experience and a distinct lack of jobs wanting Mathematica leads me to believe it’s not a useful language to know.

      Let’s now consider some other points you wrote.

      What does this mean?

      “Often computer programs will produce 3.99999999 when I need 4.000. Programs like Sage and Mathematic have already solved those problems with custom formula editors and built in subroutines that are time tested. ”

      I’m puzzled what you are saying here. Do you think Mathematica or Sage has some magic which solves numerical rounding issues? Both can do arbitrary precision arithmetic, but what this as to do with “custom formula editors” I really don’t know. Neither has a perfect solution to rounding errors.

      If you expect to get 4 instead of 3.99999999, then *maybe* you can use integer arithmetic rather than floating point. But that depends on the problem. Both Mathematica and Sage do this. But you said 4.000, which is floating point, so you will never solve this issue completely, despite you seem to think both packages have solved it.

      I would agree Mathematica is more polished than Sage.

      As someone else pointed out, each have their strengths in their own areas.

      The lack of access to the code in Mathematica is a big problem, unless you simply want to trust Mathematica, which is seems you do, but I warn you against this too much. I personally find the fact Wolfram Research know of bugs in Mathematica, which could screw up someones work, but keep them secret, to be almost unethical. Even if they fix the bug, it would be good if they made people aware that a previous version had a bug, which might mean results should be reevaluated.

      I used Mathematica during my PhD. It would be nice if there was a bug in some function that I was at least made aware of it, so I could check if a result was wrong. If so, I’d stick an errata on the web.

      Let’s take a specific issue. Mathematica has a RandomPrime[] function, which is much faster than the default algorithm in Sage for generating a random prime number. This seems odd, so I contacted Wolfram Research about this matter, as I could not understand how Mathematica could be so fast IF it done the job properly. After some discussions with Wolfram Reserach, and me using Mathematica’s Trace[] command, I ascertained that RandomPrime[] calls PrimeQ[] to see if the number if prime or not. But PrimeQ[] is only guaranteed to be right for numbers to 10^16, which is documented. But the fact RandomPrime[] is therefore only guaranteed to be right for numbers to 10^16 is not documented. This is supposedly going to be addressed (support number TS 39681), but has not been, despite I was told 3 months ago it would be.

      Now consider what happens if your research depended on RandomPrime[]. Wolfram Research will not publish details about this bug, so you will never know about it (unless you read this blog now!).

      Let’s now consider what happens if a bug is found in Sage IIf a Sage bug is found, it will be posted on for anyone to see. If your research was affected by that bug, you would be able to consider its implications. If a fix is found you could upgrade, or if a fix is not found, you know the issue remains.

      It seems to me you spent a huge amount of the article devoted to this platform support, while overlooking Solaris, yet fail to address more serious issues.


      1. PS, Sage has a function random_prime(). Using it’s default algorithm, which is guaranteed to be right, it is slower than Mathematica as I stated. If you don’t need to 100% sure, then a pseudo-prime test is faster than the one in Mathematica.

      2. Sorry my blog post didn’t go into comparing the two programs in detail but I was only writing about my initial reaction to discovering the two programs. The point about the rounding error was in regards to writing my own programs which would have to take account of a lot of little problems like that.

        I overlooked Solaris because I don’t have Solaris, and neither do 99.9% of computer users, and now that Oracle has screwed things up for Sun products, I think even fewer people will have access to it. I think you misunderstand my position. I’m a guy that doesn’t know math but is thinking about studying it again as a hobby. I wrote about Sage because I thought it was very cool. And I suggested that if kids had access to Sage or Mathematica it might help them to learn math. I wasn’t concerned with careers after college.

        Also, I just liked discovering Sage and its history, so I wanted other people to read about it. My focus on platforms was to help people try Sage. I don’t think the average kid taking math will have the skills to set up Linux.

  2. Some years ago, I took an introductory calculus course from a major university, by correspondence, almost twenty years after my last math class as a junior in high school. That was quite an experience! I couldn’t remember even the simplest stuff. And I’d developed test anxiety in the intervening years, something I’d never known before.

    As it turned out, I did surprisingly well, but I don’t think I’ve ever worked harder in a class. And today, I don’t remember any of it! I just took the class because I needed five credit hours. Heh, heh. Maybe there would have been an easier way to get them…

    My biggest problem in college was that EVERYTHING sounded interesting, so I just took a variety of classes. And everything STILL sounds interesting. I’ve never been particularly fond of math, but yes, those programs do sound interesting, Jim. Luckily, there’s no way I have the time for something like that.

  3. What kind of math are you interested in learning? It sounds like you are aiming for the kind of advanced calculus required by physics and astrophysics. On the other hand, with your computer background, theoretical computer science might be easier and no less interesting. Let me know if I can help you as a guide in the math country…

    1. Actually Ignacio, I have no idea what I want. I’m just flipping through math books. I’d love to look at any suggestions you might have for me.

      I bought a 24 part video lecture called The Power of Mathematical Thinking, which I started last night. It’s described here:

      At work we’re having trouble getting SPSS and SAS for people because of money and other restrictions so I started reading about R. I installed it on my computer at work and I’m trying to figure out how to give it a test drive. It’s been forty years since I’ve taken a statistics course. I find it fascinating just to read about how various disciplines use different software packages to solve problems. What programs do you use in your work?

      I’m also watching “The Universe” on DVD, a documentary from The History Channel. Last night I watched a fabulous episode called “Beyond the Big Bang” which surveyed the complete history of cosmology. I was intrigued about Kepler and how he made his calculations. The show said he had a tremendous wealth of observational data to work with, but didn’t go into detail. What data did he collect and how did he convert it into mathematics? I assume they knew the time it took for each planet to get back to a starting point, but would they have had any idea of about distances?


  4. James, thank you for the review. It would, however, be more useful if it discussed how Sage compared to Mathematica operationally, not just what platforms they ran on.

    With your experience, does Sage give up functionality to Mathematica or is it just less polished?

    1. I’m just starting with both of these programs, so I can’t answer your questions yet. Mathematica appears to be far more sophisticated and polished, and it’s one consistent system. There really is no comparison. Mathematica is worth the thousands of dollars it costs if you need it and can afford it. If you can’t, start with Sage.

      Sage is really a Web 2.0 front end to many older Unix mathematical programs, each working a bit different. Actually, I’ve been sidetrack by R, the statistical program, which can run on its own, or through the Sage front end. Luckily, R has a very nice Windows binary, so I’m working with it directly instead of through Sage. I’m a Windows person and not a Linux person, and having a Windows app makes a big difference.

      I guess what I’m saying is if you can’t afford Mathematica, SAS, SPSS, Matlab, Maple, etc., there are free alternatives to try.

      The thing is you can play with Sage immediately, but unless you have a university or job that provides Mathematica, it’s very hard to get a copy without spending a lot of money. Mathematica has recently started offering a home edition for $295 for folks who claim they will not use it professionally. They also provide a free demo. At the beginning level Sage’s notebook seems a lot like Mathematica’s notebook. So why not start with Sage and see how far you get. If you really get into Sage and actually use it, then consider trying the free Mathematica demo to see if you want to spend $295. I have a feeling if you start with Mathematica you’ll get hooked and have to spend the money.

    1. Sorry. The videos are on the Mathematica site. And they require Flash. I just checked and the links are still working. Try installing the latest Flash, or use another computer. They are impressive videos.

  5. I at the age of 67,a silver medal holder for 100% in Math in high school final govt exam fr chennai/madras india in 1959,year perhaps prof.wolfram was born.

    I thank my sweet nephew,very brilliant srini/chellammi,an IIT chennai/ madras india mech engg graduate,now an usa citizen showed this website to I know difference between mathematica & sage.

    thanks for this wonderful site.
    miracles do happen!! one day r night I might also go to sage for math application.

    asian indian math joke:math professor said “whenever I say sigma,I remember my wife padma!!!”

  6. I,sundarrajan balaji, in this post on September 28, 2010 at 6:34 am Said:

    “I thank my sweet nephew,very brilliant srini/chellammi,an IIT chennai/ madras india mech engg graduate,now an usa citizen showed this website to I know difference between mathematica & sage.”
    as it is wrong about my mentioning name without permission,I request u to withdraw this writing para from my posting & oblige.I regret my error.

  7. I don’t agree that Mathematica has such an abysmal quality difference over Sage. I think there are some areas where one is better than the other. Mathematica is a lot better than Sage in symbolic math (integration, symbolic differential equations, etc.). But Sage is a lot more advanced in other fields such as number theory, combinatorics, and moderately better at numerical analysis.

    The state of advancement of Sage is a reflection of the interests of it’s developers (most are mathematicians and some are physicists).

    Also, there is an ongoing effort to bring Sage to Windows. It should not be too far from being ready now.

    1. This is excellent information to know. Remember, I’m not an expert in mathematics, but just a guy trying to relearn the math he hasn’t used in over forty years. All those areas where you say Sage is better are virgin territories for me. I was saying Mathematics is superior for newbies to set up and start using, as well has having a dazzling interface. Sage is a front end for calling separate programs in Unix/Linux that handle a wide spectrum of mathematical functions. These are open source programs developed by academics and they vary greatly in quality of application, but I don’t think there is any question about their quality of mathematics. Sage wins hands down when it comes to price. I still think it’s a shame that Mathematica isn’t cheap enough to be commonly used in K-12 schools.

  8. I’ve been a Mathematica user for several years, but just became interested in learning Sage. Just installed it, in fact. Two main reasons:
    (1) ease of python integration (and object orientation)
    (2) tab-completion instant help for functions

  9. No one has yet mentioned speed or memory use here. I find Mathematica’s poor speed performance and its need for vast quantities of RAM can be a significant problem when writing and running my own Mathematica programs.

    I have been using Mathematica rather than some other computer language because it seems to be more elegant and powerful. However, when the speed and memory issues comes up, none of that seems quite so important. If you can’t finish a calculation before next Tuesday, all the elegance in the world will not help.

    Since I am just starting with Sage/Python, I don’t yet know whether it will turn out to be faster than Mathematica, or whether it uses less memory. Has anyone compared those aspects of the two packages?

    1. Speed isn’t a problem with me because I’m just playing around with these programs and not doing real math. I wish I could. What kind of problems are you working on Ralph, that’s slowing down the system?

      1. I have been looking at the “hat puzzle”

        automatically trying a lot of strategies — actually 1,046,547 of them. From one point of view, it is impressive that Mathematica can arrange and perform that many trials, even if it does take about six minutes per run. But in practice, I would like it to be faster, so I can do more experiments per hour, so to speak. I am thinking about recoding that particular program in c or c++. Because Mathematica’s programming language can do a lot on each line, and because my program is complicated, it surely will not be fun to rewrite it. Here is a sample from my code, sort of the “main loop,” although, as you can see, it does not do any explicit looping. Of course Mathematica is doing a lot of looping to run this!

        talgr =
        ruleList[ruleNum23, ruleNum31, ruleNum12],
        hatList[hat1, hat2, hat3],
        tripleResponse[ruleList[ruleNum23, ruleNum31, ruleNum12],
        hatList[hat1, hat2, hat3]]
        {ruleNum23, lenrA},
        {ruleNum31, lenrA},
        {ruleNum12, lenrA},
        {hat1, {red, blue}},
        {hat2, {red, blue}},
        {hat3, {red, blue}}
        ](* Map *)

        The above takes about six minutes on my Intel Mac Mini. I am hoping that will become just a few seconds in c or c++.


  10. Though a bit late…

    Python has iPython notebooks, which work out-of-the-box with Python(x,y) on Windows. The advantage is, that the notebook server can be run in any directory, so integrating ipython notebooks into the filesystem seems easier compared to Sage notebooks (that are on a server).

    In order to convenient functionality through pylab with plots being displayed inline in the browser window (and stored in the notebook) it has to be run as

    ipython notebook –pylab=inline

  11. FYI. If you’re looking to use Mathematica syntax on an open-source frame, you may want to try Mathics ( I’ve not put it through its paces, but it is free. And should suffice if you;re trying to work your way through some standard university math texts.

    I’ve used Mathics to work through some thorny Differential Equations. And its vector operations seem solid. So, in short, for undergrad math for engineering, this freebie should suffice, and allow you to follow along with any text that employs examples in Mathematica.

    That said, I prefer Sage’s syntax to Mathematica’s. Perhaps it’s because I completed college in the late 90’s, before the widespread use of Computer Algebra Systems. And, since I do a bit of coding to simplify my life, just find that Sage feels more like a computer language. And thus I find it easier to figure out how to “tell Sage what I want.”

  12. Have you noticed Wolfram is giving away Mathematica on the Raspberry Pi? There it is, for all K-12 kids and college students, for as little as it costs to buy a Pi.

    1. Yes, I did. I should have updated my article. I thought about buying a Raspberry Pi just to play with Mathematica. However, if you read their press release, the free version doesn’t do all the beautiful graphical output because the Pi isn’t powerful enough for that kind of graphics. Or it does, but it’s very slow.

Leave a Reply to Vagif Verdi Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Where one line can make a difference.

Engaging With Aging

As long as we're green, we're growing

A Deep Look by Dave Hook

Thoughts, ramblings and ruminations


A story a day keeps the boredom away: SF and Fantasy story reviews


Pluralism and Individuation in a World of Becoming

the sinister science

sf & critical theory join forces to destroy the present

Short Story Magic Tricks

breaking down why great fiction is great

Xeno Swarm

Multiple Estrangements in Philosophy and Science Fiction

fiction review

(mostly) short reviews of (mostly) short fiction

A Just Recompense

I'm Writing and I Can't Shut Up

Universes of the Mind

A celebration of stories that, while they may have been invented, are still true

Iconic Photos

Famous, Infamous and Iconic Photos

Make Lists, Not War

The Meta-Lists Website

From Earth to the Stars

The Asimov's Science Fiction Magazine Author & Editor Blog

SFF Reviews

Short Reviews of Short SFF

Featured Futures

classic science fiction and more

Sable Aradia, Priestess & Witch

Witchcraft, Magick, Paganism & Metaphysical Matters

Pulp and old Magazines

Pulp and old Magazines

Matthew Wright

Science, writing, reason and stuff

My Colourful Life

Because Life is Colourful

The Astounding Analog Companion

The official Analog Science Fiction and Fact blog.

What's Nonfiction?

Where is your nonfiction section please.

A Commonplace for the Uncommon

Books I want to remember - and why

a rambling collective

Short Fiction by Nicola Humphreys

The Real SciBlog

Articles about riveting topics in science

West Hunter

Omnes vulnerant, ultima necat

The Subway Test

Joe Pitkin's stories, queries, and quibbles regarding the human, the inhuman, the humanesque.

SuchFriends Blog

'...and say my glory was I had such friends.' --- WB Yeats

Neither Kings nor Americans

Reading the American tradition from an anarchist perspective


Speculations on the Future: Science, Technology and Society

I can't believe it!

Problems of today, Ideas for tomorrow


Peter Webscott's travel and photography blog

The Wonderful World of Cinema

Where classic films are very much alive! It's Wonderful!

The Case for Global Film

'in the picture': Films from everywhere and every era

A Sky of Books and Movies

Books & movies, art and thoughts.

Emily Munro

Spinning Tales in the Big Apple


hold a mirror up to life.....are there layers you can see?

%d bloggers like this: