AAA User's Manual

Programmer's Manual

Version 3.0

Welcome to AAA, Version 3.0

Starting AAA

To start arithmetica, simply type 'AAA' at the prompt

user@computerXX% AAA

This will bring up the AAA main menu:

Please Choose and Application:
     1) Arithmetica
     2) Diffmetica
     3) Imagemetica
     3) Lsysmetica
choice:

Congratulations, you have successfully started AAA. Now simply enter the number of the application you wish to run. Arithmetica is a standard mathematical expression evaluator, DIffmetica takes the first differential of a mathematica expression, Imagemetica allows for image manipulation, and Lsysmetica is an L-system expression parser that uses LOGO for display. So now move on to the next section to learn about entering expressions.

Working with Arithmetica

Entering Constants

The fundamental building blocks of arithmetica expressions are constants. At it's most basic, Arithmetica is a real number expression parser, and thus it depends on these numbers. Constants my either be entered as integers or as real numbers. Entering a constant by itself at the prompt will only cause Arithmetica to return the constant itself. Examples:

0)->6
6

1)->4.586
4.586

Entering Simple Binary Expressions

To enter a simple binary expression, simple enter it at the prompt and hit the Return/Enter key. The expression will be evaluated and the result outputted to the screeen. As with all entered expression in Arithmetica, spaces will be ignored. Examples:

0)--> 6 + 9 / 3 * 100
900

1)--> 6 + 7 * 9 / 5 / 5 - 4 - 7
-2.48

Note that in all cases, standared operator precedence (i.e. order of operations) is used. Below is a table of simple binary expressions.

Expression Syntax Meaning Examples Value Returned
+ exp + exp addition 4 + 5
3 + 66 +7
9
76
- exp - exp subtraction 4 - 5
8 - 0 -5
-1
3
* exp * exp multiplication 4 * 5
3 + 0 * 100
20
3
/ exp / exp division 4 / 5
100 / 10 / 10
.8
1
% exp % exp modulus 4 % 5
5 * 6 % 10
4
0
^ exp ^ exp exponent 4 ^ 5
5 ^ 6 % 10
1024
5

Entering Unary Expreesions

In addition to binary expressions, Arithmetica also supports unary expressions. Unary operators can come before or after the expression they modify, depending on their type. They are entered at the prompt in the same manner as binary expressions. The chart below details the supported unary functions.

Expression Syntax Meaning Examples Value Returned
- - exp negation - 5
-66 +7
-5
-59
sin sin(exp) sine (in rads) sin(4 - 5)
sin(3.141596)
-0.841471
-3.34641e-06
cos cos(exp) cosine (in rads) cos(4-5)
cos(3.141596)
0.540302
-1
tan tan(exp) tan (in rads) tan(4-5)
tan(3.141596)
-1.55741
3.34641e-06
sqrt sqrt(exp) square root sqrt(4 - 5)
sqrt(14-5)
NaN
9

Parthentheses

Aside from their obvious uses in the above unary expressions (where they are required) parentheses may be used at any point in an expression to change the order of evaluation--everything within the parentheses gets evaluated first. Examples

0)-->4 + 5 / 10
4.5

1)-->(4 + 5) / 10
.9

Variables

One of Arithmetica's most powerful features is its ability to store variables. To assign a value to a variable, simply type the name of the variable, then the assignment operator "=", and then the value of the variable. It's important to note that the values assigned to variables are in the form of expressions, not simply constant numbers. This means that you can assign entire mathmatical expressions to a variable, even expressions containing other variables. You can also assign images to variables, or expressions with images in them. When a variable is assigned at the prompt, the value returned by Arithmetica to the screen will be the numerical value of the expression represented by the variable as currently evaluated. Examples:

0)-->a = 6
6

1)-->num = 6 * 5 - 8
22

2)-->b = 75 * a
300

3)-->num = a + b / 2
156

4)-->a = 100
100

0)-->num
250

Variables, in the present version, are limited to alphabetical characters only. They cannot contain any operators--the most common mistake would be to enter variables with f (this obiously should be fixed). It should also be noted that, though spaces are allowed, the variable "b ball" is the same as "bball." Also, as can be seen in the last two examples, if the value of a variable is changed, the values of all variabls that depend on that value are changed as well.

current: There is a special variable named "current", which stores the value of the last expression without a variable assignment entered by the user. Aside from being available at the prompt, current is automatically called if you begin an expression with a binary operator, so that "+ 4" is really equivalent to "current + 4". Examples:

0)-->4 + 6
10

1)-->+5
15

2)-->current
15

3)-->x = 6
6

