Arithmetica: A New Thinking For Simple Expressions


Thank you for Using Arithmetica. Finally all your dreams of a calculator ON YOUR COMPUTER have finally come true, thanks to the many hours spent by our programming staff of one. No longer will you have to add with your fingers, or walk all the way to your book bag for that trusty TI-89. Throw away that abacus and enter the amazing world of ARITHMETICA!!!!


TABLE OF CONTENTS

[Section 1: Starting Arithmetica & General Overview]

Starting the Arithmetica program is simple as can be. At the command line you simply type: arithmetica. Once that is typed in, press enter and you are off to the wonderful world of ARITHMETICA LAND!

Before we go any further, we should first learn the general structure of Arithmetica. The Arithmetica program deals with one infix expression at a time. When you start Arithmetica, it will evaluate these expressions as well as some special features.

Just type in the expression and watch as Arithmetica produces the appropriate output, and politely asks you for the next expression

Yes. it's that easy! If you have any further questions, the rest of this documentation goes into further detail.

One more note for advanced users: you can type in the name of the file for input and output at the command line. Thus if you want to open the file input.txt and ouput results to output.txt you can do it by typing at the command line:

    arithmetica < input.txt > output.txt 

These command line arguements will only work if input.txt has properly formated valid expressions for arithmetica to evaluate


[Section 2: Entering Expressions]

[Section 2.1: Simple Infix Expressions]

In order to evaluate a simple expression such as 3 + 4, simply enter it at the command prompt, making sure to put spaces between operators and operands. For example, input of "3 + 4" would return 7, while "3+4" would return 3. This holds true for all binary operators(+,-,*,/,%), however is not necessary for unary operators(-,abs()) and parenthesis. These expressions should be entered without spaces. Ex: "3 + 4 - abs(-3 - -4)" Notice the spaces before and after a minus, but not before and after negate.

Congratulations you have entered your first expression!

[Section 2.2: [Expressions with Variables]

Now that you've entered your expression correctly, you may want to save that expression to a variable for later use. Doing so is very simple in Arithmatica. Simply type the variable name, then =, then the expression. Be careful not to have any spaces before the equals sign, or your variable name may be saved incorrectly. For Example, "a=5" is correct, while "a =5" would store the variable as "a " and not "a". To check if your variable was assigned correctly, simply type it at the next command prompt and see if the output matches what you expected.

Now that you have your variable, you may perform any operation on it as if it were an integer such as 1 or 2, simply by typing its name into the expressions at the command prompt.

[Section 2.3 [Extending Expressions]

For long expressions, you may want to type them in smaller chunks. Arithmetica understands that need, and thus allows you to add on to the last expression executed, without retyping it. At the next command line simply type the remaining operations(i.e. "+ 9") to add nine to the last expression evaluated. Also, the variable name "current" also refers to the last expression evaluated.

NOTE: Variable assignments do not count as evaluated expressions, and thus do not affect current. To use them you must retype the variable name. "3 + 4" 7 "a=5" 5 "+ 3" 10 "current + a" 15

[Section 2.4 [Q]uitting]

Once you have had enough computing for one night, simply press control-D and leave Arithmetica for another day.

[Section 3: TroubleShooting]

Due to the many types of expressions held by Arithmetica, Problems with the syntax are expected. But do not worry, nothing you can throw at it will cause it to crash. Here is some help on distinguishing what your error might be. Remeber, most errors are the result of a mistyped expression, so check your expression carefully if the output is not what you expected.

[Section 3.1: Errors]

As of this version of Arithmetica, there are only 2 error messages you should receive.

			Error: Division by 0
			Error: Undefined Variable
                        Error: Mismatched Parenthesis

Division by Zero is self explanatory, and will return a value of zero for the portion of the expression containing the illegal division

Undefined Variable arises when you attempt to acess a variable that has yet to be defined. Arithmetica will Return 0 as the value of that variable, and inform you of the problem. This error can also arise if you do not use the proper spacing in your expression, or attempt to use an operator not yet supported by Arithmetica.

Mismatched Parenthesis arises when the Parenthesis are not arranged properly, returns 0 for the expression

- Peter Smith
Monday, September 16, 2001