Example 01
Mathematica as a Simple Calculator

Copyright © 1993 by Bill Titus, Carleton College, 
Department of Physics and Astronomy, Northfield, MN  55057-4025
September 6, 1993

Topics and Skills

Problem

Solution

Step 1 - Launch MMA's front end by double-clicking the MMA icon.

Comment 1

Step 2 - Use the MMA menu system to located and open the file  Ex01.ma

Step 3 -  You'll first use MMA as a calculator and find  v[to], assuming all the numbers are integers.  Take  g = 9  and use   *   for multiplication and  -  for subtraction.  Move the cursor below this cell.  When it becomes a horizontal bar, click the mouse and type in the appropriate numbers.  Press  <Enter>  to send the results to the kernel.

Comment 3

Step 4 - Now calculate  x[to],  again assuming all the number are integers.  Use  ^  for  power  and  /  for division.

Comment 4

Step 5 - In a cell below, repeat the calculations for  v[to]  and  x[to]  with reals, now using  g = 9.8.  Use parentheses to make the order of the evaluation clear.

Comment 5

Step 6 -  Copy the last input cell for  x[to]   to a new cell below by highlighting the old cell's bracket, pressing  <Command>-c, clicking the cursor below Step 6's cell when you see the cusor become a horizontal bar, and then pressing <Command>-v.  Now replace the two  *  with spaces and enter the calculation.  Note that your cursor can be anywhere in the input cell when you press  <Enter>.  What do you find?

Comment 6

Step 7 - Editing old output.  Go back to the previous input, change  g  to  9.81, and enter the calculation.   What do you observe about the reference numbers for  In[]  and  Out[]?

Comment 7

Step 8 - Check for the presence of the missing input and output cells using some of the cell reference options discussed in Comment 7.

Step 9 -  You're now going to calculate  v[to]  and  x[to]  using reals along with symbols for units.  Right after your numbers, type a space and then type in unit(s) using the symbols  m  for meters  and   sec  for seconds.  Use parentheses to make the groupings clear.

Comment 9

Step 10  -  Use  Save As  in MMA's Notebook menu to save this notebook in your directory under myEx01.  Then quit MMA.  Look in your directory to see whether the file was indeed saved.  What extension to you see on the file?

Comment 10

Step 11 - Reload your file  myEx01  into MMA by double-clicking on the file's name or its icon.

Comment 11

Practice Problems

1.  Calculate the area of a circle of radius  2.5 m,  keeping the unit for the meter in your calculation.

2.  Use the unit conversion method to find the number of seconds in a year, starting with  60 sec = 1 min.  Use parentheses to make the conversion factors and calculation clear.  Type all the input on one line; the input won't wrap around.  When you enter the calculation, you may get an error message, depending on what symbols you use for the various units.

3.  Repeat practice problem 2, but break the line between two parentheses using the return key.  What happens when you now enter the calculation?  Why?  How can you avoid this problem?

Comment

4.  Cube the complex number  4 + 5I.  Now take its reciprocal.  Repeat with the complex number  4 + 5.0I.   Why do the results differ?

Save Your Notebook