calc: Demonstration of Calc
1.4 A Demonstration of Calc
===========================
This section will show some typical small problems being solved with
Calc. The focus is more on demonstration than explanation, but
everything you see here will be covered more thoroughly in the Tutorial.
To begin, start Emacs if necessary (usually the command ‘emacs’ does
this), and type ‘C-x * c’ to start the Calculator. (You can also use
‘M-x calc’ if this doesn’t work. Starting Calc, for various
ways of starting the Calculator.)
Be sure to type all the sample input exactly, especially noting the
difference between lower-case and upper-case letters. Remember, <RET>,
<TAB>, <DEL>, and <SPC> are the Return, Tab, Delete, and Space keys.
*RPN calculation.* In RPN, you type the input number(s) first, then
the command to operate on the numbers.
Type ‘2 <RET> 3 + Q’ to compute the square root of 2+3, which is
2.2360679775.
Type ‘P 2 ^’ to compute the value of ‘pi’ squared, 9.86960440109.
Type <TAB> to exchange the order of these two results.
Type ‘- I H S’ to subtract these results and compute the Inverse
Hyperbolic sine of the difference, 2.72996136574.
Type <DEL> to erase this result.
*Algebraic calculation.* You can also enter calculations using
conventional “algebraic” notation. To enter an algebraic formula, use
the apostrophe key.
Type ‘' sqrt(2+3) <RET>’ to compute the square root of 2+3.
Type ‘' pi^2 <RET>’ to enter ‘pi’ squared. To evaluate this symbolic
formula as a number, type ‘=’.
Type ‘' arcsinh($ - $$) <RET>’ to subtract the second-most-recent result
from the most-recent and compute the Inverse Hyperbolic sine.
*Keypad mode.* If you are using the X window system, press ‘C-x * k’
to get Keypad mode. (If you don’t use X, skip to the next section.)
Click on the <2>, <ENTER>, <3>, <+>, and <SQRT> “buttons” using your
left mouse button.
Click on <PI>, <2>, and y^x.
Click on <INV>, then <ENTER> to swap the two results.
Click on <->, <INV>, <HYP>, and <SIN>.
Click on <<-> to erase the result, then click <OFF> to turn the Keypad
Calculator off.
*Grabbing data.* Type ‘C-x * x’ if necessary to exit Calc. Now
select the following numbers as an Emacs region: “Mark” the front of the
list by typing ‘C-<SPC>’ or ‘C-@’ there, then move to the other end of
the list. (Either get this list from the on-line copy of this manual,
accessed by ‘C-x * i’, or just type these numbers into a scratch file.)
Now type ‘C-x * g’ to “grab” these numbers into Calc.
1.23 1.97
1.6 2
1.19 1.08
The result ‘[1.23, 1.97, 1.6, 2, 1.19, 1.08]’ is a Calc “vector.” Type
‘V R +’ to compute the sum of these numbers.
Type ‘U’ to Undo this command, then type ‘V R *’ to compute the product
of the numbers.
You can also grab data as a rectangular matrix. Place the cursor on the
upper-leftmost ‘1’ and set the mark, then move to just after the
lower-right ‘8’ and press ‘C-x * r’.
Type ‘v t’ to transpose this 3x2 matrix into a 2x3 matrix. Type ‘v u’
to unpack the rows into two separate vectors. Now type
‘V R + <TAB> V R +’ to compute the sums of the two original columns.
(There is also a special grab-and-sum-columns command, ‘C-x * :’.)
*Units conversion.* Units are entered algebraically. Type
‘' 43 mi/hr <RET>’ to enter the quantity 43 miles-per-hour. Type
‘u c km/hr <RET>’. Type ‘u c m/s <RET>’.
*Date arithmetic.* Type ‘t N’ to get the current date and time.
Type ‘90 +’ to find the date 90 days from now. Type ‘' <25 dec 87>
<RET>’ to enter a date, then ‘- 7 /’ to see how many weeks have passed
since then.
*Algebra.* Algebraic entries can also include formulas or equations
involving variables. Type ‘' [x + y = a, x y = 1] <RET>’ to enter a
pair of equations involving three variables. (Note the leading
apostrophe in this example; also, note that the space in ‘x y’ is
required.) Type ‘a S x,y <RET>’ to solve these equations for the
variables ‘x’ and ‘y’.
Type ‘d B’ to view the solutions in more readable notation. Type ‘d C’
to view them in C language notation, ‘d T’ to view them in the notation
for the TeX typesetting system, and ‘d L’ to view them in the notation
for the LaTeX typesetting system. Type ‘d N’ to return to normal
notation.
Type ‘7.5’, then ‘s l a <RET>’ to let ‘a = 7.5’ in these formulas.
(That’s the letter ‘l’, not the numeral ‘1’.)
*Help functions.* You can read about any command in the on-line
manual. Remember to type the letter ‘l’, then ‘C-x * c’, to return here
after each of these commands: ‘h k t N’ to read about the ‘t N’ command,
‘h f sqrt <RET>’ to read about the ‘sqrt’ function, and ‘h s’ to read
the Calc summary.
Press <DEL> repeatedly to remove any leftover results from the stack.
To exit from Calc, press ‘q’ or ‘C-x * c’ again.