home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 June
/
SIMTEL_0692.cdr
/
msdos
/
calcultr
/
amp30.arc
/
MANUAL.TXT
< prev
next >
Wrap
Text File
|
1989-03-24
|
155KB
|
7,619 lines
Copyright 1987, 1989 Cerebral Software
Algebraic
Manipulation
Program
(Version 3.0)
Users Manual (Evaluation Version)
Program and Manual by Mark Garber
Cerebral
Software
for IBMR PC/XT, PC/AT and 100% compatibles with 640 kilobytes of
memory or more.
Copyright 1987, 1989
Cerebral Software
P.O. Box 80332
Chamblee, Georgia 30366
Ph (404)-452-1129
This publication and accompanying software is protected by the
copyright laws of the United States of America. Users may
distribute this manual on a non commercial basis.
Cerebral Software reserves all copyrights and all other rights on
its software.
Cerebral Software does not warrant that its software package will
function properly in every hardware/software configuration.
NOTICE: CEREBRAL SOFTWARE IS NOT LIABLE FOR DAMAGES IN CONNECTION
WITH THE USE OF THIS SOFTWARE OR MANUAL.
Cerebral Software reserves the right to revise this publication
and to make changes to its content hereof without obligation to
notify any person of such revision or changes.
Production copies of the software and manual are available from
Cerebral Software for $90 plus $3 shipping and handling. (Ga
residents add 3% sales tax.)
AMP was written in Modula-2 using the Logitech Software
Development System.
Copyright 1987, 1989 Cerebral Software
Acknowlegment
Cerebral Software would like to acknowlegde Mike King and Tom
Mackovica of Motorola for their constructive criticism of AMP 2.0
during the development stage of that product. A great deal of
what was learned on that product has gone into this one. A great
deal of thanks goes to Hugh Horton of TRW for his timely
evaluation and bug hunting during the early development stages of
AMP 3.0.
Thanks also to all the other beta testers who suffered through
the early stages of this product and supplied feedback
information.
Copyright 1987, 1989 Cerebral Software
How To Use This Manual
Chapter I, Overview, gives a brief description of the AMP
interpreter. Chapter II, Installation, gives instructions for
installing the program on a hard disk. Chapter III, Getting
Started, chapter IV, Structure and chapter V, Tutorial, give an
introduction on how to use the AMP interpreter to solve problems.
You should go through these chapters in detail.
Once you have gone through the tutorial you should browse
though Chapters VI and become familiar with the command set.
Chapter VII describes detailed instructions for constructing
procedures. Chapter VIII gives the rules for than AMP follows
when it performs computations using relations.
Copyright 1987, 1989 Cerebral Software
Table of Contents
I.Overview . . . . . . . . . . . . . . . . . . . . . . . . . 1
II.Installation . . . . . . . . . . . . . . . . . . . . . . . 1
III.Getting Started . . . . . . . . . . . . . . . . . . . . . 2
IV.Structure . . . . . . . . . . . . . . . . . . . . . . . . 11
Labels . . . . . . . . . . . . . . . . . . . . . . . . . 11
Constants . . . . . . . . . . . . . . . . . . . . . . . 12
Units . . . . . . . . . . . . . . . . . . . . . . . . . 12
Indices and Index Expressions . . . . . . . . . . . . . 12
Variables . . . . . . . . . . . . . . . . . . . . . . . 13
Functions . . . . . . . . . . . . . . . . . . . . . . . 13
Standard Functions . . . . . . . . . . . . . . . . . . . 13
Summations . . . . . . . . . . . . . . . . . . . . . . . 14
Products . . . . . . . . . . . . . . . . . . . . . . . . 14
Derivatives . . . . . . . . . . . . . . . . . . . . . . 15
Integrals . . . . . . . . . . . . . . . . . . . . . . . 15
Expressions . . . . . . . . . . . . . . . . . . . . . . 16
Magnitudes . . . . . . . . . . . . . . . . . . . . . . . 16
Equations . . . . . . . . . . . . . . . . . . . . . . . 16
Relations . . . . . . . . . . . . . . . . . . . . . . . 16
Procedures . . . . . . . . . . . . . . . . . . . . . . . 16
Special Operators . . . . . . . . . . . . . . . . . . . 17
V.Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . 18
Numerical Calculations . . . . . . . . . . . . . . . . . 18
Simplifications . . . . . . . . . . . . . . . . . . . . 20
Two Equations . . . . . . . . . . . . . . . . . . . . . 22
Matrix Manipulation . . . . . . . . . . . . . . . . . . 25
Identities . . . . . . . . . . . . . . . . . . . . . . 30
Special Differentiation . . . . . . . . . . . . . . . . 31
VI.Command Dictionary . . . . . . . . . . . . . . . . . . . . 32
":" -- DEFINITION OPERATOR . . . . . . . . . . . . . . . 34
":=" - ASSIGNMENT OPERATOR . . . . . . . . . . . . . . . 37
ADD . . . . . . . . . . . . . . . . . . . . . . . . . . 39
ARGUMENT . . . . . . . . . . . . . . . . . . . . . . . . 40
CENTER . . . . . . . . . . . . . . . . . . . . . . . . . 41
CLEAR . . . . . . . . . . . . . . . . . . . . . . . . . 42
COEFFICIENT ISOLATE . . . . . . . . . . . . . . . . . . 43
COLLECT TERM . . . . . . . . . . . . . . . . . . . . . . 44
COLLECT OPERATOR . . . . . . . . . . . . . . . . . . . . 45
CONSTANT . . . . . . . . . . . . . . . . . . . . . . . . 46
DECIMAL . . . . . . . . . . . . . . . . . . . . . . . . 47
DEGREES . . . . . . . . . . . . . . . . . . . . . . . . 48
DERIVATIVE ISOLATE . . . . . . . . . . . . . . . . . . . 49
DIFFERENTIAL ISOLATE . . . . . . . . . . . . . . . . . . 50
DISTRIBUTE TERM . . . . . . . . . . . . . . . . . . . . 51
DISTRIBUTE OPERATOR . . . . . . . . . . . . . . . . . . 52
Copyright 1987, 1989 Cerebral Software
DIVIDE . . . . . . . . . . . . . . . . . . . . . . . . . 53
DISPLAY . . . . . . . . . . . . . . . . . . . . . . . . 54
ECHO . . . . . . . . . . . . . . . . . . . . . . . . . . 55
EXIT . . . . . . . . . . . . . . . . . . . . . . . . . . 56
EXPAND . . . . . . . . . . . . . . . . . . . . . . . . . 57
EXPAND OPERATOR . . . . . . . . . . . . . . . . . . . . 58
FACTOR . . . . . . . . . . . . . . . . . . . . . . . . . 59
FLOATING . . . . . . . . . . . . . . . . . . . . . . . . 60
FUNCTION . . . . . . . . . . . . . . . . . . . . . . . . 61
GRADIANS . . . . . . . . . . . . . . . . . . . . . . . . 62
HIGHBOUND . . . . . . . . . . . . . . . . . . . . . . . 63
IMAGINARY . . . . . . . . . . . . . . . . . . . . . . . 64
IN . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . 66
INTEGRAL ISOLATE . . . . . . . . . . . . . . . . . . . . 67
ITERATE . . . . . . . . . . . . . . . . . . . . . . . . 68
LABEL . . . . . . . . . . . . . . . . . . . . . . . . . 69
LEFT . . . . . . . . . . . . . . . . . . . . . . . . . . 70
LIST . . . . . . . . . . . . . . . . . . . . . . . . . . 71
LOAD . . . . . . . . . . . . . . . . . . . . . . . . . . 72
LOWBOUND . . . . . . . . . . . . . . . . . . . . . . . . 73
MULTIPLY . . . . . . . . . . . . . . . . . . . . . . . . 74
NEGATE . . . . . . . . . . . . . . . . . . . . . . . . . 75
NOTATION . . . . . . . . . . . . . . . . . . . . . . . . 76
ON . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
PRINT . . . . . . . . . . . . . . . . . . . . . . . . . 78
PROCEDURE . . . . . . . . . . . . . . . . . . . . . . . 79
PRODUCT . . . . . . . . . . . . . . . . . . . . . . . . 80
QUOTIENT . . . . . . . . . . . . . . . . . . . . . . . . 82
RADIANS . . . . . . . . . . . . . . . . . . . . . . . . 83
RAISE . . . . . . . . . . . . . . . . . . . . . . . . . 84
REMAINDER . . . . . . . . . . . . . . . . . . . . . . . 85
REPLACE . . . . . . . . . . . . . . . . . . . . . . . . 86
RIGHT . . . . . . . . . . . . . . . . . . . . . . . . . 87
SAVE . . . . . . . . . . . . . . . . . . . . . . . . . . 88
SCIENTIFIC . . . . . . . . . . . . . . . . . . . . . . . 89
SOUND . . . . . . . . . . . . . . . . . . . . . . . . . 90
STANDARD . . . . . . . . . . . . . . . . . . . . . . . . 91
SWITCH . . . . . . . . . . . . . . . . . . . . . . . . . 92
SUBTRACT . . . . . . . . . . . . . . . . . . . . . . . . 93
SUM . . . . . . . . . . . . . . . . . . . . . . . . . . 94
UNIT . . . . . . . . . . . . . . . . . . . . . . . . . . 96
VARIABLE . . . . . . . . . . . . . . . . . . . . . . . . 97
VII.Procedures . . . . . . . . . . . . . . . . . . . . . . 98
Procedure Heading . . . . . . . . . . . . . . . . . . . 98
VIII.Relation Arithmetic . . . . . . . . . . . . . . . . . . 101
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Copyright 1987, 1989 Cerebral Software
I.Overview
AMP 3.0 is a symbolic calculation tool for students,
teachers, and professionals in engineering or mathematical
sciences. AMP allows the user to edit and simplify numerous
expressions or equations in a mathematical derivation quickly and
accurately.
AMP functions in an interpreter mode and program mode. In
the interpreter mode you may manipulate up to 128 expressions,
equations or inequalities. In the program mode you have access
to a combination screen editor and compiler so that you may
define procedures using the same type statements that you use in
the interpreter mode. Errors are displayed with the cursor
positioned at the offending statement.
AMP facilitates tensor manipulation using index notation.
Tensor elements may be simple numbers or complex expressions :
elements which are expressions are simplified by AMP. Tensors
whose components are relations may also be defined. A special
case of tensor manipulation is matrix multiplication.
AMP is language driven and interactive. You input a command
line telling AMP what to do. AMP then echoes the results to the
screen. There are commands which allow you to direct results of
a derivation to the printer. Expressions and equations may be
saved to the disk and then later recalled.
II.Installation
Prior to installing the program you should check your AMP
disk for the READ.ME file. This file contains late changes to
the manual or program (if any).
In order to run AMP you must have an IBM-PC compatible
computer with a MGA, CGA, EGA, or VGA video card running under
DOS 2.1 or later. The computer must have a hard disk and at
least 640 kilobytes of memory.
In systems with extended memory a ramdisk may be used to
speed processing. The AMP program and associated overlay and
help files occupy slightly less than 800 kilobytes. You should
define a ramdisk of at least 1 megabyte. You will then have room
for the AMP program files and any data (*.DAT) and program files
(*.PRC) that you may define.
After you have booted your system place the AMP diskette
into DRIVE A. Then type :
A:INSTALL C:dirname
1
Copyright 1987, 1989 Cerebral Software
All the necessary files will be copied to dirname where dirname
is the name of a directory to which the necessary files of AMP
will be reside1.
III.Getting Started
Make certain that you are in the directory where the AMP
files reside. At the DOS prompt type AMP. The screen should
suddenly become blank and after a few seconds you should see the
copyright information. Hit any key to initiate the program.
You should then see a screen as shown in figure 1. The
square prompt and the blinking cursor indicate where input from
the keyboard will be echoed to the screen. The top of the screen
lists special soft keys which are used by AMP. Tables I, II, III
describes these keys as well as the functioning of the keyboard
under AMP.
You are now ready to enter your first equation to AMP. Try
entering the following equation at the blinking cursor:
Q1 : f(a,b) = (b/c)*(c/b)*d + a + 1/2*a + 1.5 + 2.2 + X + x
Q1 is a label which is used to identify the equation following
the colon. Once you press the carriage return AMP simplifies the
equation as follows :
(1) The terms "a" and "1/2*a" are added to give "3/2*a".
(2) Factors are cancelled in the term "(b/c)*(c/b)*d" giving "d".
(3) The terms 1.5 and 2.2 are added giving 3.70.
(4) The terms are then ordered alphabetically.
The simplified equation is
Q1 : f(a,b) = 3/2*a + d + X + x + 3.70
Keep in mind that AMP is case sensitive in many cases. The
variables "X" and "x" are not considered the same and hence they
are not added.
1 The installation permits installation in only the
current directory. A statement such as "A:INSTALL
C:DIR1\DIR2" is not permitted and will crash. If you
wish to install the program files in another directory,
you should first create the directory and then change
the current directory to the new directory.
2
Copyright 1987, 1989 Cerebral Software
Prior to entering any more data to AMP you should read the
following section on structure, chapter IV, and you should work
through the tutorial.
If you wish to terminate the present session with AMP, just
type "EXIT" at the prompt. AMP will then return control to DOS.
3
Copyright 1987, 1989 Cerebral Software
Figure 1 Screen after copyright informations is shown.F1: Greek F2: Last F3: Save F4: Recall F5: Program F6:
Dos F7: Help
4
Copyright 1987, 1989 Cerebral Software
TABLE I
Interpreter Edit and Function Keys
Key
Combination Description
<- Moves the curser one space to the left.
-> Moves the curser one space to the right.
Moves the curser up one line of multiline
input.
Moves the curser down one line of multiline
input.
Back Space Erases input immediately before curser.
<cr> Ends the current input line and initiates
processing.
Ctrl <- Moves the cursor left 10 spaces or to front
of line.
Ctrl -> Moves the cursor right 10 spaces or to the
end of line.
Ctrl <cr> Brings the cursor to the next line. Allows
for multiline inputs.
Ctrl Home Clears Screen.
Ctrl End Erases input from cursor to end of line.
Ctrl PgDn Erases input from cursor to last line of
multiline input.
Del Erases input at the cursor.
End Moves the cursor to the end of line.
Esc Erases the current input lines.
Ins Toggles insert mode. Cursor size indicates
mode status : A large cursor indicates
character will be inserted at the cursor; a
small cursor indicates characters will be
overwritten.
5
Copyright 1987, 1989 Cerebral Software
Home Moves the cursor to front of line.
TABLE I cont'd
Key
Combination Description
PgUp Moves the cursor to the first line of a
multiline input.
PgDn Moves the cursor to the last input line of a
multiline input.
Shift Tab Moves cursor five spaces left.
Tab Moves cursor five spaces right.
Interpreter Function Keys
Key
Combination Description
F1: Greek Remaps the keyboard to allow the input of
Greek character set. Once a key is struck,
the keyboard reverts to the Roman character
set.
Shift
F1: Greek Remaps the keyboard to allow the input of the
Greek Character set.
F2: Last Recalls the last line statement entered.
F3: Save Saves the current input to a buffer for later
recall (See F4 : Recall ).
F4: Recall Recalls last statement saved to a buffer (See
F3: Save ).
F5: Program Activates screen editor for defining proce-
dures.
F6: Dos Activate command processor giving the user
access to such dos shell commands as COPY and
DIR.
F7: Help Activates help.
6
Copyright 1987, 1989 Cerebral Software
TABLE II
Special Character Keys
(Program and Interpreter Modes)
When the function key F1: Greek or Shift F1: Greek is acti-
vated, the key board is remapped as follows:
Key Remap
A,a alpha
B,b beta
D DELTA
d delta
E,e epsilon
F PHI
f phi
G,g GAMMA
I,i infinity
M,m mu
O,o OMEGA
P PI
p pi
S SIGMA
s sigma
T THETA
t tau
All other keys remain the same.
Other special keys are :
Ctrl A Vertical bar which represents the
magnitude character.
Ctrl D Highlighted D which represents the
derivative character.
Ctrl K Highlighted INTEGRAL character which
represents the integral character.
Ctrl L Highlighted d which represents the
differential character.
7
Copyright 1987, 1989 Cerebral Software
TABLE III
Program Edit and Function Keys
Key
Combination Description
<- Moves the cursor one space to the left.
-> Moves the cursor one space to the right.
Moves the cursor up one line.
Moves the cursor down one line.
Back Space Deletes input immediately before the cursor.
Ctrl <- Moves the cursor 8 spaces to the left or to
the beginning of the line.
Ctrl -> Moves the cursor 8 spaces to the right to the
end of the line.
Ctrl End Deletes input from the cursor to end of line.
Ctrl PgDn Deletes input from cursor to end of text.
Program requires confirmation before per-
forming this task.
Del If block mode is active then whole block is
deleted. If block mode is inactive then
input at the cursor is deleted.
End Moves the cursor to the end of the line
Ins Toggles insert mode. Cursor size indicates
mode status : A large cursor indicates
character will be inserted at the cursor; a
small cursor indicates characters will be
overwritten.
Home Moves the cursor to the front of the line.
PgUp Moves the cursor to the top of the screen or
to the preceding page.
PgDn Moves the cursor to the bottom of the screen
or to the following page.
Shift Tab Moves the cursor 8 positions to the left.
8
Copyright 1987, 1989 Cerebral Software
9
Copyright 1987, 1989 Cerebral Software
TABLE III cont'd
Compiler Function Keys
Key
Combination Description
F1: Greek Remaps the keyboard to allow the input of
Greek character set. Once a key is struck,
the keyboard reverts to the Roman character
set.
Shift
F1: Greek Remaps the keyboard to allow the input of the
Greek character set.
F2: Block Activates block mode. When this mode is
active the functions of F4: Save and F4:
Load is changed. Text is saved or loaded
from a temporary buffer. Otherwise text is
saved or loaded to disk.
F3: Save If block mode is active then the block is
saved to a temporary buffer. If the text
has been successfully compiled then the
procedure is saved to a file of the same name
in the current directory; the extension
".PRC" is appended to the file name. If the
file has not been compiled then the user is
prompted for a file name.
F4: Load Prompts the user for a procedure file to
load. If no file is specified then text from
the temporary buffer is written at the
cursor.
F5: Quit Quits the editor and returns the user to the
interactive interpreter mode. The current
procedure is saved to a file of the same name
if the file has been compiled; otherwise, the
user is prompted for a name.
F6: Compile Compiles current input text and displays
errors.
10
Copyright 1987, 1989 Cerebral Software
IV.Structure
AMP can recognize numbers, variables, functions, summations,
products, derivatives, and integrals. All these quantities
except numbers are abstract and have no particular numerical
value. With these quantities the user can build complex expres-
sions, equations, or relations.
Labels
The label is an alphanumeric string consisting of no more
than ten alphanumeric characters. It is comparable to a label
found beside an equation or relation in an engineering or
scientific textbooks. For example
f(x) = x (Q1)
is an equation describing the function f. Q1 is the label
associated with the equation f(x)=x. An AMP equation is written
Q1 : f(x) = x
A label may also be subscripted. Subscripted labels may be
defined with no more than four subscripts and must be declared
using a LABEL statement:
LABEL A[1..3, 1..3, 1..3, 1..3] , Q[1..10] , E
In the above examples, "E" is a label with no subscripts. "Q" is
the label with one subscript, "A" is a label with the maximum of
four subscripts. The above statement is equivalent to the
dimension declaration in BASIC.
Labels with no subscripts can be declared implicitly when an
expression, equation or relation is defined.
Other examples of labels are as follows:
Q[1] : f(t)=t^2/2 + f(0)
Q[2] : g(t)=t^2 + f(1)
E : a + b
The labels Q[1],Q[2] correspond to equations which describe
functions "f" and "g". "E" corresponds to the expression "a +
b".
Imaginary Unit
11
Copyright 1987, 1989 Cerebral Software
The default imaginary unit is "i" and can be changed to the
letter "j" by the following declaration :
imaginary j
Constants
AMP can accept either real or complex constants whose parts
are integers, rationals, or floating point numbers. Floating
point numbers are numeric strings followed by a decimal point and
another numeric string and then an optional exponent, or it may
be a numeric string followed by an exponent. Imaginary parts of
numbers are any valid number immediately followed by the
imaginary unit. Examples of valid constants are :
100 Integer
10/25 Rational
12.5 Floating Point
19e10 Floating Point
1.95e34 Floating Point
1+10i Complex
23/57 + 1.2e3i Complex
Integers may range from -32768 to 32767. Floating point
numbers may range from 4.19X10E-307 to 1.67X10E308.
Units
Units are declared alphanumeric strings of no more than 10
characters. The first character must be a letter. A unit
declaration is used to denote units. For example :
UNITS cm, sec, dyne, m
defines some of the more common metric units2.
Indices and Index Expressions
An index consists of a single alpha character in lower case.
An index expression is an algebraic expression consisting of
indices and real rational numbers. Examples of valid index
expressions are:
j + 3/2
6*k*l+j
2 If you type UNITS <cr>, then AMP will report
the units you have defined.
12
Copyright 1987, 1989 Cerebral Software
1/2
Variables
Variables consist of an alphanumeric string of no more than
ten characters. The first character must be a letter. Optional
subscripts containing index expressions may be specified. The
subscripts must be surrounded by square brackets ("[","]") and
separated by commas. All subscripted variables are limited to no
more than four subscripts. Examples of valid variables :
speed "speed" is the name of a variable with no
subscripts.
SPEED[1,n+j,k^2] "SPEED" is the name of a variable with three
subscripts. "n","j","k" are indices. Note
that "SPEED" is different from "speed"
because of case sensitivity for variables.
d[j] "d" is the name of a variable with one sub-
script. "j" is the index.
Functions
Functions consist of an alphanumeric string of no more than
ten characters. The first character must be a letter. Any
function may have from one to four arguments. All the arguments
are surrounded by parenthesis and separated by commas. Optional
subscripts containing index expressions may be specified. The
subscripts must be surrounded by square brackets ("[","]") and
separated by commas. Examples of valid functions :
pos(Var + VAR[2,n+j,k^2]) "pos" is the name of a function
with one argument.
J[0](12.3+Var) "J" is the name of a function with
one subscript and one argument.
f[k,l,m,n](arg1,arg2,arg3) "f" is the name of a function with
four subscripts and three argu-
ments.
Standard Functions
All standard functions consist of only one argument. They
are :
ArcHypCos inverse hyperbolic cosine
ArcHypSin inverse hyperbolic sine
ArcHypTan inverse hyperbolic tangent
13
Copyright 1987, 1989 Cerebral Software
HypCos hyperbolic cosine
HypSin hyperbolic sine
HypTan hyperbolic tangent
ArcCos inverse cosine
ArcSin inverse sine
ArcTan inverse tangent
Cos cosine
Sin sine
Tan tangent
Exp natural exponential function
Ln natural logarithm
Log common logarithm
AMP has the capability to evaluate the standard functions
when the argument is a real number. For example Sin(3.1415/2)
will return 1.00.3
Summations
Summations consist of the special greek character SIGMA
followed by an optional bounds of summation and then followed by
an argument. For example:
SIGMA{j=1,infinity}(a[j])
would be written in more conventional notation as
SIGMAinfinitya[j] = a[1]+a[2]+a[3] . . .
j=1
An optional step factor may be added so that
SIGMA{j=2,infinity,2}(a[j]) = a[2]+a[4]+a[6] . . .
The bounds of summation may be omitted:
SIGMA{j}(a[j]) or SIGMA(a[j]).
Products
3 Since AMP is case sensitivity with regards to standard
functions, you must type the standard functions exactly
as shown.
14
Copyright 1987, 1989 Cerebral Software
Products consist of the special greek character PI followed
by an optional bounds of multiplication and then followed by an
argument4. Its structure will be illustrated by example.
PI{j=1,infinity}(a[j])
would be written in more conventional notation as
PIinfinity(a[j]) = a[1]*a[2]*a[3] . . .
j=1
An optional step factor may be added so that
PI{j=2,infinity,2}(a[j]) = a[2]*a[4]*a[6] . . .
The bounds of multiplication may be omitted:
PI{j}(a[j]) or PI(a[j]).
Derivatives
Derivatives consist of the highlighted "D" character (which
is accessed by Ctrl D on the keyboard) followed by a list of
differentials and their orders and then followed by an argument.
Optional evaluation points may be specified.
D[x|2,y|3](f(x,y))@(x=0,y=1)
would be written in more conventional notation as
d5
---- f(x,y) @ x=0,y=1
d3xd2y
All derivatives are limited to a maximum of four differentials
and four evaluation points.
Integrals
Integrals consist of the highlighted "integral" character
(which is accessed by Ctrl K on the keyboard) followed by an
optional bounds of integration, followed by an argument and then
a differential. The differential consists of the highlighted "d"
character (accessed by Ctrl L on the keyboard) followed by a
differential argument.
4 The AMP key board gives you access to an upper case and
a lower case . The upper case must be used for products.
15
Copyright 1987, 1989 Cerebral Software
"integral"{a,b} g(x) d(x)
(Remember "integral" is Ctrl K)
(Remember d - differential is Ctrl L)
would be written in more conventional notation as
_
|a g(x) dx
|b
-
Expressions
Expressions are quantities consisting of the arithmetic
operators (-,+,*,/,^) and the quantities described thus far.
An example of an expression :
c*(a + b)^2 + D[x](f(x))
Magnitudes
Magnitudes are expressions enclosed by vertical bars
(accessed by Ctrl A on the keyboard). AMP simplifies all
magnitudes. If the quantity inside a magnitude is a complex or
negative number then it is evaluated. An expression may contain
any number of magnitudes. An example of a magnitude :
½ßTa + i*b½ßT
Equations
An equation consists of two expressions separated by an
equal sign "=". An example of an equation :
x^2 + y^2 = a^2
Relations
A relation consists of two or three expressions separated by
inequalities. Examples are :
x^2 + y^2 <= c^2
0< "integral"{a,x} f(t) d(t) < x
(Remember "integral" is Ctrl K)
(Remember d - differential is Ctrl L)
Procedures
16
Copyright 1987, 1989 Cerebral Software
Procedures are sequences of statements which are grouped
together with a procedure heading. They are much like the
procedures that found in other programming languages such as
FORTRAN. The big difference between an AMP procedure and a
procedure in these other programming languages is that AMP allows
for complex symbol manipulation and not just number crunching.
The only limitation is that AMP doesn't contain "IF THEN ELSE"
constructs; however, the procedure definition capability is very
useful. The procedure heading consists of the reserved word
PROCEDURE followed by the procedure name, followed by an argument
list enclosed in parenthesis. For example :
PROCEDURE TEST(INTEGER M,N ; LABEL L ; PARAMETER p,q ; INDEX j) ;
is a procedure heading used in the procedure definition. The
reserved words INTEGER, LABEL , PARAMETER, INDEX, VARIABLE and
FUNCTION are used to describe the attributes of the arguments.
The arguments, p and q, of type PARAMETER may be constants,
indices, variables, functions, standard functions, derivatives,
integrals, expressions, or even labels (provided those labels
have expressions assigned to them). Many examples of procedures
are given in the command dictionary. Rules for procedure usage
are given in chapter VII.
Special Operators
There are two special operators which are very important: The
definition operator, ":" and the assignment operator ":=". The
definition operator is used to define expressions, equations, or
relations. Consider the following example :
R : a < b < c
E : x + 1
"a < b < c" is a relation among the variables "a", "b", and "c"
and the label for this relation is "R". "x + 1" is an expression
and the label for this expression is "E".
Operations can be performed using combinations of relations,
equations and expressions; these operations are performed using
the assignment operator, ":=". For example we can add the twice
the expression "x + 1" to the relation "a < b < c". by entering
the following assignment statement :
R:=R+2*E
The resulting relation is :
R : a + 2*x + 2 < b + 2*x + 2 < c + 2*x + 2
17
Copyright 1987, 1989 Cerebral Software
Chapter VIII on relation operations gives a detailed discussion.
V.Tutorial
Numerical Calculations
All expressions must have labels. This includes expressions
which contain only numbers. Try typing a few numerical
expressions.
Type in E1 : 4/5 + 9/2 (cr)
Result E1 : 53/10
Note that the result is a rational number. AMP has the
capability to do rational arithmetic. Rational numbers may
contain integers up to 32767. If you wish to convert the
previously defined number to a floating point number then
Type in E1 := DECIMAL(E1)
Result E1 : 5.30
You may abbreviate the command DECIMAL to DEC. AMP allows
you to abbreviate many of the longer reserved words to the first
three to five letters (See Command Dictionary). Another
alternative to converting a rational number to a floating point
number is to multiply the rational number by the floating point
number 1.0.
Type in E1 : 53/10
Type in MULTIPLY 1.0
Result E1 : 5.30
You can declare mneumonics for repetitively used constants
and then later recall them5.
Type in CONSTANT TwoPi=6.28318530
Type in E2 : TwoPi/2
Result E2 : 3.14
5 You can get a report of the constants you have defined
by typing "CONSTANT <cr>" at the prompt.
18
Copyright 1987, 1989 Cerebral Software
Observe that AMP rounds to the first two digits after the
decimal point. This particular rounding is the default display
mode for floating point numbers. If you wish to display floating
point numbers with a maximum of 10 places with four digits after
the decimal point then
Type in FLOAT 10.4
Type in LIST E2
Result E2 : 3.1416
You can display more digits after the decimal point. For
example typing FLOAT 10.8 will display 8 digits after the decimal
point. If a number cannot fit into the floating point
specification then AMP defaults to scientific notation. AMP can
display a maximum of 15 digits for floating point numbers.
AMP can evaluate the most commonly used functions.
Type in E3 : 3*Sin(pi/3) where pi is predefined as
3.141592654
Result E3 : 2.5891
The functions that AMP can evaluate are6 :
ArcHypSin Inverse Hyperbolic Sine
ArcHypCos Inverse Hyperbolic Cosine
ArcHypTan Inverse Hyperbolic Tangent
ArcSin Inverse Sine
ArcCos Inverse Cosine
ArcTan Inverse Tangent
HypSin Hyperbolic Sine
HypCos Hyperbolic Cosine
HypTan Hyperbolic Tangent
Sin Sine
Cos Cosine
Tan Tangent
Exp Natural Exponent
Log Common Logarithm
6 If you type "STANDARD <cr>" at the prompt, then AMP
will display all the standard functions which are
available.
19
Copyright 1987, 1989 Cerebral Software
Ln Natural Logarithm
Since AMP is case sensitive the functions must be typed
exactly as shown.
Now try an example using the Ln function.
Type in E4 : Ln(0)
After typing this expression you get an error message at the top
of the screen telling you that the argument of Ln is not
permitted. The cursor is positioned at the offending argument.
You may type over the erroneous text. If,instead, you wish to
type a whole new line then press the (Esc) and
Type in E4 : Ln(1)
Result E4 : 0.0000e0
You may use up to eight levels of parentheses in a numeric
expression just as you would with a calculator.
You can also use AMP to take the square root of a number or
to do complex arithmetic :
Type in E4 : 2^(1/2) (cr)
Result E4 : 1.4142
Type in E5 : 1 + 1i (cr)
Type in E6 : 2 + 2i (cr)
Type in E7 := E5*E6 (cr)
Result E7 : 4i
Type in E8 : 2* E7 (cr) (The magnitude character is Ctrl A)
Result E8 : 8.0000
AMP observes the usual precedence for operations. If you
had typed E4 : 2^1/2 you would get a result of 1 since
exponentiation has a higher precedence than division.
Simplifications
AMP has two display modes, normal and neat. The neat mode
displays output in two dimensions. The normal mode gives a one
20
Copyright 1987, 1989 Cerebral Software
dimensional output and is the default display mode. To set the
neat display mode
Type in DISPLAY NEAT (cr)
Type in EQ : 2/3*c*y + 2*c*y + 3*a + a = 4*a + 2*a + 3*b (cr)
Result EQ :
8*c*y
4*a + ----- = 6*a + 3*b
3
Note that 2/3*c*y and 2*c*y have been added together to give
8*c*y/3 and that all terms involving a have been added together
where valid. Note also that 4*a appears before 8*c*y/3 on the
left side of the equation: AMP lexigraphically orders all terms
as it simplifies. However, the ordering is clearly evident only
when in the normal display mode.
Now try to solve for y. To do this you must subtract 4*a
from both sides of the equation.
Type in SUBTRACT 4*a (cr)
Result EQ :
8*c*y
----- = 2*a + 3*b
3
Type in DIVIDE 8/3*c (cr)
Type in DISTRIBUTE 1/c (cr)
Result EQ :
3*a 9*b
y = --- + ---
4*c 8*c
If you wish to solve for y/a then
Type in DIVIDE a (cr)
Type in DISTRIBUTE 1/a
Result EQ :
1*y 9*b 3
--- = ----- + ---
a 8*a*c 4*c
You can also use AMP to expand expressions. For example:
21
Copyright 1987, 1989 Cerebral Software
Type in E : (a + b)*(c + d)^2 (cr)
Type in EXPAND (c + d)^2 (cr)
Result E :
2 2
(a + b)*(c + 2*c*d + d )
Type in EXPAND (cr)
Result E :
2 2 2 2
a*c + 2*a*c*d + a*d + b*c + 2*b*c*d + b*d
Two Equations
To solve two equations in two unknowns, define a one
dimensional label7
Type in LABEL Q[1..2]
Two equations Q[1] and Q[2] will be defined. The unknowns in
these equations will be the variables x and y. A solution for y
will be found first.
Type in Q[1] : a1*x + b1*y = c1 (cr)
Type in Q[2] : a2*x + b2*y = c2 (cr)
Type in IN Q[1] DIVIDE a1 (cr)
Type in EXPAND (cr)
Result Q[1] :
1*b1*y 1*c1
------ + x = ----
a1 a1
Type in IN Q[2] DIVIDE a2 (cr)
Type in EXPAND (cr)
Result Q[2] :
7 If you type "LABEL <cr>" at the prompt, then
AMP will display all the labels which you
have defined.
22
Copyright 1987, 1989 Cerebral Software
1*b2*y 1*c2
------ + x = ----
a2 a2
The variable x must be removed from the two equations. This
is done by subtracting equation Q[2] from Q[1].
Type in Q[1]:=Q[2]-Q[1]
Type in COLLECT y
Result Q[1] :
1*b1 1*b2 1*c1 1*c2
y*( - ---- + ----) = - ---- + ----
a1 a2 a1 a2
Type in C := COEFF(y) Q[1]
Note that since the label C has no dimensioning, it is not
necessary to declare it before usage.
Result C :
1*b1 1*b2
- ---- + ----
a1 a2
Type in Q[1]:=Q[1]/C
23
Copyright 1987, 1989 Cerebral Software
Result Q[1] :
1*c1 1*c2
1*( - ---- + ----)
a1 a2
y = ------------------
1*b1 1*b2
( - ---- + ----)
a1 a2
Type in Y := RIGHT Q[1]
Note that Y is a label is implicitly declared as having zero
dimension. y is a variable. Y is a label for the expression
which is the solution for y.
Type in IN Q[2] REPLACE y BY Y
Result Q[2] :
1*c1 1*c2
1*b2*( - ---- + ----)
a1 a2 1*c2
--------------------- + x = ----
1*b1 1*b2 a2
a2*( - ---- + ----)
a1 a2
Type in SUBTRACT x + c2/a2
Type in SWITCH
Type in MULTIPLY -1
Result Q[2] :
1*c1 1*c2
1*b2*( - ---- + ----)
a1 a2 1*c2
x = - --------------------- + ----
1*b1 1*b2 a2
a2*( - ---- + ----)
a1 a2
24
Copyright 1987, 1989 Cerebral Software
Matrix Manipulation
Suppose you have a 3X3 matrix, A, whose eigenvectors you
wish to find. Suppose also that A is :
½ßT2 0 1½ßT
½ßT ½ßT
A = ½ßT0 1 0½ßT
½ßT ½ßT
½ßT1 0 2½ßT
First declare A as a multidimensional label.
Type in LABEL A[1..3,1..3] (cr)
A has been declared a 3X3 label. Assignments must be made for
each component of A.
Type in A[1,1] : 2
Type in A[1,2] : 0
Type in A[1,3] : 1
Type in A[2,1] : 0
Type in A[2,2] : 1
Type in A[2,3] : 0
Type in A[3,1] : 1
Type in A[3,2] : 0
Type in A[3,3] : 2
If you wish to review the entries then
Type in LIST A (cr)
All the entries are echoed to the screen by column. Next define
a diagonal matrix, D. First, declare the label:
Type in LABEL D[1..3,1..3] (cr)
Most of the entries for D will be zero and you could enter
each of the components one by one as you did for the components
of A. Instead, a better method will be outlined:
Type in ITERATE I FROM 1 TO 3
25
Copyright 1987, 1989 Cerebral Software
Type in ITERATE J FROM 1 TO 3
The quantities I and J are iteration variables. They allow
you to make multiple statement assignments as well as issuing
commands which allow you to manipulate more than one equation or
expression at a time.
First make the whole D matrix a zero matrix:
Type in D[I,J] : 0
Result D[1,1] : 0
D[2,1] : 0
D[3,1] : 0
D[1,2] : 0
D[2,2] : 0
D[3,2] : 0
D[1,3] : 0
D[2,3] : 0
D[3,3] : 0
You could compare the above statements to the iterative BASIC
assignment statement :
10 FOR I=1 TO 3
20 FOR J = 1 TO 3
30 D[I,J] = 0
40 NEXT J
50 NEXT I
Next, assign d to the diagonal:
Type in D[I,I] : d
Result D[1,1] : d
D[2,2] : d
D[3,3] : d
Declare one more matrix B:
Type in LABEL B[1..3,1..3]
Type in B[I,J] := D[I,J] - A[I,J]
Result B[1,1] : d - 2
B[2,1] : 0
B[3,1] : - 1
B[1,2] : 0
B[2,2] : d - 1
26
Copyright 1987, 1989 Cerebral Software
B[3,2] : 0
B[1,3] : - 1
B[2,3] : 0
B[3,3] : d - 2
The determinant of B must now be determined. Since the
computation of determinants from 3X3 matrices is a fairly common
operation, then a procedure should be written. Depress function
key F5 : Program to invoke the screen editor. Then type the
following procedure :
PROCEDURE DET3X3(LABEL MAT, DET) ;
LABEL M11, M12, M13 ;
M11 := MAT[2,2]*MAT[3,3]-MAT[2,3]*MAT[3,2] ;
M12 := MAT[2,1]*MAT[3,3]-MAT[3,1]*MAT[2,3] ;
M13 := MAT[2,1]*MAT[3,2]-MAT[3,1]*MAT[2,2] ;
DET := M11*MAT[1,1] - M12*MAT[1,2] + M13*MAT[1,3] ;
EXPAND ;
EXIT
Once you have entered this procedure press function key F6 :
Compile to compile the procedure. Any errors are flagged. (If
you find that you have errors, correct them and compile again.)
Now return to the interpreter by pressing function key F5 :
Quit. The procedure is automatically saved to the file
"DET3X3"8. If you wish to get a listing of all the procedures
that are defined then
Type in PROCEDURE
Result DET3X3(LABEL MAT, DET)
Now you are ready to compute the determinant of B:
Type in LABEL DET (cr)
Type in DET3X3(B, DET) (cr)
Result DET : d^3 - 5*d^2 + 7*d - 3
8 You can recall the procedure at future sessions. This
is done by pressing F4 : Load. You are then asked for
a file name. Typing DET3X3 at the prompt recalls the
program. When the file is saved to disk, the extension
"PRC" is appended to the file name. This extension is
transparent to the user.
27
Copyright 1987, 1989 Cerebral Software
We must now factor the above determinant polynomial. The
constant in the above expression is a prime number and the
candidates for factors are d - 1, d + 1, d - 3, d + 3.
Type in R1 := REMAINDER(d + 3) DET
Result R1 : - 96
Type in R1 := REMAINDER(d - 3) DET
Result R1 : 0
Type in Q1 := QUOTIENT(d-3) DET
Result Q1 : d^2 - 2*d + 1
At this point you can see that DET = (d - 1)^2 * (d - 3)
Thus the roots are 1,1,3. They must be substituted back into the
matrix B. Before you substitute this value back into B you
should save it.
Type in LABEL T[1..3,1..3] (cr)
Type in T[I,J]:=B[I,J]
Type in IN B[I,J] REPLACE d BY 1
Result B[1,1] : -1
B[2,1] : 0
B[3,1] : -1
B[1,2] : 0
B[2,2] : 0
B[3,2] : 0
B[1,3] : -1
B[2,3] : 0
B[3,3] : -1
From the above matrix we can explicitly find the equations
defining the eigenvectors :
Type in LABEL V1[1..3], V2[1..3], Q[1..3]
Type in V1[1] : x
V1[2] : y
V1[3] : z
Type in ITERATE I FROM 1 TO 3
ITERATE J FROM 1 TO 3
28
Copyright 1987, 1989 Cerebral Software
Type in V2[I]:=SUM(J) B[I,J]*V1[J]
Result V2[1] : - x - z
V2[2] : 0
V2[3] : - x - z
Type in Q[I] : V2[I] = 0
Result Q[1] : - x - z = 0
Q[2] : 0 = 0
Q[3] : - x - z = 0
From the above equations (0,1,0) and (1,0,1) are two
eigenvectors. By substituting 3 for d in the matrix T a third
eigenvector can be found.
29
Copyright 1987, 1989 Cerebral Software
Identities
With AMP's procedure definition capabilities you can write
procedures to do function substitution, rudimentary
differentiation and integration. Again invoke the screen editor
and type in the following statements :
PROCEDURE TRIGSUB(LABEL L ; PARAMETER a,b) ;
IN L REPLACE Sin(a + b) BY Sin(a)*Cos(b) + Cos(a)*Sin(b) ;
IN L REPLACE Cos(a + b) BY Cos(a)*Cos(b) - Sin(a)*Sin(b) ;
EXIT
Compile the above procedure and quit the screen editor.
Type in T1 : a*Cos(a + b + c) + b*Sin(a + b + c)
Now we wish to expand the above trig expression in terms of a + c
and b. Thus
Type in TRIGSUB(T1,(a + c),b)
Result T1 : a*(Cos(a + c)*Cos(b) - Sin(a + c)*Sin(b))
+ b*(Cos(a + c)*Sin(b) + Cos(b)*Sin(a + c))
You can also use procedures to accomplish integration and
differentiation.
PROCEDURE TRIGCALC(LABEL L) ;
LABEL x,y,lb,ub ;
y := INTEGRAL L ;
x := DIFFERENTIAL y ;
lb:= LOWBOUND y ;
ub:= HIGHBOUND y ;
IN L REPLACE "integral"{lb,ub} Cos(x) d(x) BY Sin(ub) - Sin(lb)
;
IN L REPLACE D[x](Cos(x)) BY - Sin(x) ;
EXIT
(Remember --- Ctrl k for integral character or "integral",
Ctrl l for differential character or d,
Ctrl D for derivative character of D)
Note that each statement is seperated by the delimeter ";".
Compile and save this procedure. Then return to the interactive
interpreter mode.
Type in E : "integral"{a, a + 3} Cos(y/z) d(y/z) +
D[y/z](Cos(y/z))
30
Copyright 1987, 1989 Cerebral Software
(Remember Ctrl k for "integral")
(Remember Ctrl l is differential d)
Type in TRIGCALC(E)
Result E : Sin(a + 3) - Sin(a) - Sin(y/z)
Special Differentiation
Type in E : x^5 + x^4 + x^3 + x^2
Type in F : D[x](E) (cr)
Result F : D[x](x^5 + x^4 + x^3 + x^2)
Type in DIST D (cr) (Again Ctrl D for derivative character)
Result F : D[x](x^5) + D[x](x^4) + D[x](x^3) + D[x](x^2)
Type in ITERATE I FROM 2 TO 5
Type in ON I REPLACE D[x](x^I) BY I*x^(I-1)
Result F :
4 3 2
5*x + 4*x + 3*x + 2*x
31
Copyright 1987, 1989 Cerebral Software
VI.Command Dictionary
AMP operates in two modes: the interpreter mode and the
compiler mode. The following dictionary describes each command
for both modes.
The collection of expressions, equations, and relations with
their labels is the database for AMP. When you type an equation,
expression or relation on the AMP command line while in the
interpreter mode, you are adding it to the database.
Examples are given with each command. Lines in the examples
which are proceeded by "~" are items which you type and are
assumed to end with a carriage return.
Although AMP is case sensitive, reserved words are an
exception: They may be entered in either upper or lower case.
However, reserved words are shown only in upper case in the
dictionary.
In many of the commands the term STRICTLY is used. This
word refers to how factors are matched. Two terms with the same
variables and functions are said to match strictly if all
variables and functions are raised to the same exponent. For
example the terms 2*a^2*b^2 and 5*a^2*b^2 match strictly because
the variables a and b in each of the terms are raised to the same
exponent. Two terms are said to match if they contain the same
variables and functions. For example 2*a^2*b and 5*a*b match;
however, they do not match strictly because a is raised to
different exponents in each of the terms.
32
Copyright 1987, 1989 Cerebral Software
Conventions in Syntactic Forms
monospaced text means use exactly as indicated.
italics indicates items you must replace with your
own symbols.
{} encloses optional items. When the optional
item contains a delimeter such as ',' or ';',
then the item within the brackets may be
repeated more than once.
{|} indicates a choice of an optional item. E.
g. {ON|OFF} indicates that you have the
optional choice of ON or OFF.
Ellipses Vertical ellipses are used in program
examples to indicate that a portion of a
program has been omitted for space
considerations.
. . . Indicates that non-essential information has
been omitted for space considerations.
33
Copyright 1987, 1989 Cerebral Software
":" -- DEFINITION OPERATOR
Syntax label : expression {= expression}
label : expression {r1 expression{r2 expression}}
Where r1 and r2 are the relations (<,>,<=,>=,=<,=>). If r1
is <, <= or =< then r2 is restricted to <,<=,=<. If
r1 is >, >=, => then r2 is restricted to >,>=,=>.
Restrictions expression may contain labels; however, only
expressions may be associated with the labels.
AMP will flag an error if equations or relations
are associated with labels in expression.
Purpose Allows input into the database.
Examples
Option 1 : Single assignment
~E : x + ArcHypSin(x) + "integral"{0,x} Sin(t) d(t)
Comment "E" is the label corresponding to the expression "x +
ArcHypSin(x) + "integral"{0,x} Sin(t) d(t)".
(Remember Ctrl k for "integral")
(Remember Ctrl l is differential d)
~LABEL Q[1..2]
~Q[1] : f(x) = D[x|2,y|2](h(x,y))@(y=0)
~Q[2] : g(x) = x + INTEGRAL{0,x} t^2 + cos(t) + i*sin(t) d(t)
Comment Q is a one dimensional label with two components which
are equations describing the functions f and g.
~LABEL R[1..2]
~R[1] : 0 < x
~R[2] : 0 <= g(x) < f(x)
Comment R is a one dimensional label with two components which
are relations. The first relation defines the range of
the variable x and the second relation describes the
relation between the functions f and g.
34
Copyright 1987, 1989 Cerebral Software
Option 2 : Multiple assignment
~LABEL A[1..3,1..3]
~ITERATE I FROM 1 TO 3
~ITERATE J FROM 1 TO 3
~A[I,J] : I + J
A[1,1] : 2
A[2,1] : 3
A[3,1] : 4
A[1,2] : 3
A[2,2] : 4
A[3,2] : 5
A[1,3] : 4
A[2,3] : 5
A[3,3] : 6
Comment A is a 2 dimensional label with 9 components. The
above sequence of statements could be compared to the
following iterative assignment statement in BASIC:
FOR I = 1 TO 3
FOR J = 1 TO 3
A[I,J] = I + J
NEXT J
NEXT I
~LABEL A[1..3,1..3]
~ITERATE I FROM 1 TO 3
~ITERATE J FROM 1 TO 3
~A[I,J] : s[I+k,J+m] + D[x|I](f(x)) + D[y|J](g(x)
A[1,1] : s[k+1,m+1] + D[x](f(x)) + D[y](g(x))
A[2,1] : s[k+2,m+1] + D[x|2](f(x)) + D[y](g(x))
A[3,1] : s[k+3,m+1] + D[x|3](f(x)) + D[y](g(x))
A[1,2] : s[k+1,m+2] + D[x](f(x)) + D[y|2](g(x))
A[2,2] : s[k+2,m+2] + D[x|2](f(x)) + D[y|2](g(x))
A[3,2] : s[k+3,m+2] + D[x|3](f(x)) + D[y|2](g(x))
A[1,3] : s[k+1,m+3] + D[x](f(x)) + D[y|3](g(x))
A[2,3] : s[k+2,m+3] + D[x|2](f(x)) + D[y|3](g(x))
A[3,3] : s[k+3,m+3] + D[x|3](f(x)) + D[y|3](g(x))
Comment The variable a contains two indices k and m. Note how
the iterations I and J are used.
35
Copyright 1987, 1989 Cerebral Software
Example with Procedure
PROCEDURE ASSIGN(INTEGER N ; LABEL L ; PARAMETER p) ;
ITERATE I FROM 1 TO N ;
L[I] : p ;
EXIT
~LABEL B[1..3]
~ASSIGN(3,B,(x+s[k,m]))
B[1] : s[k,m] + x
B[2] : s[k,m] + x
B[3] : s[k,m] + x
36
Copyright 1987, 1989 Cerebral Software
":=" - ASSIGNMENT OPERATOR
Syntax label := expression or
label 2 := reserved word{(argument list)} label 1
Where expression consists of labels and numbers and
parenthesis.
Purpose Permits the combining of expressions, equations or
relations. When relations are involved, only
mathematically valid operations are permitted.
Note When relations are used, AMP checks for validity of
operations. (See Chapter VIII - Relation Arithmetic)
Example
~R1 : x < x + y < z
R1 : x < x + y < z
~E1 : x
E1 : x
~R2:=R1-E1
R2 : 0 < y < -x + z
37
Copyright 1987, 1989 Cerebral Software
Example with Procedure
PROCEDURE Example(INTEGER N ; LABEL L ; PARAMETER P) ;
ITERATE I FROM 1 TO N ;
ITERATE J FROM 1 TO N ;
LABEL M[1..N,1..N] ;
M[I,J] : 0 ;
M[I,I] : P ;
L[I,J] := L[I,J] - M[I,J] ;
EXIT
~ECHO OFF
~LABEL A[1..3,1..3], D[1..3,1..3]
~ITERATE I FROM 1 TO 3
~ITERATE J FROM 1 TO 3
~A[I,J] : 0
~LIST A
A[1,1] : 0
A[2,1] : 0
A[3,1] : 0
A[1,2] : 0
A[2,2] : 0
A[3,2] : 0
A[1,3] : 0
A[2,3] : 0
A[3,3] : 0
~Example(3,A,d)
~LIST A
A[1,1] : -d
A[2,1] : 0
A[3,1] : 0
A[1,2] : 0
A[2,2] : -d
A[3,2] : 0
A[1,3] : 0
A[2,3] : 0
A[3,3] : -d
38
Copyright 1987, 1989 Cerebral Software
ADD
Syntax {IN label} {ON iteration} ADD expression
Purpose Adds expression to an expression, equation, or
relation.
Restrictions expression may contain labels; however, only
expressions may be associated with the labels.
AMP will flag an error if equations or relations
are associated with labels in expression.
Example
~R1 : - c < - c + x < - c + d
R1 : - c < -c + x < - c + d
~IN R1 ADD c
R1 : 0 < x < d
Example with Procedure
PROCEDURE Example(INTEGER N ; LABEL L ; PARAMETER P) ;
ITERATE I FROM 1 TO N ;
IN L[I] ADD P ;
EXIT
~LABEL V[1..3]
~ITERATE I FROM 1 TO 3
~V[I] : 0
V[1] : 0
V[2] : 0
V[3] : 0
~Example(3,V,(c + d))
V[1] : c + d
V[2] : c + d
V[3] : c + d
39
Copyright 1987, 1989 Cerebral Software
ARGUMENT
Syntax ARGUMENT
Purpose Show whether trigonometric function arguments are
degrees, radians or gradians.
Note The default argument is radians.
Abbreviation ARG
Note
Example
~ARGUMENT
radians
Note : Command cannot be used in a procedure.
40
Copyright 1987, 1989 Cerebral Software
CENTER
Syntax label 2 := CENTER label 1
Purpose The center expression of label 1 is assigned to label 2
Example
~R1 : c < d < e
R1 : c < d < e
~E1:=CENTER R1
E1 : d
Example with Procedure
PROCEDURE Example(LABEL L1,L2) ;
L2 := CENTER L1 ;
EXIT
~R1 : c < d < e
R1 : c < d < e
~LABEL E1
~Example(R1,E1)
E1 : d
41
Copyright 1987, 1989 Cerebral Software
CLEAR
Syntax CLEAR label
Purpose Removes label from the database.
Note Using this command excessively may cause
error, "Label table overflow". When this
command is used table locations are not
reclaimed.
Example
~LABEL A[1..3,1..2]
~CLEAR A
42
Copyright 1987, 1989 Cerebral Software
COEFFICIENT ISOLATE
Syntax label := COEFFICIENT(expression{,occurrence}) label
Where occurrence is the number of the term. The default
value is one.
Purpose Isolates the coefficient of a factor .
Abbreviation COEF
Example
~E1 : 4*x*y + 2*x*z
E1 : 4*x*y + 2*x*z
~E2 := COEFFICIENT(x) E1
E2 : 4*y
~E3 := COEFFICIENT(x,2) E1
E3 : 2*z
Note "COEFFICIENT(x,2)" isolates the coefficient of x of the
second term.
Example with Procedure
PROCEDURE Example(INTEGER N ; LABEL L1,L2 ; PARAMETER P) ;
ITERATE I FROM 1 TO N ;
L2[I]:=COEFFICIENT(P) L1[I] ;
EXIT
~LABEL V[1..3]
~ITERATE I FROM 1 TO 3
~V[I] : v[I]*x
V[1] : v[1]*x
V[2] : v[2]*x
V[3] : v[3]*x
~Example(3,V,V,x)
V[1] : v[1]
V[2] : v[2]
V[3] : v[3]
43
Copyright 1987, 1989 Cerebral Software
COLLECT TERM
Syntax {IN label} {ON iteration} COLLECT {STRICTLY} term
Purpose Collects common terms in an expression, equation or
relation.
Abbreviation COL for COLLECT
Restrictions term may contain labels; however, only expressions
may be associated with the labels. AMP will flag
an error if equations or relations are associated
with labels in term.
Example
~E1 : u[0] + u[1]*x + u[2]*x^2 + v[0] + v[1]*x + v[2]*x^2
E1 : u[0] + u[1]*x + u[2]*x^2 + v[0] + v[1]*x + v[2]*x^2
~E2:=E1
E2 : u[0] + u[1]*x + u[2]*x^2 + v[0] + v[1]*x v[2]*x^2
~IN E1 COLLECT x
E1 : u[0] + v[0] + x*1(u[1] + u[2]*x + v[1] + v[2]*x)
~ITERATE I FROM 1 TO 2
~IN E2 ON I COLLECT STRICTLY x^I
E2 : u[0] + v[0] + x*(u[1] + v[1]) + x^2*(u[2] + v[2])
Example with Procedure
PROCEDURE Example(INTEGER N ; LABEL L ; PARAMETER P) ;
ITERATE I FROM 1 TO N ;
IN L[I] COLLECT P ;
EXIT
~ITERATE I FROM 1 TO 3
~LABEL V[1..3]
~V[I] : u[I]*x + v[I]*x
V[1] : u[1]*x + v[1]*x
V[2] : u[2]*x + v[2]*x
V[3] : u[3]*x + v[3]*x
~Example(3,V,x)
V[1] : x*(u[1] + v[1])
V[2] : x*(u[2] + v[2])
V[3] : x*(u[3] + v[3])
44
Copyright 1987, 1989 Cerebral Software
COLLECT OPERATOR
Syntax {IN label}{ON iteration} COLLECT operator ON term
Where operator is :
D - Derivative operator (Ctrl D on keyboard)
INTEGRAL - Integral operator (Ctrl K on
keyboard)
SIGMA - Summation operator (Greek capital S )
Purpose Collects operators in an expression, equation, or
relation.
Abbreviation COL
Examples
~E1 : D[x](f(x)) + D[x](g(x))
~IN E1 COLLECT D
E1 : D[x](f(x) + g(x))
~E1 : "integral"f(x)d(x) + "integral"g(x)d(x) +
"integral"{a,b}f(y)d(y) + "integral"{a,b}g(y)d(y)
E1 : "integral"f(x)d(x) + "integral"g(x)d(x) +
"integral"{a,b}f(y)d(y) + "integral"{a,b}g(y)d(y)
~COLLECT INTEGRAL ON x
E1 : "integral"f(x) + g(x)d(x) + "integral"{a,b}f(y)d(y) +
"integral"{a,b}g(y)d(y)
E1 : SIGMA{j=1,20}(u[j]) + SIGMA{j=1,20)(v[j]) +
SIGMA{k=1,30}(u[j]) + SIGMA{k=1,30}(v[j])
~IN E1 COLLECT SIGMA ON j
E1 : SIGMA{j=1,20}(u[j] + v[j]) + SIGMA{k=1,30}(u[j]) +
SIGMA{k=1,30}(v[j])
(Remember Ctrl k for "integral")
(Remember Ctrl l is differential d)
Example with Procedure
PROCEDURE Example(INTEGER N ; LABEL L ; PARAMETER P) ;
ITERATE I FROM 1 TO N ;
IN L ON I COLLECT D ON P ;
EXIT
~E1 : D[x](g(x)) + D[x](f(x)) + D[x|2](f(x)) + D[x|2](g(x))
E1 : D[x](f(x)) + D[x](g(x)) + D[x|2](f(x)) + D[x|2](g(x))
~Example(2,E1,x)
E1 : D[x](f(x) + g(x)) + D[x|2](f(x) + g(x))
45
Copyright 1987, 1989 Cerebral Software
CONSTANT
Syntax CONSTANT {constant=number}{,constant=number}
Where constant is an integer or
rational number or
floating point number
Purpose Allows the user to define mneumonics for often used
constants. If no constants are declared then AMP gives
a listing of constants which are already defined.
Abbreviation CONST
Example
~CONSTANT ½ß¬=113
~CONSTANT
pi=3.14 ½ß¬=113
Comment Note that the floating point number, pi, is shown to
two significant digits after the decimal point. To
show more digits the user must use the command FLOATING
or SCIENTIFIC which are described in this dictionary.
46
Copyright 1987, 1989 Cerebral Software
DECIMAL
Syntax label 2 := DECIMAL label 1
Purpose Converts rational numbers in an expression, equation or
relation to decimal numbers.
Abbreviation DEC for DECIMAL
Example
~E1 : 53/10*x
E1 : 53/10*x
~E2 := DECIMAL E1
E2 : 5.30*x
47
Copyright 1987, 1989 Cerebral Software
DEGREES
Syntax DEGREES
Purpose Forces all trigonometric functions to evaluate their
arguments in degrees.
Note By default all trigonometic functions evaluate their
arguments in radians if this command or the GRADIANS
command is not used.
Abbreviation DEG
Restriction May not be used in a procedure.
Example
~DEGREES
48
Copyright 1987, 1989 Cerebral Software
DERIVATIVE ISOLATE
Syntax label := DERIVATIVE{(n)} expression
Where expression contains labels, and numbers.
Purpose Isolates the nth derivative. If n is omitted then the
first derivative is assigned to label.
Abbreviation DERIV
Example
~E : a*b*D[x](f(x)) + 4
E : a*b*D[x](f(x)) + 4
~F:=DERIVATIVE E
F : D[x](f(x))
Example with Procedure
PROCEDURE ISOLATE(LABEL L,M) ;
M := DERIVATIVE L ;
EXIT
~E : a*b*D[x](f(x)) + 4
E : a*b*D[x](f(x)) + 4
~ISOLATE(E,F)
F : D[x](f(x))
49
Copyright 1987, 1989 Cerebral Software
DIFFERENTIAL ISOLATE
Syntax label := DIFFERENTIAL{(n)} label
Purpose Isolates the nth differential in a derivative or the
differential of an integral. (See DERIVATIVE ISOLATE
and INTEGRAL ISOLATE)
Abbreviation DIFF
Example
~E : a + b*D[x|3,y|3](h(x,y))
E : a + b*D[x|3,y|3](h(x,y))
~F:=DERIVATIVE E
F : D[x|3,y|3](h(x,y))
~G:=DIFFERENTIAL(2) F
G : y
Example with Procedure
PROCEDURE Isolate(LABEL L, M) ;
LABEL T ;
T := INTEGRAL L ;
M := DIFFERENTIAL T ;
EXIT
~E : a * b*"integral"Sin(x)d(x)
~Isolate(E,F)
~LIST F
F : x
(Remember Ctrl k for "integral")
(Remember Ctrl l is differential d)
50
Copyright 1987, 1989 Cerebral Software
DISTRIBUTE TERM
Syntax {IN label} {ON iteration} DISTRIBUTE term
Purpose Distributes term into an expressions. If no label is
given then the last label used becomes the default
label.
Abbreviation DIST for DISTRIBUTE
Restrictions term may contain labels; however, only expressions
may be associated with the labels. AMP will flag
an error if equations or relations are associated
with labels in term.
Example
~E1 : x*(c + d)
E1 : x*(c + d)
~DISTRIBUTE x
E1 : c*x + d*x
Example with Procedure
PROCEDURE Example(INTEGER N ; LABEL L ; PARAMETER P) ;
ITERATE I FROM 1 TO N ;
IN L DISTRIBUTE P ;
EXIT
~ITERATE I FROM 1 TO 3
~LABEL V[1..3]
~V[I] : c*(u[I]+v[I] )
V[1] : c*(u[1] + v[1])
V[2] : c*(u[2] + v[2])
V[3] : c*(u[3] + v[3])
~Example(3,V,c)
V[1] : c*u[1] + c*v[1]
V[2] : c*u[2] + c*v[2]
V[3] : c*u[3] + c*v[3]
51
Copyright 1987, 1989 Cerebral Software
DISTRIBUTE OPERATOR
Syntax {IN label} {ON iteration} DISTRIBUTE operator {ON
expression}
Where operator is :
D - Derivative operator (Ctrl D on keyboard)
INTEGRAL - Integral operator (Ctrl K on
keyboard)
SIGMA - Summation operator (Greek capital S )
Purpose Distributes a derivative operator
Example
~E1 : D[x](f(x) + g(x))
E1 : D[x](f(x) + g(x))
~IN E1 DISTRIBUTE D ON x
E1 : D[x](f(x)) + D[x](g(x))
~E1 : "integral"f(x) + g(x)d(x)
E1 : "integral"f(x) + g(x)d(x)
~IN E1 DISTRIBUTE "integral"
E1 : "integral"f(x)d(x) + "integral"g(x)d(x)
~E1 : SIGMA{j=1,infinity}(u[j] + v[j])
E1 : SIGMA{j=1,infinity}(u[j] + v[j])
~IN E1 DISTRIBUTE SIGMA ON j
E1 : SIGMA{j=1,infinity}(u[j]) + SIGMA{j=1,infinity}(v[j])
Note : infinity is accessed by pressing F1 : Greek and then "i".
Example with Procedure
PROCEDURE Example(LABEL L ; PARAMETER P) ;
IN L DISTRIBUTE D ON P ;
EXIT
~E1 : D[x](f(x) + g(x))
E1 : D[x](f(x) + g(x))
~Example(E1,x)
E1 : D[x](f(x)) + D[x](g(x))
52
Copyright 1987, 1989 Cerebral Software
DIVIDE
Syntax {IN label} {ON iteration} DIVIDE term
Purpose Divides term into the expression, equation, or relation
belonging to label.
Note When this command is used with relations, there is no
check for validity of the operation. (See Chapter VIII
-Relation Arithmetic)
Example
~R1 : c < c*x < d
R1 : c < c*x < d
~DIVIDE c
R1 : 1 < x < 1/c*d
Example with Procedure
PROCEDURE Example(INTEGER N ; LABEL L ; PARAMETER P) ;
ITERATE I FROM 1 TO N ;
IN L[I] DIVIDE P ;
EXIT
~ITERATE I FROM 1 TO 3
~LABEL V[1..3]
~V[I] : u[I]
V[1] : u[1]
V[2] : u[2]
V[3] : u[3]
~Example(3,V,c)
V[1] : 1/c*u[1]
V[2] : 1/c*u[2]
V[3] : 1/c*u[3]
53
Copyright 1987, 1989 Cerebral Software
DISPLAY
Syntax DISPLAY {NEAT|NORMAL}
Purpose Sets the display in the NEAT (two dimensional) or
NORMAL (one dimensional) display mode. If the reserved
words NEAT or NORMAL are not specified then AMP will
respond with either of the reserved words NEAT or
NORMAL.
Abbreviation DISP for DISPLAY
Restrictions Not permitted in procedures.
Example
~DISPLAY NEAT
54
Copyright 1987, 1989 Cerebral Software
ECHO
Syntax ECHO {ON | OFF}
Purpose Controls automatic echo of results of instructions to
the screen.
Abbreviation ECHO
Restrictions May not be used in a procedure.
Example
~ECHO ON
55
Copyright 1987, 1989 Cerebral Software
EXIT
Syntax EXIT
Purpose Allows the user to exit interpreter mode of AMP. In
the program mode this is a command for exiting a
procedure, much like the RETURN statement in Pascal or
Basic.
Note Be certain to save important work before using this
command. When this command is executed in the
interpreter mode, all unsaved work is lost.
Abbreviation EXIT
Example
~EXIT
Example with Procedure
PROCEDURE ExitTest() ;
.
.
statements
.
.
EXIT
56
Copyright 1987, 1989 Cerebral Software
EXPAND
Syntax {IN label} {ON iteration} EXPAND {term}
Purpose Expands term by multiplying factors.
Example
~E1 : (x + y)*(c + d)^2
E1 : (c + d)^2*(x + y)
~EXPAND (c + d)^2
E1 : (c^2 + 2*c*d + d^2)*(x + y)
~EXPAND
E1 : c^2*x + c^2*y + 2*c*d*x + 2*c*d*y + d^2*x + d^2*y
Example with Procedure
PROCEDURE Example(INTEGER N ; LABEL L ; PARAMETER P) ;
ITERATE I FROM 1 TO N ;
IN L ON I EXPAND STRICTLY P^I ;
EXIT
~E1 : x + y + (x + y)^2 + (x + y)^3
E1 : x + y + (x + y)^3 + (x + y)^2
~Example(3,E1,(x + y))
E1 : x^3 + 3*x^2*y + x^2 + 3*x*y^2 + 2*x*y + x + y^3 + y^2 + y
57
Copyright 1987, 1989 Cerebral Software
EXPAND OPERATOR
Syntax {IN label} {ON iteration} EXPAND operator {ON index}
Purpose Expands operator where operator is:
SIGMA{j=m,n,l} - summation operator
PI{j=m,n,l} - multiplication or product operator
and m,n,l are numbers.
The expansions are over finite sums and finite
products.
Example
~E1 : SIGMA{j=1,4}(u[j])
E1 : SIGMA{j=1,4}(u[j])
~EXPAND SIGMA ON j
E1 : u[1] + u[2] + u[3] + u[4]
~E1 : PI{j=1,4}(u[j])
~EXPAND PI
E1 : u[1]*u[2]*u[3]*u[4]
Example with Procedure
PROCEDURE EXPSUM(LABEL L ; INDEX k) ;
IN L EXPAND SIGMA ON k ;
EXIT
~E1 : SIGMA{j=1,4}(u[j])
~EXPSUM(E1,j)
E1 : u[1] + u[2] + u[3] + u[4]
58
Copyright 1987, 1989 Cerebral Software
FACTOR
Syntax {IN label} FACTOR expression {ON pivot}
Purpose Factors expression into label. The result is in the
form of quotient*divisor + remainder.
Comment pivot specifies the lead factor in divisor. If you
want to divide a + b + c into a^2*b + b*c + a, then 'a'
would automatically be the pivot term of divisor. 'b'
as the pivot term will give a different result.
Example
~E1 : c^2 + c*d + b^2
E1 : c^2 + c*d + b^2
~IN E1 FACTOR c - d
E1 : 3*b^2 + (c - d)*(c + 2*d)
Example with Procedure
PROCEDURE Example(LABEL E1 ; PARAMETER P) ;
IN E1 FACTOR P ;
EXIT
~E1 : c^2 + c*d + b^2
E1 : c^2 + c*d + b^2
~Example(E1,(c-d))
E1 : 3*b^2 + (c - d)*(c + 2*d)
59
Copyright 1987, 1989 Cerebral Software
FLOATING
Syntax FLOATING m.n
Purpose Forces AMP to display all numerical output in floating
point form. m is the total number of places to use to
display the number including sign and decimal point. n
is the number of digits to display after the decimal
point. If a number is too large to fit the format then
it is displayed in scientific notation.
Abbreviation FLOAT
Restriction May not be used in procedure.
Example
~FLOATING 10.2
60
Copyright 1987, 1989 Cerebral Software
FUNCTION
Syntax FUNCTION
Purpose Forces AMP to display all functions which have been
defined. Note that this command does not show standard
functions. (See STANDARD).
Abbreviation FUNCT
Restrictions Cannot be used in procedure.
Example
~E : a*f(x) = b*g(x)
.
.
.
~FUNCTION
f(x) g(x)
Comment In the above example a relation between the two
functions "f(x)" and "g(x)" is defined. "FUNCTION"
gives a listing of the functions used.
61
Copyright 1987, 1989 Cerebral Software
GRADIANS
Syntax GRADIANS
Purpose Forces all trigonometric functions to evaluate their
arguments in gradians.
Note By default, all trigonometric functions evaluate their
arguments in radians if this command or the DEGREES
command is not used.
Abbreviation GRAD for GRADIANS
Restrictions Cannot be used in a procedure
Example
~GRADIANS
62
Copyright 1987, 1989 Cerebral Software
HIGHBOUND
Syntax label := HIGHBOUND label
Purpose Isolates the upper bound of an integral. (See ISOLATE
INTEGRAL.)
Abbreviation HIGH
Example
~E : a + b*"integral"{a,b}f(x)d(x)
~F:=INTEGRAL E
"integral"{a,b}f(x)d(x)
~G:=HIGHBOUND F
G : b
(Remember Ctrl k for "integral")
(Remember Ctrl l is differential d)
Example with Procedure
PROCEDURE Example(LABEL L,M) ;
LABEL T ;
T:=INTEGRAL L ;
M:=HIGHBOUND L ;
EXIT
~LABEL F
~E : a + b*"integral"{a,b}f(x)d(x)
E : a + b*"integral"{a,b}f(x)d(x)
~Example(E,F) ;
~LIST F
F : b
63
Copyright 1987, 1989 Cerebral Software
IMAGINARY
Syntax IMAGINARY {letter}
Where letter is a small letter.
Purpose To set the imaginary unit. If no unit is specified
then AMP will report the unit. The default unit is "i"
Restriction Cannot be used in a procedure.
Example
~IMAGINARY j
Comment The above command set the imaginary unit to j which is
the accepted unit by electrical engineers. Once the
imaginary unit is declared to be other than "i", the
user is free to use "i" as a variable or an index.
64
Copyright 1987, 1989 Cerebral Software
IN
Syntax IN label {ON iteration} statement_1
or IN label statement_2
Where statement_1 is :
COLLECT {STRICTLY} term
DISTRIBUTE {STRICTLY} term
EXPAND {STRICTLY} term
REPLACE {STRICTLY} term1 BY term2
statement_2 is :
ADD expression
DIVIDE expression
MULTIPLY expression
NEGATE expression
RAISE expression
Purpose Specifies an expression, equation, or relation.
Example
~E1 : x
E1 : x
~E2 : y
E2 : y
~E3 : z
E3 : z
~IN E1 REPLACE x BY 2*y + z
~E1 : 2*y + z
Example with Procedure
PROCEDURE Example(LABEL L;PARAMETER P) ;
IN L COLLECT P ;
EXIT
~LABEL E1
~E1 : a*x + a*y
E1 : a*x + a*y
~Example(E1,a)
E2 : a*(x + y)
65
Copyright 1987, 1989 Cerebral Software
INDEX
Syntax INDEX {letter}
Where letter is a..z
Purpose Used to declare indices. If letters is omitted then a
listing of indices is given.
Restriction Cannot be used in a procedure.
Example
~INDEX k,l,m,n
~INDEX
k l m n
66
Copyright 1987, 1989 Cerebral Software
INTEGRAL ISOLATE
Syntax label := INTEGRAL{(occurence)} label
Where occurence is the term number in which the integral
occurs.
Purpose Isolates a particular integral in an expression,
equation or relation.
Example
~E1 : a*b*"integral" f(x) d(x) + "integral" g(x) d(x)
E1 : a*b*"integral" f(x) d(x) + "integral" g(x) d(x)
~E2:=INTEGRAL E1
E2 : "integral" f(x) d(x)
~E3:=INTEGRAL(2) E1
E3 : "integral" g(x) d(x)
(Remember Ctrl k from "integral")
(Remember Ctrl l is differential d)
Example with Procedure
PROCEDURE Example(LABEL L, M) ;
M:=INTEGRAL M ;
EXIT
~E1 : a*b*"integral" f(x) d(x) + "integral" g(x) d(x)
E1 : a*b*"integral" f(x) d(x) + "integral" g(x) d(x)
~Example(E1, E2)
E2 : "integral" f(x) d(x)
(Remember Ctrl k from "integral")
(Remember Ctrl l is differential d)
67
Copyright 1987, 1989 Cerebral Software
ITERATE
Option 1 : Iteration declaration in interpreter mode.
Syntax ITERATE {letter FROM integer TO integer {STEP integer}}
Where letter is "A".."Z" ; capital letters only.
integer is an integer.
Purpose Define iteration variables which are used in multiple
assignments or to requests information about them.
Example ~ITERATE I FROM 1 TO 10
~ITERATE J FROM 2 TO 10 STEP 2
~ITERATE K FROM -1 TO -10 STEP -1
~ITERATE
I FROM 1 TO 10
J FROM 2 TO 10 STEP 2
K FROM -1 TO -10 STEP -1
Option 2 : Iteration declaration in program mode.
Syntax ITERATE letter FROM expr TO expr {STEP expr}
Where letter is "A".."Z" ie capital letters only.
expr is a simple expression consisting of proced-
ure arguments of type INTEGER and integers.
Purpose Defines iterates which are used in multiple assignments
and which are local to the procedure. These iterates
are in effect only while the procedure is executing.
When the procedure terminates these iterates are
discarded.
Example with Procedure
PROCEDURE itertest(INTEGER N,M) ;
ITERATE I FROM N TO M+1 ;
ITERATE J FROM 2*N TO 3*M ;
EXIT
68
Copyright 1987, 1989 Cerebral Software
LABEL
Option 1 : Label declaration in Interpreter
Syntax LABEL {label ,label . . .}
Where label is name{[int..int{,int..int}]}
name is an alphanumeric string.
int is an integer.
Purpose Used to declare labels for the database or request
information about them.
Example ~LABEL A[1..3,1..3],B[1..3],E
~LABEL
A[1..3,1..3] B[1..3]
E
Option 2 : Label declaration in compiler mode.
Syntax LABEL label {,label,. . .}
Where label is name{[expr..expr {,expr..expr}3]}
name is an alphanumeric string.
expr is a simple expression consisting of integers
a procedure arguments of type INTEGER.
Purpose Used to declare labels which are local to a procedure.
These labels are in effect only while the procedure is
executing. When the procedure terminates these labels
are discarded.
Example
PROCEDURE Example(INTEGER N ; PARAMETER p) ;
LABEL B[N-1..N+2] ;
ITERATE I FROM N-1 TO N+2 ;
B[I] : 3*p ;
EXIT
~Example(1,(x+y))
B[0] : x + y
B[1] : x + y
B[2] : x + y
Comment The label B is local to the PROCEDURE "Example" and is
discarded once the procedure execution is complete.
69
Copyright 1987, 1989 Cerebral Software
LEFT
Syntax label 2 := LEFT label 1
Purpose Assigns the left expression of label 2 to label 1
Example
~R1 : c < d < e
R1 : c < d < e
~E1 := LEFT R1
E1 : c
Example with Procedure
PROCEDURE Example(LABEL L1,L2) ;
L2 := LEFT L1 ;
EXIT
~R1 : c < d < e
R1 : c < d < e
~LABEL E1
~Example(R1,E1)
E1 : c
70
Copyright 1987, 1989 Cerebral Software
LIST
Syntax LIST label {TO filename}
Where label may be a label with or without the subscripts.
If label is a tensor and the subscripts are omitted
then the whole tensor is listed.
filename is an alphanumeric string. It may contain no
more than eight characters.
Note When data is listed to a file, the extension 'TXT' is
appended to the filename. The text listed to this file
is suitable for importation into many word processing
programs.
Restrictions May not be used in a procedure.
Example
~LABEL A[1..3,1..3]
~LIST A TO TEXT
~LIST A
71
Copyright 1987, 1989 Cerebral Software
LOAD
Syntax LOAD filename
Purpose Loads data that was saved to a file using the SAVE
command. LOAD also checks for conflicting labels.
Abbreviation LOAD
Restriction Cannot be used in a procedure.
Example
~LOAD DATA
Comment "DATA" is the name of a file to which data was saved
using the SAVE command.
72
Copyright 1987, 1989 Cerebral Software
LOWBOUND
Syntax label := LOWBOUND label
Purpose Isolates the lower bound of an integral. (See ISOLATE
INTEGRAL.)
Abbreviation LOW
Example
~E : a + b*"integral"{a,b}f(x)d(x)
~F:=INTEGRAL E
"integral"{a,b}f(x)d(x)
~G:=LOWBOUND F
G : a
(Remember Ctrl k from "integral")
(Remember Ctrl l is differential d)
Example with Procedure
PROCEDURE Isolate(LABEL L,M) ;
LABEL T ;
T:=INTEGRAL L ;
M:=LOWBOUND L ;
EXIT
~LABEL F
~E : a + b*"integral"{a,b}f(x)d(x)
E : a + b*"integral"{a,b}f(x)d(x)
~Isolate(E,F) ;
~LIST F
F : a
73
Copyright 1987, 1989 Cerebral Software
MULTIPLY
Syntax {IN label} {ON iteration} MULTIPLY expression
Purpose Multiplies expression, equation, or relation with label
by expression. When this command is used on relations
there is no checking for validity of operation.
Note When this command is used with relations, there are no
checks for analytical validity of operations. (See
Chapter VIII - Relation Arithmetic)
Example
~R1 : 1/c < 1/c*x < c
R1 : 1/c < 1/c*x < c
IN R1 MULTIPLY c
~R1 : 1 < x < c^2
Example with Procedure
PROCEDURE Example(INTEGER N ; LABEL L ; PARAMETER P) ;
ITERATE I FROM 1 TO N ;
IN L[I] MULTIPLY P ;
EXIT
~ITERATE I FROM 1 TO 3
~LABEL V[1..3]
~V[I] : I
V[1] : 1
V[2] : 2
V[3] : 3
~Example(3,V,c)
V[1] : c
V[2] : 2*c
V[3] : 3*c
74
Copyright 1987, 1989 Cerebral Software
NEGATE
Syntax {IN label} NEGATE expression
Purpose Negates an expression in a term while maintaining the
same sign of the term.
Example
~E1 : c*( - d - e)
E1 : c*( - d - e)
~NEGATE - d - e
E1 : - c*(d + e)
Note In the above example c*( - d - e) has the same sign as
- c*(d + e).
Example with Procedure
PROCEDURE Example(LABEL L ; PARAMETER P) ;
IN L NEGATE P ;
EXIT
~E1 : c*( - d - e)
E1 : c*( - d - e)
~Example(E1,( - d - e))
E1 : - c*(d + e)
75
Copyright 1987, 1989 Cerebral Software
NOTATION
Syntax Notation
Purpose Reports whether floating point or scientific notation
is currently being used.
Abbreviation NOTAT
Restriction May not be used in a procedure.
Example
~NOTATION
scientific
76
Copyright 1987, 1989 Cerebral Software
ON
Syntax {IN iteration} ON iteration statement
Where statement is :
COLLECT {STRICTLY} term
DISTRIBUTE {STRICTLY} term
EXPAND {STRICTLY} term
REPLACE {STRICTLY} term1 BY term2
Purpose Specifies an iteration upon which to repetitively do
statement.
Example
~E1 : D[x](x^4) + D[x](x^3) + D[x](x^2) + D[x](x)
E1 : D[x](x^4) + D[x](x^3) + D[x](x^2) + D[x](x)
~ITERATE I FROM 1 TO 4
~ON I REPLACE STRICTLY D[x](x^I) BY I*x^(I-1)
E1 : 4*x^3 + 3*x^2 + 2*x + 1
Note The last two statements above could be compared to the
following psuedocode :
FOR I := 1 TO 4
REPLACE D[x](x^I) BY I*x^(I-1)
NEXT I
Example with procedure
PROCEDURE Example(INTEGER N ; LABEL L ; PARAMETER P) ;
ITERATE I FROM 1 TO N ;
IN L REPLACE D[P](P^I) BY I*P^(I-1) ;
EXIT
~E1 : D[x](x^4) + D[x](x^3) + D[x](x^2) + D[x](x)
E1 : D[x](x^4) + D[x](x^3) + D[x](x^2) + D[x](x)
~Example(4,E1,x)
E1 : 4*x^3 + 3*x^2 + 2*x + 1
77
Copyright 1987, 1989 Cerebral Software
PRINT
Syntax PRINT label
Purpose Directs output to the line printer.
Restriction Cannot be used in a procedure.
Example
~LABEL A[1..3,1..3]
~PRINT A
78
Copyright 1987, 1989 Cerebral Software
PROCEDURE
Syntax PROCEDURE
Purpose This command causes AMP to display all procedure
headings.
Abbreviation PROC
Restriction Cannot be used in a procedure.
Example
~PROCEDURE
79
Copyright 1987, 1989 Cerebral Software
PRODUCT
Syntax label := PRODUCT(iteration{,iteration,...}) expression
Purpose Computes the product over an iteration
Example
~LABEL A[1..3,1..3],B[1..3,1..3],C[1..3,1..3]
~ITERATE I FROM 1 TO 3
~ITERATE J FROM 1 TO 3
~ITERATE K FROM 1 TO 3
~A[I,J] : s[I,J]
A[1,1] : s[1,1]
A[2,1] : s[2,1]
A[3,1] : s[3,1]
A[1,2] : s[1,2]
A[2,2] : s[2,2]
A[2,3] : s[2,3]
A[3,1] : s[3,1]
A[3,2] : s[3,2]
A[3,3] : s[3,3]
~B[I,J] : t[I,J]
B[1,1] : t[1,1]
B[2,1] : t[2,1]
B[3,1] : t[3,1]
B[1,2] : t[1,2]
B[2,2] : t[2,2]
B[3,2] : t[3,2]
B[1,3] : t[1,3]
B[2,3] : t[2,3]
B[3,3] : t[3,3]
~C[I,J] := PRODUCT(K) A[I,K] + B[K,J]
C[1,1] : (s[1,1] + t[1,1])*(s[1,2] + t[2,1])*(s[1,3] + t[3,1])
C[2,1] : (s[2,1] + t[1,1])*(s[2,2] + t[2,1])*(s[2,3] + t[3,1])
C[3,1] : (s[3,1] + t[1,1])*(s[3,2] + t[2,1])*(s[3,3] + t[3,1])
C[1,2] : (s[1,1] + t[1,2])*(s[1,2] + t[2,2])*(s[1,3] + t[3,2])
C[2,2] : (s[2,1] + t[1,2])*(s[2,2] + t[2,2])*(s[2,3] + t[3,2])
C[3,2] : (s[3,1] + t[1,2])*(s[3,2] + t[2,2])*(s[3,3] + t[3,2])
C[1,3] : (s[1,1] + t[1,3])*(s[1,2] + t[2,3])*(s[1,3] + t[3,3])
C[2,3] : (s[2,1] + t[1,3])*(s[2,2] + t[2,3])*(s[2,3] + t[3,3])
C[3,3] : (s[3,1] + t[1,3])*(s[3,2] + t[2,3])*(s[3,3] + t[3,3])
80
Copyright 1987, 1989 Cerebral Software
Example with Procedure
PROCEDURE Example(LABEL L1,L2,L3) ;
ITERATE I FROM 1 TO 3 ;
ITERATE J FROM 1 TO 3 ;
ITERATE K FROM 1 TO 3 ;
L3[I,J] := PRODUCT(K) L1[I,K] + L2[K,J] ;
EXIT
~LABEL A[1..3,1..3],B[1..3,1..3],C[1..3,1..3]
~ITERATE I FROM 1 TO 3
~ITERATE J FROM 1 TO 3
~A[I,J] : s[I,J]
A[1,1] : s[1,1]
A[2,1] : s[2,1]
A[3,1] : s[3,1]
A[1,2] : s[1,2]
A[2,2] : s[2,2]
A[2,3] : s[2,3]
A[3,1] : s[3,1]
A[3,2] : s[3,2]
A[3,3] : s[3,3]
~B[I,J] : t[I,J]
B[1,1] : t[1,1]
B[2,1] : t[2,1]
B[3,1] : t[3,1]
B[1,2] : t[1,2]
B[2,2] : t[2,2]
B[3,2] : t[3,2]
B[1,3] : t[1,3]
B[2,3] : t[2,3]
B[3,3] : t[3,3]
~Example(A,B,C)
C[1,1] : (s[1,1] + t[1,1])*(s[1,2] + t[2,1])*(s[1,3] + t[3,1])
C[2,1] : (s[2,1] + t[1,1])*(s[2,2] + t[2,1])*(s[2,3] + t[3,1])
C[3,1] : (s[3,1] + t[1,1])*(s[3,2] + t[2,1])*(s[3,3] + t[3,1])
C[1,2] : (s[1,1] + t[1,2])*(s[1,2] + t[2,2])*(s[1,3] + t[3,2])
C[2,2] : (s[2,1] + t[1,2])*(s[2,2] + t[2,2])*(s[2,3] + t[3,2])
C[3,2] : (s[3,1] + t[1,2])*(s[3,2] + t[2,2])*(s[3,3] + t[3,2])
C[1,3] : (s[1,1] + t[1,3])*(s[1,2] + t[2,3])*(s[1,3] + t[3,3])
C[2,3] : (s[2,1] + t[1,3])*(s[2,2] + t[2,3])*(s[2,3] + t[3,3])
C[3,3] : (s[3,1] + t[1,3])*(s[3,2] + t[2,3])*(s[3,3] + t[3,3])
81
Copyright 1987, 1989 Cerebral Software
QUOTIENT
Syntax label2 := QUOTIENT(divisor{,pivot}) label1
Purpose Returns the quotient of divisor divided into label1.
label1 must be an expression.
Comment pivot specifies the lead factor in divisor. If you
want to divide a + b + c into a^2*b + b*c + a, then 'a'
would automatically be the pivot term of divisor. 'b'
as the pivot term will give a different result.
Example
~E1 : c^3 - d^3
E1 : c^3 - d^3
~E2:=QUOTIENT(c - d) E1
E2 : c^2 + c*d + d^2
Example with Procedure
PROCEDURE Example(LABEL L1,L2 ; PARAMETER P) ;
L2 := QUOTIENT(P) L1 ;
EXIT
~E1 : c^3 - d^3
E1 : c^3 - d^3
~LABEL E2
~Example(E1,E2,(c - d))
E2 : c^2 + c*d + d^2
82
Copyright 1987, 1989 Cerebral Software
RADIANS
Syntax RADIANS
Purpose Forces trigonometric function to evaluate arguments in
radians
Abbreviation RAD
Restriction Cannot be used in a procedure.
Example
~RADIANS
83
Copyright 1987, 1989 Cerebral Software
RAISE
Syntax {IN label} {ON iteration} RAISE expression
Purpose Raises an expression, equation, relation belonging to
label to the power of expression.
Note When this command is used with relations, there is no
check for analytical validity of the operation. (See
Chapter VIII - Relation Arithmetic)
Example
~R1 : c < x < d
R1 : c < x < d
~IN R1 RAISE c
R1 : c^c < x^c < d^c
Example with Procedure
PROCEDURE Example(INTEGER N ; LABEL L ; PARAMETER P) ;
ITERATE I FROM 1 TO N ;
IN L[I] RAISE P ;
EXIT
~LABEL V[1..3]
~ITERATE I FROM 1 TO 3
~V[I] : u[I]
V[1] : u[1]
V[2] : u[2]
V[3] : u[3]
~Example(3,V,c)
V[1] : u[1]^c
V[2] : u[2]^c
V[3] : u[3]^c
84
Copyright 1987, 1989 Cerebral Software
REMAINDER
Syntax label2 := REMAINDER(divisor {,pivot}) label1
Purpose divisor is divided into label1. label2 is the result.
Example
~E1 : c^2 + c*d + d^2
E1 : c^2 + c*d + d^2
~E2:=REMAINDER(c-d,-d) E1
E2 : 3*c^2
Example with Procedure
PROCEDURE Example(LABEL L1, L2 ; PARAMETER P) ;
L2:=REMAINDER(P) L1 ;
EXIT
~E1 : c^2 + c*d + d^2
E1 : c^2 + c*d + d^2
~LABEL E2
~Example(E1,E2,(c-d))
E2 : 3*d^2
85
Copyright 1987, 1989 Cerebral Software
REPLACE
Syntax {IN label} {ON iteration} REPLACE {STRICTLY} expression
1 BY expression 2
Purpose Replaces expression 1 by expression 2
Example
~E1 : u[j]/v[j] + c/d
E1 : u[j]/v[j] + c/d
~REPLACE u[j]/v[j] BY c/d
E1 : 2*c/d
Example with Procedure
PROCEDURE Example(LABEL L ; PARAMETER P1,P2) ;
IN L REPLACE P1 BY P2 ;
EXIT
~E1 : u[j]/v[j] + c/d
E1 : u[j]/v[j] + c/d
~Example(E1,(u[j]/v[j]),(c/d))
E1 : 2*c/d
86
Copyright 1987, 1989 Cerebral Software
RIGHT
Syntax label 2 := RIGHT label 1
Purpose The right expression of label 1 is assigned to label 2
Example
~R1 : c < d < e
R1 : c < d < e
~E1 := RIGHT R1
E1 : e
Example with Procedure
PROCEDURE Example(LABEL L1,L2) ;
L2 := RIGHT L1 ;
EXIT
~R1 : c < d < e
R1 : c < d < e
~LABEL E1
~Example(R1,E1)
E1 : e
87
Copyright 1987, 1989 Cerebral Software
SAVE
Syntax SAVE {ALL | label} TO filename
Purpose Saves data to filename
Restrictions May not be used in a procedure.
Note When data is saved to filename the extension 'DAT' is
appended to it. The data may be later recalled using
the command LOAD.
Example
~LABEL A[1..3,1..3]
~SAVE A TO DATA
~SAVE ALL TO DATA
~ITERATE I FROM 1 TO 3
~ITERATE J FROM 1 TO 3
~SAVE A[I,J] TO PARTS
88
Copyright 1987, 1989 Cerebral Software
SCIENTIFIC
Syntax SCIENTIFIC n
Purpose Forces AMP to display all numerical output in
scientific notation. n is the number of characters to
display after the decimal point. n can be a maximum of
15.
Abbreviation SCIEN
Example
~SCIENTIFIC 6
89
Copyright 1987, 1989 Cerebral Software
SOUND
Syntax SOUND {ON|OFF}
Purpose Controls the sound. When sound is on a beep is emitted
when AMP detects a syntax or runtime error.
Restrictions Not permitted in procedures.
Example
~SOUND OFF
~SOUND
OFF
90
Copyright 1987, 1989 Cerebral Software
STANDARD
Syntax STANDARD
Purpose Causes AMP to display all standard functions.
Example
~STANDARD
91
Copyright 1987, 1989 Cerebral Software
SWITCH
Syntax SWITCH label
Purpose Switches the left and right sides of an equation.
Example
~Q1 : a = b
Q1 : a = b
~SWITCH Q1
Q1 : b = a
Example with Procedure
PROCEDURE Example(LABEL L) ;
SWITCH L
EXIT
~Q1 : a = b
Q1 : a = b
~Example(Q1)
Q1 : b = a
92
Copyright 1987, 1989 Cerebral Software
SUBTRACT
Syntax {IN label} {ON iteration} SUBTRACT expression
Purpose Subtracts expression FROM expression, equation, or
relation.
Example
~R1 : c < c + x < d
R1 : c < c + x < d
~SUBTRACT c
R1 : 0 < x < - c + d
Example with Procedure
PROCEDURE Example(INTEGER N ; LABEL L ; PARAMETER P) ;
ITERATE I FROM 1 TO N ;
IN L[I] SUBTRACT P ;
EXIT
~ITERATE I FROM 1 TO 3
~LABEL V[1..3]
~V[I] : u[I] + c
V[1] : u[1] + c
V[2] : u[2] + c
V[3] : u[3] + c
~Example(3,V,c)
V[1] : u[1]
V[2] : u[2]
V[3] : u[3]
93
Copyright 1987, 1989 Cerebral Software
SUM
Syntax label := SUM(iteration{,iteration}) expression
Purpose Sums expressions on iteration. Command is primary used
for tensor manipulations e.g. matrix multiplication.
Example
~LABEL A[1..3,1..3],B[1..3,1..3],C[1..3,1..3]
~ITERATE I FROM 1 TO 3
~ITERATE J FROM 1 TO 3
~ITERATE K FROM 1 TO 3
~A[I,J] : s[I,J]
A[1,1] : s[1,1]
A[2,1] : s[2,1]
A[3,1] : s[3,1]
A[1,2] : s[1,3]
A[2,2] : s[2,3]
A[3,3] : s[3,3]
A[3,1] : s[3,1]
A[3,2] : s[3,2]
A[3,3] : s[3,3]
~B[I,J] : t[I,J]
B[1,1] : t[1,1]
B[2,1] : t[2,1]
B[3,1] : t[3,1]
B[1,2] : t[1,2]
B[2,2] : t[2,2]
B[3,2] : t[3,2]
B[1,3] : t[1,3]
B[2,3] : t[2,3]
B[3,3] : t[3,3]
~C[I,J] := SUM(K) A[I,K]*B[K,J]
C[1,1] : s[1,1]*t[1,1] + s[1,2]*t[2,1] + s[1,3]*t[3,1]
C[2,1] : s[2,1]*t[1,1] + s[2,2]*t[2,1] + s[2,3]*t[3,1]
C[3,1] : s[3,1]*t[1,1] + s[3,2]*t[2,1] + s[3,3]*t[3,1]
C[1,2] : s[1,1]*t[1,2] + s[1,2]*t[2,2] + s[1,3]*t[3,2]
C[2,2] : s[2,1]*t[1,2] + s[2,2]*t[2,2] + s[2,3]*t[3,2]
C[3,2] : s[3,1]*t[1,2] + s[3,2]*t[2,2] + s[3,3]*t[3,2]
C[1,3] : s[1,1]*t[1,3] + s[1,2]*t[2,3] + s[1,3]*t[3,3]
C[2,3] : s[2,1]*t[1,3] + s[2,2]*t[2,3] + s[2,3]*t[3,3]
C[3,3] : s[3,1]*t[1,3] + s[3,2]*t[2,3] + s[3,3]*t[3,3]
Comment The above example demonstrates how go multiply two
matices A, and B to give the resulting matrix, C.
94
Copyright 1987, 1989 Cerebral Software
Example with Procedure
PROCEDURE Example(INTEGER N ; LABEL L1, L2, L3) ;
ITERATE I FROM 1 TO N ;
ITERATE J FROM 1 TO N ;
ITERATE K FROM 1 TO N ;
L3[I,J]:=SUM(K) L1[I,K]*L2[K,J] ;
EXIT
~LABEL A[1..3,1..3],B[1..3,1..3],C[1..3,1..3]
~ITERATE I FROM 1 TO 3
~ITERATE J FROM 1 TO 3
~A[I,J] : s[I,J]
A[1,1] : s[1,1]
A[2,1] : s[2,1]
A[3,1] : s[3,1]
A[1,2] : s[1,2]
A[2,2] : s[2,2]
A[2,3] : s[2,3]
A[3,1] : s[3,1]
A[3,2] : s[3,2]
A[3,3] : s[3,3]
~B[I,J] : t[I,J]
B[1,1] : t[1,1]
B[2,1] : t[2,1]
B[3,1] : t[3,1]
B[1,2] : t[1,2]
B[2,2] : t[2,2]
B[3,2] : t[3,2]
B[1,3] : t[1,3]
B[2,3] : t[2,3]
~Example(3,A,B,C)
C[1,1] : s[1,1]*t[1,1] + s[1,2]*t[2,1] + s[1,3]*t[3,1]
C[2,1] : s[2,1]*t[1,1] + s[2,2]*t[2,1] + s[2,3]*t[3,1]
C[3,1] : s[3,1]*t[1,1] + s[3,2]*t[2,1] + s[3,3]*t[3,1]
C[1,2] : s[1,1]*t[1,2] + s[1,2]*t[2,2] + s[1,3]*t[3,2]
C[2,2] : s[2,1]*t[1,2] + s[2,2]*t[2,2] + s[2,3]*t[3,2]
C[3,2] : s[3,1]*t[1,2] + s[3,2]*t[2,2] + s[3,3]*t[3,2]
C[1,3] : s[1,1]*t[1,3] + s[1,2]*t[2,3] + s[1,3]*t[3,3]
C[2,3] : s[2,1]*t[1,3] + s[2,2]*t[2,3] + s[2,3]*t[3,3]
C[3,3] : s[3,1]*t[1,3] + s[3,2]*t[2,3] + s[3,3]*t[3,3]
95
Copyright 1987, 1989 Cerebral Software
UNIT
Syntax UNIT {unit list}
Purpose Used to declare units. If unit list is omitted then
AMP will respond with the units which have been
declared.
Restriction Cannot be used in a procedure.
Abbreviation UNIT
Example ~UNIT m, dyne, cm, sec
~UNIT
cm dyne m sec
96
Copyright 1987, 1989 Cerebral Software
VARIABLE
Syntax VARIABLE
Purpose Causes AMP to display variables which are in use
Abbreviation VAR for VARIABLE
Restriction Cannot be used in a procedure.
Example ~VARIABLE
97
Copyright 1987, 1989 Cerebral Software
VII.Procedures
Procedure Heading
Syntax PROCEDURE name(type list {;type list}) ;
Where name is an alphanumeric string
type is INTEGER or
FUNCTION or
LABEL or
PARAMETER or
INDEX or
VARIABLE
list is a list of alphanumeric strings separated by
commas.
Rule (1) All alphanumeric strings are limited to 16 characters.
Thus name and the alphanumeric strings in list are
limited to 16 characters.
(2) None of the alphanumeric strings may be subscripted.
Example PROCEDURE cross(LABEL L) ;
PROCEDURE example(INTEGER N ; LABEL L ; PARAMETER p,q);
Usage of various types
INTEGER parameters are used to declare variable labels and
iterations.
Example PROCEDURE INTEX(INTEGER M,N ; LABEL L) ;
LABEL T[M..N] ;
ITERATE I FROM M TO N ;
.
.
.
EXIT
~INTEX(3, 3 + 4, L) ;
98
Copyright 1987, 1989 Cerebral Software
FUNCTION parameters are used for establishing identities. Note
that standard function may not be used.
Example PROCEDURE FUNCEX(FUNCTION f; PARAMETER p,q; LABEL L );
IN L REPLACE f(p*q) BY f(p)*f(q) ;
EXIT
~E : g(x*y)
~FUNCEX(g,x,y,R)
E : g(x)*g(y)
LABEL parameters must be contained in all procedures.
PARAMETER parameters may be indices, numbers, variables,
functions, summations, products, derivatives, integrals, or
labels provided that the labels have only expressions assigned to
them. Parameters may also be complex expressions surrounded by
parentheses.
Example PROCEDURE PAREX(PARAMETER a,b,c,d,e ; LABEL L) ;
.
.
.
EXIT
~PAREX(j,SIGMA{j=1,3}(x[j]),D[x](f(x[j])),(j + x[j]),L)
INDEX parameters are used to manipulate summations or products.
Example PROCEDURE EXIND(INDEX j ; LABEL L) ;
IN L EXPAND SIGMA ON j ;
EXIT
~E : SIGMA{j=1,4}(x[j])
~EXIND(j,E)
VARIABLE parameters are used to manipulate variables.
Example PROCEDURE VAREX(VARIABLE v ; LABEL L) ;
IN L DISTRIBUTE D ON v ;
EXIT
~E : D[x](f(x) + g(x))
~VAREX(x,E)
E : D[x](f(x)) + D[x](g(x))
99
Copyright 1987, 1989 Cerebral Software
Combinations of indexes, functions and variables may be used.
Example PROCEDURE COMEX(INDEX j ; FUNCTION f ; VARIABLE v
; LABEL L) ;
IN L REPLACE f[j](v[j]) BY v[j] ;
EXIT
~E : g[k](x[k])
~COMEX(k,g,x,E)
E : x[k]
100
Copyright 1987, 1989 Cerebral Software
VIII.Relation Arithmetic
When computations are performed using the assignment
operator ":=" on combinations of relations, equations and
expressions, the ordering of expressions in the relation may be
rearranged to make certain the operations are analytically valid.
The following rules describe valid operations on combinations of
relations, equations, and expressions and how these operations
are performed.
Let D[j] : dl[j] < dc[j] < dr[j]
S[j] : sl[j] < sr[j]
Q : ql = qr
E : e
d_[j] can represent dl[j], dc[j], dr[j].
s_[j] can represent sl[j], sr[j].
In the above relations and the following discussion, <= may be
substituted.
d_[j], s_[j] may not contain any complex expressions unless those
expressions are contained in magnitudes.
d_[j], s_[j] >= 0 if d_[j], s_[j] is a magnitude or a positive
number.
d_[j], s_[j] <= 0 if d_[j], s_[j] is a negative number.
D[j] + D[k] is always valid.
~R:=D[j] + D[k]
R : dl[j] + dl[k] < dc[j] + dc[k] < dr[j] + dr[k]
D[j] - D[k] is always valid.
~R:=D[j] - D[k]
R : dl[j] - dr[k] < dc[j] - dc[k] < -dl[k] + dr[j]
D[j]*D[k] is valid when 1) dl[j] >= 0 and dl[k] >= 0 or
2) dr[j] <= 0 and dr[k] <= 0
~R := D[j]*D[k]
When condition 1) is true.
R : dl[j]*dl[k] < dc[j]*dc[k] < dr[j]*dr[k]
When condition 2) is true.
R : dr[j]*dr[k] < dc[j]*dc[k] < dl[j]*dl[k]
101
Copyright 1987, 1989 Cerebral Software
D[j]/D[k] is never valid.
D[j]^D[k] is valid when dl[j] >= 0
~R := D[j]^D[k]
R : dl[j]^dl[k] < dc[j]^dc[k] < dr[j]^dr[k]
Operations involving D[_] and S[_] are never valid.
D[j] + E is always valid.
~R := D[j] + E
R : dl[j] + e < dc[j] + e < dr[j] + e
D[j] - E is always valid.
~R := D[j] - E
R : dl[j] - e < dc[j] - e < dr[j] - e
D[j]*E is valid when 1) dl[j] >= 0 and e >= 0 or
2) dl[j] >= 0 and e <= 0 or
3) dr[j] <= 0 and e >= 0 or
4) dr[j] <= 0 and e <= 0
~R := D[j]*E
When conditions 1) and 3) is true :
R : dl[j]*e < dc[j]*e < dr[j]*e
When conditions 2) and 4) is true :
R : dr[j]*e < dc[j]*e < dl[j]*e
D[j]/E is valid when 1) dl[j] >= 0 and e >= 0 or
2) dl[j] >= 0 and e <= 0 or
3) dr[j] <= 0 and e >= 0 or
4) dr[j] <= 0 and e <= 0
~R := D[j]*E
When conditions 1) and 3) are true :
R : dl[j]*e < dc[j]*e < dr[j]*e
When conditions 2) and 4) are true :
R : dr[j]*e < dc[j]*e < dl[j]*e
D[j]^E is valid when dl[j] >= 0
~R := D[j]^E
R : dl[j]^e < dc[j]^e < dr[j]^e
102
Copyright 1987, 1989 Cerebral Software
S[j] + D[k] is never valid.
S[j] - D[k] is never valid.
S[j] * D[k] is never valid.
S[j] / D[k] is never valid.
S[j] ^ D[k] is never valid.
S[j] + Q is always valid.
~R := S[j] + Q
R : sl[j] + ql < sr[j] + qr
S[j] - Q is always valid.
~R := S[j] - Q
R : sl[j] - ql < sr - qr
S[j]*Q is valid when
1) sl[j] >= 0 and (qr >= 0 or ql >= 0)
2) sr[j] <= 0 and (qr >= 0 or ql >= 0)
3) sl[j] >= 0 and (qr <= 0 or ql <= 0)
4) sr[j] <= 0 and (qr <= 0 or ql <= 0)
~R := S[j]*Q
When conditions 1) and 2) are true
R : sl[j]*ql < sr[j]*qr
When conditions 3) and 4) are true
R : sr[j]*ql < sl[j]*qr
S[j]/Q is valid when 1) sl[j] >= 0 and (qr >= 0 or ql >= 0)
2) sr[j] <= 0 and (qr >= 0 or ql >= 0)
3) sl[j] >= 0 and (qr <= 0 or ql <= 0)
4) sr[j] <= 0 and (qr <= 0 or ql <= 0)
~R := S[j]/Q
When conditions 1) and 2) are true
R : sl[j]*ql < sr[j]*qr
When conditions 3) and 4) are true
R : sr[j]*ql < sl[j]*qr
S[j]^Q is valid when sl[j] >= 0
~R := S[j]^Q
R : sl[j]^ql < sr[j]^qr
103
Copyright 1987, 1989 Cerebral Software
Q + D[k] is never valid.
Q - D[k] is never valid.
Q / D[k] is never valid.
Q ^ D[k] is never valid.
Q + S[k] is always valid.
~R := Q + S[K]
R : ql + sl[k] < qr + sr[k]
Q - S[k] is always valid.
~R := Q - S[k]
R : ql - sr[k] < qr - sl[k]
Q * S[k] is valid when 1) (ql <= 0 or qr <= 0) and sr[k] <= 0
2) (ql <= 0 or qr <= 0) and sl[k] >= 0
3) (ql >= 0 or qr >= 0) and sr[k] <= 0
4) (ql >= 0 or qr >= 0) and sl[k] >= 0
~R := Q + S[k]
When conditions 1) and 2) are true :
R : ql*sr[k] < qr*sl[k]
When conditions 3) and 4) are true :
R : ql*sl[k] < qr*sr[k]
Q / S[k] is valid when 1) (ql <= 0 or qr <= 0) and sr[k] <= 0
2) (ql <= 0 or qr <= 0) and sl[k] >= 0
3) (ql >= 0 or qr >= 0) and sr[k] <= 0
4) (ql >= 0 or qr >= 0) and sl[k] >= 0
~R := Q/S[k]
When conditions 1) and 4) are true:
R : ql*sl[k] < ql*sr[k]
When conditions 2) and 3) are true:
R : ql*sr[k] < qr*sl[k]
Q ^ S[k] is valid when ql >= 0 or qr >= 0
~R := Q^S[k]
R : ql^sl[k] < qr^sr[k]
104
Copyright 1987, 1989 Cerebral Software
E + D[k] is valid
~R : E + D[k]
R : e + dl[k] < e + dc[k] < e + dr[k]
E - D[k] is valid
~R : E - D[k]
R : e - dr[k] < e - dc[k] < e - dl[k]
E * D[k] is valid when 1) e <= 0
2) e >= 0
~R : E * D[k]
When condition 1) is true
R : e*dr[k] < e*dc[k] < e*dl[k]
When condition 2) is true
R : e*dl[k] < e*dc[k] < e*dr[k]
E / D[k] is valid when 1) e <= 0 and (dl[k], dc[k], dr[k] not 0)
2) e >= 0 and (dl[k], dc[k], dr[k] not 0)
~R := E/D[k]
When condition 1) is true
R : e/dl[k] < e/dc[k] < e/dr[k]
When conditino 2) is true
R : e/dr[k] < e/dc[k] < e/dl[k]
E ^ D[k] is valid when e >= 0
~R := E^D[k]
R : e^dl[k] < e^dc[k] < e^dr[k]
A potential invalid operation is flagged by the program.
105
Copyright 1987, 1989 Cerebral Software
INDEX
Last (6)
":" (34)
":=" (37)
-> (5), (8)
<- (5), (8)
ADD (39)
ArcCos (14)
ArcHypCos (13)
ArcHypSin (13)
ArcHypTan (13)
ArcSin (14)
ArcTan (14)
ASSIGN (34)
Assignment (17)
Back Space (5), (8)
CENTER (41)
CLEAR (42)
COEFFICIENT (43)
COLLECT (23), (44)
Common logorithm (14)
Compile (10)
Complex (12)
CONSTANT (46)
Constants (18)
COPY (6)
Cos (14), (30)
Cosine (14)
Cr (5)
Ctrl -> (5), (8)
Ctrl <- (5), (8)
Ctrl A (7)
Ctrl cr (5)
Ctrl D (7)
Ctrl End (5), (8)
Ctrl Home (5)
Ctrl K (7)
Ctrl L (7)
Ctrl PgDn (5), (8)
DECIMAL (47)
Definition (17)
DEGREES (48)
Del (5), (8)
Derivative (7), (49)
Derivatives (11)
Differential (7), (30), (50)
DIR (6)
DISPLAY (54)
DISTRIBUTE (51), (52)
DIVIDE (21), (53)
106
Copyright 1987, 1989 Cerebral Software
Dos (6)
ECHO (55)
Edit Keys (5)
Eigenvectors (25)
End (5), (8)
Equation (16)
Esc (5)
EXIT (56)
Exp (14)
EXPAND (22), (57), (58)
Exponential function (14)
Expressions (16)
FACTOR (59)
FLOATING (60)
Floating point (12)
FUNCTION (61), (98)
Function Keys (6)
Functions (11), (13)
GRADIANS (62)
Greek (6), (10)
Help (6)
HIGHBOUND (30), (63)
Home (6), (8)
HypCos (14)
Hyperbolic cosine (14)
Hyperbolic sine (14)
Hyperbolic tangent (14)
HypSin (14)
HypTan (14)
IMAGINARY (64)
Imaginary Unit (11)
IN (65)
Index (12), (66), (98)
Ins (5), (8)
INTEGER (98)
Integers (12)
Integral (7), (30), (67)
Integrals (11), (15)
Inverse cosine (14)
Inverse hyperbolic cosine. (13)
Inverse hyperbolic sine (13)
Inverse hyperbolic tangent (13)
Inverse sine (14)
Inverse tangent (14)
ITERATE (68)
Key Board (5)
LABEL (11), (69), (98)
Labels (11)
LEFT (70)
LIST (71)
107
Copyright 1987, 1989 Cerebral Software
Ln (14)
Load (10), (72)
Log (14)
LOWBOUND (30), (73)
Magnitude (7)
Magnitudes (16)
Matrix (1)
MULTIPLY (74)
Natural logorithm (14)
NEAT (21)
NEGATE (75)
Normal display (21)
NOTATION (76)
Numbers (11)
ON (77)
Overview (3)
PARAMETER (98)
PgDn (6), (8)
PgUp (6), (8)
PRINT (78)
PROCEDURE (79), (98)
Heading (98)
Procedures (17)
PRODUCT (80)
Products (11), (15)
Program (6)
Quit (10)
QUOTIENT (82)
RADIANS (83)
Rationals (12)
Real (12)
Recall (6)
Relations (1)
REMAINDER (85)
REPLACE (30), (86)
RIGHT (87)
Rvs Tab (6)
Save (6), (10), (88)
SCIENTIFIC (89)
SELECT (87)
Sin (14), (30)
Sine (13), (14)
SOUND (90)
Special Character Keys (7)
STANDARD (91)
STRICTLY (32)
SUBTRACT (21), (93)
SUM (94)
Summations (11), (14)
SWITCH (92)
108
Copyright 1987, 1989 Cerebral Software
Tab (6)
Tan (14)
Tangent (13), (14)
Tensor (1)
UNIT (96)
Units (12)
VARIABLE (97), (98)
Variables (11), (13)
109
Copyright 1987, 1989 Cerebral Software
Order Form
Please send 1 copy of AMP to :
Name_____________________________________________________________
Address__________________________________________________________
City__________________________ State___________________
Zip_____________________
Phone ( )__________________
( )__________________
Price $ ______ (Orders placed before July 1 '89
get introductory price of $47.
After July 1 '89 the price
is $90)
Shipping 3.00
Tax (Ga. residents only 3%)
------------------
Total
Send order form to :
Cerebral Software
P.O. Box 80332
Chamblee, GA 30366
Ph (404)-452-1129
(Call for wholesale or site pricing)
110