4)-->x^2+4*x-6
54

5)-->x = 2
2

6)-->current
54

As a final not about variables, it should be noted that you cannot enter a circular reference to a variable. This should be desired by the user at all times, execpt perhaps on the first level, eg:

0)-->x=2
2

1)-->f(x^2,z=3)
4

Working with Diffmetica

Entering expressions

All that is important to know about Diffmetica is the method of entering differential expressions:

d d(exp,variable) differentiation d(x+3,x)
d(x^2+z,x)
(1 + 0)
(((2 * (x ^ (2 - 1))) * 1) + 0)

Clearly, differential expressions are entered just like the binary expressions above. The first differential of the expression entered in the first half of the parenthetical expression is given with respect to the variable in the second part of the equation. Additionally, it should be noted that the values returned will be unsimplified. Also, unlike function evaluation, differentiation does not look up the values of variables that are not assigned in the expression itself. Thus:

0)-->d(x^2,z)
(2 * (x ^ (2 - 1)) * 0)

Working with Imagemetica

Entering expressions

Imagematica supports all functions given in the table below. Imagemetica expressions can be entered like arithmetica expressions below, although images can be entered as operands.

Commands allowed Syntax Explanation
Constants; >Any real number >Will return grey scale image with the color of given constant
Variables >Any word >Will return black image if unassigned, or the image it assigned to
String any word Indicate a filename,will reutrn image of filename
Assignment >Variable = expr >Assign any expression to Variable
Unary Operator >!expr >Return Invert of image
BiOperator >Expr<op>Expr, where op: + - * / >Return the respective operated image
Unary Function >Op(expr), op: sin, cos, tan, abs >Return the respective operated image
Multi Function >Op(expr,expr)
Color(R,G,B)
Color("string")string should be hex
Filter("filename","kernel file")
>Color(R,G,B) return a image with the given RGB color
Color(string) reutrns a image with the given Hex string color
Filterreturns image filtered by the kernel file

Imagmetica will automatically open the image returned by uses expression using xv program on unix machines. The user can type q when the mouse is over the image to close the image and enter another expression. Some example of Imagemetica expressions are:

Color(2,5,255)
<1.ppm+2/sin(2.ppm)
filter(1.ppm, blur)

It should be noted that a constant will only return a grey scale image that takes value from 0 to 1. Anything outside that range will give image of white color. No Negative numbers are allowed. A RGB color will take values from 0 to 255. Hex values should be preceded by a #, for example #ff00ff.

Lsysmetica

Lsysmetica is capable of passing any logo command to the logo interperator, but it's real strength is in taking an expression entered by the user, and turning it into an L-system. Before examples, first take a look at this table of what Lsysmetica is capable of taking as input

Expression Syntax Meaning Examples Value Returned
Constant (any number) an integer constant
(it should be noted that entering a constant alone will result in that constant being pased to logo, which won't do anything with it.
3
16807.7
n/a
n/a
String (any LOGO expression between quotes) strings are passed directly to LOGO interperter "fd 50"
"pu fd 50 pd repeat 50 [fd 5 rt 360/50] pu home"
a line in LOGO
a circle in LOGO
Variable (a non-numeric string that does not contain operators) some expression represented by a word goForth
x
output depends on the value associated with variable; unitialized variables return nothing
Assignment var = expression assigns an expression (presumably a LOGO command) to a variable lt = "lt"
goForth = "pd fd 100"
LOGO will say it doesn't have enough input LOGO turtle draws a straigt line
Rule var->exprlist a rule generates a list of variables to be evaluted. these expression will most always be circular, as when they are evaluted using the expand function, they will only show the L-system pattern of growth if they are circular. f->f--f+f+f
a = ab
no real output, though LOGO is called
Expand (Binary Function) expand(rule,const) the rule is expanded const number of times--so the string in rule is replaced by the rule to which it is linked throughout the entire rule for const number of levels expand(f,2) output depends on what f means in terms of LOGO command and what it's rule is

Using the expand function is really where the fun part of L-systems comes from. So just play around with that of them. Also, once logo is called, you can enter commands directly into it, or return to AAA by typing "bye".

The following variables are set to default values:

distance        // 10
angle           // 30
f               // "pd fd" distance
g               // "pu fd" distance
+               // "rt" angle
-               // "lt" angle

THANK YOU FOR USING AAA

Endnote

This manual has made every attempt to be exhaustive. However, some things have surely been left out. If you are curious as to what will happen, go ahead and try something. The program still has a few bugs, but is remarkably stable, and most input that cannot be evalutated will merely generate error messages.

last modified: 10-09-02