A 10 minute tutorial for solving Math problems with Maxima

About 50,000 people read my article 3 awesome free Math programs. Chances are that at least some of them downloaded and installed Maxima. If you are one of them but are not acquainted with CAS (Computer Algebra System) software, Maxima may appear very complicated and difficult to use, even for the resolution of simple high school or calculus problems. This doesn’t have to be the case though, whether you are looking for more math resources to use in your career or a student in an online bachelor’s degree in math looking for homework help, Maxima is very friendly and this 10 minute tutorial will get you started right away. Once you’ve got the first steps down, you can always look up the specific function that you need, or learn more from Maxima’s official manual. Alternatively, you can use the question mark followed by a string to obtain in-line documentation (e.g. ? integrate). This tutorial takes a practical approach, where simple examples are given to show you how to compute common tasks. Of course this is just the tip of the iceberg. Maxima is so much more than this, but scratching even just the surface should be enough to get you going. In the end you are only investing 10 minutes.

Maxima as a calculator

You can use Maxima as a fast and reliable calculator whose precision is arbitrary within the limits of your PC’s hardware. Maxima expects you to enter one or more commands and expressions separated by a semicolon character (;), just like you would do in many programming languages.

(%i1) 9+7;
(%o1) 16
(%i2) -17*19;
(%o2) -323
(%i3) 10/2;
(%o3) 5

Maxima allows you to refer to the latest result through the % character, and to any previous input or output by its respective prompted %i (input) or %o (output). For example:

(%i4) % - 10;
(%o4) -5
(%i5) %o1 * 3;
(%o5) 48

For the sake of simplicity, from now on we will omit the numbered input and output prompts produced by Maxima’s console, and indicate the output with a => sign. When the numerator and denominator are both integers, a reduced fraction or an integer value is returned. These can be evaluated in floating point by using the float function (or bfloat for big floating point numbers):

=> 4
=> 4.0
=> \displaystyle \frac{1}{3}
=> 0.33333333333333
=> 0.33333333333333
=> \displaystyle \frac{13}{2}
=> 6.5

As mentioned above, big numbers are not an issue:

=> 91733330193268616658399616009
=> \displaystyle 9.1733330193268623\text{ }10^_{+28}
=> 265252859812191058636308480000000
=> \displaystyle 7.5715969098311943\text{ }10^_{+12}

Constants and common functions

Here is a list of common constants in Maxima, which you should be aware of:

  • %e – Euler’s Number
  • %pi – \displaystyle \pi
  • %phi – the golden mean (\displaystyle \frac{1+\sqrt{5}}{2})
  • %i – the imaginary unit (\displaystyle \sqrt{-1})
  • inf – real positive infinity (\infty)
  • minf – real minus infinity (-\infty)
  • infinity – complex infinity

We can use some of these along with common functions:

sin(%pi/2) + cos(%pi/3);
=> \displaystyle \frac{3}{2}
tan(%pi/3) * cot(%pi/3);
=> 1
float(sec(%pi/3) + csc(%pi/3));
=> 3.154700538379252
=> 9
=> 1

Defining functions and variables

Variables can be assigned through a colon ‘:’ and functions through ‘:=’. The following code shows how to use them:

a:7; b:8;
=> 7
=> 8
=> \sqrt{113}
f(x):= x^2 -x + 1;
=> x^2 -x + 1
=> 7
=> 43
=> 57

Please note that Maxima only offers the natural logarithm function log. log10 is not available by default but you can define it yourself as shown below:

log10(x):= log(x)/log(10);
=> \displaystyle log10(x):=\frac{log(x)}{log(10)};
=> 1

Symbolic Calculations

factor enables us to find the prime factorization of a number:

=> \displaystyle 2^{26}\,3^{14}\,5^7\,7^4\,11^2\,13^2\,17\,19\,23\,29

We can also factor polynomials:

factor(x^2 + x -6);
=> (x-2)(x+3)

And expand them:

=> \displaystyle x^4+12\,x^3+54\,x^2+108\,x+81

