Pages created and updated by Terry Sturtevant Date Posted: May 12, 2017

Maxima Logic Tutorial

Maxima is a GPL program, available for Windows, Mac, and Linux. It is a computer algebra system (CAS) like Maple or Mathematica.
There are various tutorials out there on how to use Maxima; this one is designed to focus on its use for digital circuit analysis; i.e. lots of use of Boolean algebra.

Sample Digital Logic Circuit

Here is a simple circuit:
Prime Number Indentifier Circuit

It gives us the following boolean Sum-Of-Products (SOP) equation :
prime = a3 a2 a1 + a3 a2 a0 + a2 a1 a0 + a2 a1 a0

A computer algebra system can be very useful for analyzing circuits like this.
  1. Opening Maxima

  2. Entering Equations

  3. Saving a Session

  4. Quitting Maxima

  5. Loading a Previous Session

  6. Redefining Variables

  7. Checking all Possible Input Combinations

  8. Links


  1. Opening Maxima:
    • At a command prompt, type maxima
      bash-4.1$ maxima
      Maxima 5.25.1 http://maxima.sourceforge.net
      using Lisp CLISP 2.49 (2010-07-07)
      Distributed under the GNU Public License. See the file COPYING.
      Dedicated to the memory of William Schelter.
      The function bug_report() provides bug reporting information.
      (%i1) 
      


  2. Entering Equations:
    • To enter a boolean equation,
      At the prompt, type in the the command as shown:
      (%i1)  (not a3) and (not a2 and a1); 
      (%o1)                    (not a3) and (not a2) and a1
      
      

      This is the first term in the equation; we can type in each term separately to keep them all straight.
      We could also assign each term to its own variable, like this:
      (%i1) t1: (not a3) and (not a2 and a1); 
      (%o1)                    (not a3) and (not a2) and a1
      
      


      The remaining terms can be entered similarly:
      (%i2) (not a3) and (a2 and a0); 
      (%o2)                       (not a3) and a2 and a0
      (%i3) (not a2) and (a1 and a0); 
      (%o3)                       (not a2) and a1 and a0
      (%i4) (not a1) and (a2 and a0); 
      (%o4)                       (not a1) and a2 and a0
      

      If we wanted to use assignments for each it would look like this:
      (%i2) t2: (not a3) and (a2 and a0); 
      (%o2)                       (not a3) and a2 and a0
      (%i3) t3: (not a2) and (a1 and a0); 
      (%o3)                       (not a2) and a1 and a0
      (%i4) t4: (not a1) and (a2 and a0); 
      (%o4)                       (not a1) and a2 and a0
      


      We can combine the individual terms easily by their results numbers, like this:
      (%i5)  %o1 or %o2 or %o3 or %o4;
      (%o5) ((not a3) and (not a2) and a1) or ((not a3) and a2 and a0)
                              or ((not a2) and a1 and a0) or ((not a1) and a2 and a0)
      

      This ability to recall previous results is very useful, and we'll use it a lot.

      For instance, now %o5 represents the complete expression for the function.

      If we used assignments for the terms, we would combine them like this:
      (%i5)  t1 or t2 or t3 or t4;
      (%o5) ((not a3) and (not a2) and a1) or ((not a3) and a2 and a0)
                              or ((not a2) and a1 and a0) or ((not a1) and a2 and a0)
      

    • You can substitute in specific component values:
      (%i6) %o5, a0=false, a1=false,a2=false, a3=false;
      (%o6)                                false
      


  3. Saving a Session:
    • Saving a session: (The "all" means to save all variables from this session.)
      (%i6) %o5, a0=false, a1=false,a2=false, a3=false;
      (%o6)                                false
      (%i7) save("test",all);
      (%o7)                       /home/terry/maxima/test
      
      


  4. Quitting Maxima:
    • Quitting maxima:
      (%o7)                       /home/terry/maxima/test
      (%i8) quit();
      
      


  5. Loading a Previous Session:
    • It's nice to be able to pick up where you left off, so you can keep developing an analysis over time.
      To loading a previous session:
      bash-4.1$ maxima
      Maxima 5.25.1 http://maxima.sourceforge.net
      using Lisp CLISP 2.49 (2010-07-07)
      Distributed under the GNU Public License. See the file COPYING.
      Dedicated to the memory of William Schelter.
      The function bug_report() provides bug reporting information.
      (%i1) load("test");
      (%o7)                                test
      
      Notice that the statement number has jumped ahead; all of the statements from the previous session have been included in this one.

    • Previous statements can be recalled:
      (%i1) load("test");
      (%o7)                                test
      (%i8) %o5;
      (%o8) ((not a3) and (not a2) and a1) or ((not a3) and a2 and a0)
                              or ((not a2) and a1 and a0) or ((not a1) and a2 and a0)
      


  6. Redefining Variables:
    • Variables can be changed:
      (%i9) %o5, a0=true, a1=false,a2=false, a3=false;
      (%o9)                                false
      (%i10) %o5, a0=false, a1=true,a2=false, a3=false;
      (%o10)                                true
      


      We can continue on, substituting all of the input variable combinations.
  7. Checking all Possible Input Combinations:
    • Loops can be used to check all possible input combinations to an equation:
      (%i11) for a0 in [false,true]
      do for a1 in [false,true]
      do for a2 in [false,true]
      do for a3 in [false,true]
      do (t1:(not a3) and (not a2 and a1),
      t2:(not a3) and (a2 and a0),
      t3:(not a2) and (a1 and a0),
      t4:(not a1) and (a2 and a0),
      result:t1 or t2 or t3 or t4,
      display(a0,a1,a2,a3,result));
       
      

      This sets up four nested loops, (one for each variable), to check all of the combinations. Note: When multiple statements are performed inside loops, the statments are separated by commas, not semicolons, and the entire set is enclosed in parentheses.
      The output looks like this:
                                        a0 = false
      
                                        a1 = false
      
                                        a2 = false
      
                                        a3 = false
      
                                      result = false
      
                                        a0 = false
      
                                        a1 = false
      
                                        a2 = false
      
                                         a3 = true
      
                                      result = false
      
                                        a0 = false
      
                                        a1 = false
      
                                         a2 = true
      
                                        a3 = false
      
                                      result = false
      
                                        a0 = false
      
                                        a1 = false
      
                                         a2 = true
      
                                         a3 = true
      
                                      result = false
      
                                        a0 = false
      
                                         a1 = true
      
                                        a2 = false
      
                                        a3 = false
      
                                       result = true
      
                                        a0 = false
      
                                         a1 = true
      
                                        a2 = false
      
                                         a3 = true
      
                                      result = false
      
                                        a0 = false
      
                                         a1 = true
      
                                         a2 = true
      
                                        a3 = false
      
                                      result = false
      
                                        a0 = false
      
                                         a1 = true
      
                                         a2 = true
      
                                         a3 = true
      
                                      result = false
      
                                         a0 = true
      
                                        a1 = false
      
                                        a2 = false
      
                                        a3 = false
      
                                      result = false
      
                                         a0 = true
      
                                        a1 = false
      
                                        a2 = false
      
                                         a3 = true
      
                                      result = false
      
                                         a0 = true
      
                                        a1 = false
      
                                         a2 = true
      
                                        a3 = false
      
                                       result = true
      
                                         a0 = true
      
                                        a1 = false
      
                                         a2 = true
      
                                         a3 = true
      
                                       result = true
      
                                         a0 = true
      
                                         a1 = true
      
                                        a2 = false
      
                                        a3 = false
      
                                       result = true
      
                                         a0 = true
      
                                         a1 = true
      
                                        a2 = false
      
                                         a3 = true
      
                                       result = true
      
                                         a0 = true
      
                                         a1 = true
      
                                         a2 = true
      
                                        a3 = false
      
                                       result = true
      
                                         a0 = true
      
                                         a1 = true
      
                                         a2 = true
      
                                         a3 = true
      
                                      result = false
      
      (%o11)                              done
      
  8. Links:
    • Maxima Manual [HTML; ]
      The official documentation
    • Maxima Overview [HTML; Burkhard Bunk]
      A good shorthand reference to commands and syntax
    • Maxima tutorial [HTML; Boris Gaertner]
      The "First Steps" and "Getting Started" sections are very useful introductions to the basics.

Creative Commons License
Information on this site which is produced by Terry Sturtevant is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 2.5 Canada License.

Resources

To view pdf documents, you can download Adobe Acrobat Reader .
get Acrobat Reader
If you need to update a browser, you might try Firefox which is Get Firefox!
Since this page uses cascading style sheets for its layout, it will look best with a browser which supports the specifications as fully as possible.

If you are looking for an office package, with a word processor, spreadsheet, etc., you might try LibreOffice which is Get LibreOffice!

Go to the main page for the Department of Physics and Computer Science.

Valid XHTML 1.1

Valid CSS!

WCAG 2.0
(Level AA)

Wilfrid Laurier University