Copyrighted Material
Total Page:16
File Type:pdf, Size:1020Kb
Trim Size: 178mm x 254mm Single Column k Senese c01.tex V1 - 08/02/2018 3:01pm Page 1 1 1 Fundamentals The most powerful single idea in mathematics is the notion of a variable. – K. Dewdney [1] Maxima is a general-purpose computer algebra system (CAS) that can be used to perform numerical and symbolic calculations, simplify complicated expressions, solve algebraic and differential equations, analyze and plot data, differentiate and integrate functions, compute statistics, perform matrix and vector operations, and more. Maxima in various forms has been in use for half a century. Development on Maxima’s predecessor Macsyma began in the late 1960s at MIT. In 1998, the U.S. Department of Energy released Macsyma’s source code into the public domain, and the program became Maxima. Today, Maxima is actively supported and updated by an international community of users and developers [2]. k Maxima differs in several important ways from commercial CASs like Mathcad, MATLAB, k Maple, and Mathematica: • Maxima is open-source software, distributed under the the Free Software Foundation’s GNU General Public License [3]. • Maxima is available for Windows, Mac OS, Linux, and Android tablets and phones. Com- mercial software is usually available on a limited number of platforms. For example, Mathcad works only under Windows; Mathematica and Maple are not available for Android tablets or phones, or on non-Intel-based Macs. • Most commercial CASs provide a single interface, while Maxima is a computational “back end” that can use several different interfaces. Think of Maxima as an automobile engine; it runs unseen under the hood of the car. It is controlled through a graphical “front end” or user interface, analogous to the steering wheel, dashboard, and pedals of the car. Some front-ends and software systems that use Maxima as a back end are wxMaxima [4], XMaxima [5], Euler Math Toolbox [6], Sage [7], TeXmacs [8], SMath Studio [9], and Cantor [10]. Websites can also perform symbolicCOPYRIGHTED calculations and plot graphs MATERIAL interactively using Maxima as a back end [11]. 1.1 Getting Started With wxMaxima Maxima comes bundled with two front-ends: Xmaxima and wxMaxima. wxMaxima is the more powerful of the two. It displays typeset mathematical expressions and plots, and it provides menus, toolbars, and dialogs to access most important Maxima functions. It also saves an entire session with Maxima including text, headings, and calculations in a single printable document. In this book, we’ll focus exclusively on Maxima running under wxMaxima. Symbolic Mathematics for Chemists: A Guide for Maxima Users, First Edition. Fred Senese. © 2019 John Wiley & Sons Ltd. Published 2019 by John Wiley & Sons Ltd. Companion website: http://booksupport.wiley.com k Trim Size: 178mm x 254mm Single Column k Senese c01.tex V1 - 08/02/2018 3:01pm Page 2 2 Symbolic Mathematics for Chemists In wxMaxima, commands are typed into input cells. To create a new cell, click on an empty space anywhere. A horizontal line will appear. This is the cell cursor; typing will create a new input cell at that point. You can click between cells or before the first cell to move the cell cursor to at any point in the worksheet. Start wxMaxima and type 2+2;. To execute the command, press + Enter .Theresultwill like this: Commands end with either a semicolon (;)oradollarsign($). The semicolon shows output from the command; the dollar sign hides it. wxMaxima adds the semicolon automatically to the last command in a cell if you forget to type it. k Linebreaks, tabs, and spaces are ignored in Maxima commands. You’ll get an k error message if you try to separate commands only with a linebreak instead of a semicolon or dollar sign. 1.1.1 Input Cells Let’s take a closer look at the way wxMaxima displays a command and its output in input cells: Maxima labels both input and output within the cell. The first command is labeled with (%i1). Each additional command you type will be labeled with %i followed by the number of the com- mand.Theoutputislabeledwith(%o1). Every output is labeled with %o followed by the number of the corresponding input command. Notice the glyph on the left edge of the cell (Figure 1.1). It shows the division between input and output in the cell, and also provides a way to hide the output (click on the triangle on top of the glyph). Clicking on the glyph itself selects the cell. Dragging the mouse over multiple glyphs selects them all. You can then cut, copy, or delete the selected cell or cells: • To copy, press Ctrl + c or click on the Copy Selection icon on the tool bar (it’s just to the right of the scissors icon). Click on the triangle Figure 1.1 An input cell in wxMaxima divides the cell into input and output Input label to hide output sections, with a glyph on the left that provides a way to hide output or select the cell for copying, cutting, or deleting. (%i1) 2+2; (%o1) 4 Output label k Trim Size: 178mm x 254mm Single Column k Senese c01.tex V1 - 08/02/2018 3:01pm Page 3 Fundamentals 3 File operations Editing Execution Select New Save Options Copy All Interrupt OpenPrint Cut Paste Find Restart Go to and current replace cell Animated plots Help for selected Play Step frame-by-frame command Stop Figure 1.2 The wxMaxima toolbar. • To delete, press the Delete key. • To cut (which copies the cell and then deletes it), press Ctrl + x atthesametimeorclickon thescissorsicononthetoolbar. Cells that have been cut or copied can be pasted back into the worksheet. Click on the space where you’d like to insert the cell or cells and press Ctrl + v . Cells are executed by pressing + Enter . While a cell is executing, the glyph is outlined in black, and the message Maxima is calculating appears in the status bar at the bottom of the k window.1 The black outline will not go away if you’ve made an error in the cell. k You can place multiple commands into a single input cell, as long as each ends with a semi- colon or a dollar sign. This is useful in showing intermediate results or for grouping commands. Press Enter after each command to keep the input readable. Maxima executes commands within a cell the order that you type them, and it numbers the output for each line automatically. 1.1.2 The Toolbar The toolbar provides shortcuts for storing, loading, editing, and managing sessions in wxMax- ima (Figure 1.2). The crossed tool icon is used to set program options and flags, and also to set styles for fonts and colors. We’ll look at it in more detail in Section 1.1.3. The triangle, square, and slider icons are used to play, stop, and step through animated plots. This is an advanced feature that we’ll use in one of the worksheets for Chapter 4. The blue question mark icon on the right will display the Maxima manual in a separate win- dow. To see the help page for a particular command, select the command in your worksheet and click on the Help icon (the question mark on the far right side of the toolbar). Clicking the icon without first selecting a command brings up the wxMaxima manual. You can also press the F1 key or select Help Maxima Help to bring up help pages for a selected command. 1.1.3 The Menus Many Maxima functions can be accessed through the menus above the toolbar. The menus also let you configure wxMaxima and control the execution of cells. 1 Cells usually execute so quickly that you won’t notice this, but complex calculations can take some time. If you want to interrupt a calculation, select Maxima Interrupt or press Ctrl + g . k Trim Size: 178mm x 254mm Single Column k Senese c01.tex V1 - 08/02/2018 3:01pm Page 4 4 Symbolic Mathematics for Chemists • The File menu has items for creating, opening, saving, and printing wxMaxima documents. File Load Package... can load special-purpose code packages into Maxima. File Load Batch File... canloadandexecuteaseriesofcommandsthathavebeenpreviouslysavedasafilewiththe .mac extension.2 File Export can save your wxMaxima file as an HTML file or as a LATEXfile.3 • The Edit menu has items for undoing and redoing changes; cutting, copying, and pasting commands and output; finding and selecting text; zooming in and out; and setting prefer- ences. The Edit Configure item is equivalent to the crossed-tool icon on the toolbar. Select Edit Configure Options to change wxMaxima’s default behavior. Most of the options are self-explanatory. –CheckMatch parenthesis in text controls so wxMaxima will automatically type a closing parenthesis after you type an open parenthesis, and so that clicking on a closing parenthe- sis automatically highlights the matching opening parenthesis. –CheckShow long expressions if you’d like to see results when Maxima displays a message like << Expression too long to display! >>. –CheckEnter evaluates cells if you’d rather not execute cells with + Enter (the default). This isn’t recommended, because it will keep you from breaking long commands up into aseriesofeasy-to-readlines. Select Edit Configure Style to change the fonts and colors that wxMaxima uses. • The Cell menu is used to evaluate, copy, insert, and hide different types of cells. In addition to input cells containing Maxima commands, you can organize your wxMaxima document by inserting text, titles, section titles, subsection titles, images, and page breaks. k • The Maxima menu is used to interrupt or restart Maxima . Several useful floating toolbars can k be shown using View .