Building Forms

Mathematical object forms are defined recursively in the following way:

Atomic object
names are mathematical object forms.

Numbers are mathematical object forms.

Legal
binary combinations of mathematical object forms using the operators +,-,*,/,^ and # are mathematical object forms. (The composition operator # may only be used with names, or atomic function objects.)

Statements f( a, b, c, ...) where f is a function or program and a, b, c, ... are mathematical object forms, are mathematical object forms. These are called
program statements or function statements.

Statements v( m, n, ...) where v is a vector or matrix name and m, n, ... are mathematical object forms that evaluate to positive integers, are mathematical object forms. These are called
indexed vector or indexed matrix statements.

Binary Operators and Binary Tests

MathScript has the usual binary operators and tests, together with a few unusual ones. The binary operators may be used to combine objects of any type except
list or string. All types of course may be compared using the equality test: ==. The tests return TRUE (T) or FALSE (NIL). Viewed as functions, these operators and tests always evaluate their arguments.

The
binary operators are:

+ addition

- subtraction

/ division

^ exponentiation

= equation binder (the left and right side form an equation object)

# composition of functions, or, when arguments are vectors, returns scalar product.

The
binary tests are:

< less than

<= less than or equal to

> greater than

>= greater than or equal to

== equality

In addition to these are the logic functions: and, or, and not. And and Or take any number of arguments. And returns the value of its last argument if none evaluates to FALSE, else it returns FALSE (and evaluates no arguments after the one that evaluated to FALSE). Or returns the value of the first argument that does not evaluate to FALSE (and evaluates no arguments after that), else it returns FALSE. Also,

To give a simple example of the use of object forms, suppose that c is a curve in the Cartesian plane, that is, it was defined as a function c: R --> R². And suppose that

Trans: R
² --> R² is a coordinate transformation. The command:

Draw the curve c in "Thiswindow" (or simply: curve c) will cause the curve to be drawn in the window with name: Thiswindow (or in the latter case, whatever window was selected).

The command:

Draw the curve sin*c in "Thatwindow" will cause the new curve obtained by scalar multiplying the function c by the sine function to be drawn.

The command:

Draw the curve trans#c in "Mywindow" will cause the composition of trans with c (a new curve) to be drawn in the window Mywindow.

Similarly, the command:

Draw the curve c + trans#c will have the desired effect. The commands do type checking on the types of objects and manipulate those objects by name in mathematically natural ways.

For example, if f: R
² --> R is defined by:

Make f(x,y) x+y, or f(x,y) := x+y then the command:

Make newfun f#trans would create a new mathematical object:
newfun, and then the command:

Draw the surface newfun in "My3DWindow" (or simply: surface newfun) would cause a 3D graph to be drawn. This style has obvious implications when more complex mathematical tasks are to be done than curve-sketching. For example, routines that solve differential equations can be readily implemented by defining the vectorfield as an object, and then simply applying it to the appropriate points along the solution trajectory. Since the vectorfield may contain parameters that may be interactively modified, this makes it easy for the student to explore effects of perturbations, etc.