Simplify rational expressions:

=> x-1

And simplify trigonometric expressions:

trigsimp(2*cos(x)^2 + sin(x)^2);
=> \displaystyle \cos ^2x+1

Similarly, we can expand trigonometric expressions:

=> \displaystyle -\sin ^2x+2\,\cos x\,\sin x+\cos ^2x

Please note that Maxima won’t accept 2x as a product, it requires you to explicitly specify 2*x. If you wish to obtain the TeX representation of a given expression, you can use the tex function:

=> $$-\sin ^2x+2\,\cos x\,\sin x+\cos ^2x$$

Solving Equations and Systems

We can easily solve equations and systems of equations through the function solve:

=> \displaystyle \left[ x=-2 , x=2 \right]
=> x=2
=> \displaystyle \left[ x={{\sqrt{3}\,i-1}\over{2}} , x=-{{\sqrt{3}\,i+1}\over{2}}  , x=1 \right]
trigsimp(solve([cos(x)^2-x=2-sin(x)^2], [x]));
=> \displaystyle \left[ x=-1 \right]
solve([x - 2*y = 14,  x + 3*y = 9],[x,y]);
=> \left[ \left[ x=12 , y=-1 \right]  \right]

2D and 3D Plotting

Maxima enables us to plot 2D and 3D graphics, and even multiple functions in the same chart. The functions plot2d and plot3d are quite straightforward as you can see below. The second (and in the case of plot3d, the third) parameter, is just the range of values for x (and y) that define what portion of the chart gets plotted.



plot2d([x^2, x^3, x^4 -x +1] ,[x,-10,10]);


f(x,y):= sin(x) + cos(y);
plot3d(f(x,y), [x,-5,5], [y,-5,5]);



=> %e
=> 1
=> 8
=> -\infty
=> -\infty


diff(sin(x), x);
=> \displaystyle cos(x)
diff(x^x, x);
=> \displaystyle x^{x}\,\left(\log x+1\right)

We can calculate higher order derivatives by passing the order as an optional number to the diff function:

diff(tan(x), x, 4);
=> \displaystyle 8\,\sec ^2x\,\tan ^3x+16\,\sec ^4x\,\tan x


Maxima offers several types of integration. To symbolically solve indefinite integrals use integrate:

integrate(1/x, x);
=> \displaystyle log(x)

For definite integration, just specify the limits of integrations as the two last parameters:

integrate(x+2/(x -3), x, 0,1);
=> \displaystyle -2\,\log 3+2\,\log 2+{{1}\over{2}}
=> \sqrt{\% pi}

If the function integrate is unable to calculate an integral, you can do a numerical approximation through one of the methods available (e.g. romberg):

romberg(cos(sin(x+1)), x, 0, 1);
=> 0.57591750059682

Sums and Products

sum and product are two functions for summation and product calculation. The simpsum option simplifies the sum whenever possible. Notice how the product can be use to define your own version of the factorial function as well.

sum(k, k, 1, n);
=> \displaystyle \sum_{k=1}^{n}{k}
sum(k, k, 1, n), simpsum;
=> \displaystyle {{n^2+n}\over{2}}
sum(1/k^4, k, 1, inf), simpsum;
=> \displaystyle {{\%pi^{4}}\over{90}}
fact(n):=product(k, k, 1, n);
=> fact(n):=product(k,k,1,n)
=>  3628800

Series Expansions

Series expansions can be calculated through the taylor method (the last parameter specifies the depth), or through the method powerseries:

niceindices(powerseries(%e^x, x, 0));
=> \displaystyle \sum_{i=0}^{\infty }{{{x^{i}}\over{i!}}}
taylor(%e^x, x, 0, 5);
=> \displaystyle 1+x+{{x^2}\over{2}}+{{x^3}\over{6}}+{{x^4}\over{24}}+{{x^5}\over{120 }}+\cdots

The trunc method along with plot2d is used when taylor’s output needs to be plotted (to deal with the +\cdots in taylor’s output):

plot2d([trunc(%), %e^x], [x,-5,5]);


I hope you’ll find this useful and that it will help you get started with Maxima. CAS can be powerful tools and if you are willing to learn how to use them properly, you will soon discover that it was time well invested.

Sponsor’s message: Math Better Explained is an insightful ebook and screencast series that will help you deeply understand fundamental mathematical concepts, and see math in a new light. Get it here.

If you enjoyed this post, then make sure you subscribe
to our Newsletter and/or RSS Feed.

132 Responses to “A 10 minute tutorial for solving Math problems with Maxima”

  1. Josh says:

    This is awesome. Awesome! Thank you.

    – Josh

  2. Will says:

    Cool beans. Very nice write-up.

  3. bastianazzo says:

    nice infos, in my opinion these kind of software should be much more supported by universities, instead of (implicitly) encouraging the use of pirated software…
    thanks! I was just trying to improve my Maxima skills…

    ciao ciao!

  4. Beni says:

    Thank you. Very useful intro.

  5. dzer0 says:

    Wow. Looks awesome. The thing that REALLY sealed the deal was the TeX output. Love it.

  6. [...] A 10 minute tutorial for solving Math problems with Maxima (tags: math tutorial) [...]

  7. [...] A 10 minute tutorial for solving Math problems with Maxima (tags: math lisp tutorial) [...]

  8. [...] Link Original: A 10 minute tutorial for solving Math problems with Maxima [...]

  9. Sexy Girl says:

    Great software. Great for my high school subject.

  10. Bogititus says:

    this was NOT a guide for high school calc…

    it’s a great, vague, manual snapshot


    a guide would have a scan from a high school calc book, and STEPS with screenshots

  11. A 10 minute tutorial for solving Math problems with Maxima(10 分鐘學會使用Maxima)

    3 Awesome Math Programs(3個超棒的數學繪圖程式)
    圖片和解釋都說得很詳盡(想當初用Mathematica用到快起肖= =&#82…

  12. man, where was all this cool free math software when I was stuck using maple on mac plus? argh!

  13. budlight says:

    probably a good thing that it “appears” difficult as it’d a shame for highschoolers to simply use it instead of learning basic algebra.

  14. unikuser says:

    This is awesome little tool. Wish I knew about this in my school.

  15. Birch Leafminer says:

    I have been using Maxima as I re-learn Algebra. I use it it verify what I do by hand, but sometimes I would like to see some of the intermediate steps. Is there any way to do that?

  16. Ian says:

    How the hell do you translate these formulas to be used in software programs like javascript and actionscript?

    Could you possibly create a tutorial on what all the symbols mean?

  17. rwinston says:

    Excellent write-up. How did you get the LaTeX output on the fly? The presentation looks great!

  18. Will says:

    The fancy calculus stuff doesn’t translate. Most of the basic functions (sin, sqrt, log, etc) are available as Math.sin() and whatnot. Google for “javascript math” to get a full list of Javascript’s math functions and constants.

  19. Antonio says:


    Thank you very much. I used a LaTeX plugin for WordPress, and I wrote the TeX code for simple cases and Maxima’s tex(expr) function for the longer ones.

  20. easan says:

    great job ! do u know of a similar tutorial for R ?

  21. Antonio says:


    Thanks a lot easan. For R, take a look at this tutorial:

  22. DaedriX says:

    This is really cool, sadly the school year is now over and I can’t use it!!! fdasdafhasdkj! GRRR!

  23. Machuidel says:

    Maxima has its roots in Macsyma which existed before Mathematica and Maple.

    See the following article about Macsyma:

    I’ve recommended Maxima to many people. Most of these people rejected it and did not even bother to look it up because they never heard of the name or believe free software cannot be of good quality.

    I would like to see a side-to-side comparison between Maxima and the commercial alternatives. I can imagine Mathematica and Maple having more features (never missed them though) and a more optimized solver.

  24. [...] A 10 minute tutorial for solving Math problems with Maxima (tags: mathematics opensource tutorial) [...]

  25. mart1n says:

    great program! helps a lot at the university

  26. alex says:


    I’d messed with Maxima a few months ago, and found it a painful experience trying to figure it out from the manual. Went thru your tutorial last night and now I can use this for solving real problems.

    This will be a HUGE asset for me.


  27. sewlai says:

    Hi!The information was delivered in a simple way that it is very easy to understand in using the software which initially i found it very difficult to use Maxima when I explore it al by my own. But now you had help me to solve my probs.
    It is indeed a fantastic piece of info for me especially at this moment in rushing my assignment. Thanks…

  28. Me says:

    Got exactly what I wanted.
    Thank you so much@

  29. Jacobus says:

    Thanks for the Tut. However I cant find information to help me. My problem is as follows:
    I want to solve f in the following two functions, when I choose the following:
    s=2400 and d = 2000. f is the required value, which is the focal point of a parabole.


    I substitude h in the second function and then evaluate for the said values of s and d.

    All goes well and is calculated. However I then can not get a calculated value for f from Maxima. The following eauation is given.


    What can I do to get a calculated value for f?


  30. JiK says:

    with Mathematica, I can do wonderful things to turn a series of calculations into a semi-professional looking document. Can I do that with maxima? (or wmaxima, or …?) I’ve played with it (on windows) and it just seems like a ‘calculator’ I can solve it all, but it’s not really made to give a nice formatted output. Seems. I claim no full knowledge, maybe I’m missing something.

  31. rajendra says:

    Thank you. Your article is very useful to me to start with with Maxima.

  32. JiK, you can use Maxima from within TeXmacs or from a SAGE notebook.

  33. Mz. DiC3 says:

    i think that knowing all this math will be very helpful in the long run. it should really help you in the future

  34. Tom Carnevale says:

    Any suggestions on how to get Maxima to generate a surface of revolution; e.g., the surface formed between y=x^2, y=0 and x=6 is revolved about either axis?


  35. Heraldo says:

    Very usefull. Muito bom mesmo.

  36. Hr.stein says:

    fantastic program! great work guys!

    After a short tutorial, I tried a real problem:

    solve([x*(1+(0.083/y)^(1/z))-41, x*(1+(0.833/y)^(1/z))-44.9, x*(1+(8.333/y)^(1/z))
    -47.8], [x,y,z]);
    But get no response, anything I was wrong?

  37. Hr.stein, I run your system of equations and as a response I got that it has no solutions ([]).

  38. Hr.stein says:

    thanks for your reply, Antonio!

    In fact, I would expect an approximate solution using least square approach, with indication of deviation.( somewhat like the Mathematica does).

    I still think Maxima could solve the equations, only I miss some built-in functions or there is mistake in my expression.


  39. ENYI JOHNSON says:

    log (3m+7)-log (m+4)= 2log 6 – 3log 3
    6 6 6 6

  40. Alex Tzeros says:

    This is a fantastic tutorial. Thanks to the author, I was able to discover the great power of this amazing program. Based on this page, I started to write a tutorial for Maxima in Greek.

  41. Richard says:


    How can I tell maxima that a given variable is real and greater than zero in the expression below?


  42. Jeffrey S Fox says:

    fantastic!! This is a great getting started tutorial and showes the power of the program.
    I teach at University of Colorado and really push the value and quality of open source software (which I use in my own research). Next time I teach numerical analysis I will definitly use Maxima!

  43. macosala says:

    Excellent!! Thanks for your great tutorial for Maxima.

  44. Baha' Alsaify says:

    Wow, just from reading about the Maxima wants me to use it, it seems that its a very powerful mathematical tool

  45. Ray Pereda says:

    I used to lust after Mathematica but it is outrageously expensive: $2,500. We are approaching the point where open source alternatives, like Maxima, are the way to go for heavy duty computer assisted symbolic and numerical mathematics.

Leave a Reply

Current day month ye@r *