5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: REDUCE INTERACTIVE LESSON NUMBER 1
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: David R. Stoutemyer
5f892713c3 2021-03-03 trnsz@pobox.c: University of Hawaii
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT This is lesson 1 of 7 interactive lessons about the REDUCE
5f892713c3 2021-03-03 trnsz@pobox.c: system for computer symbolic mathematics. These lessons presume an
5f892713c3 2021-03-03 trnsz@pobox.c: acquaintance with elementary calculus, together with a previous
5f892713c3 2021-03-03 trnsz@pobox.c: exposure to some computer programming language.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: In REDUCE, any sequence of characters from the word "COMMENT" through
5f892713c3 2021-03-03 trnsz@pobox.c: the next semicolon or dollar-sign statement separator is an
5f892713c3 2021-03-03 trnsz@pobox.c: explanatory remark ignored by the system. In general, either
5f892713c3 2021-03-03 trnsz@pobox.c: separator signals the end of a statement, with the dollar sign
5f892713c3 2021-03-03 trnsz@pobox.c: suppressing any output that might otherwise automatically be produced
5f892713c3 2021-03-03 trnsz@pobox.c: by the statement. The typing of a carriage return initiates the
5f892713c3 2021-03-03 trnsz@pobox.c: immediate sequential execution of all statements which have been
5f892713c3 2021-03-03 trnsz@pobox.c: terminated on that line. When REDUCE is ready for more input, it will
5f892713c3 2021-03-03 trnsz@pobox.c: prompt you with a prompt number followed by a colon and a space at the
5f892713c3 2021-03-03 trnsz@pobox.c: left margin.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: Expressions can be formed using "^", "*", "/", "+", and "-" to
5f892713c3 2021-03-03 trnsz@pobox.c: indicate exponentiation, multiplication, division, addition, and
5f892713c3 2021-03-03 trnsz@pobox.c: subtraction or negation respectively. Assignments to variables can be
5f892713c3 2021-03-03 trnsz@pobox.c: done using the operator ":=". For example:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: r2d2 := (987654321/15)^3;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT The immediately preceding line, without a semicolon, is the
5f892713c3 2021-03-03 trnsz@pobox.c: computed output generated by the line with a semicolon which precedes
5f892713c3 2021-03-03 trnsz@pobox.c: it. Note that exact indefinite-precision rational arithmetic was
5f892713c3 2021-03-03 trnsz@pobox.c: used, in contrast to the limited-precision arithmetic of traditional
5f892713c3 2021-03-03 trnsz@pobox.c: programming languages.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: We can use the name R2D2 to represent its value in subsequent
5f892713c3 2021-03-03 trnsz@pobox.c: expressions such as;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: r2d2 := -r2d2/25 + 3*(13-5);
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT We could equally well write the name of this variable as R2D2,
5f892713c3 2021-03-03 trnsz@pobox.c: r2D2 or R2d2 since REDUCE is case-insensitive. Using this
5f892713c3 2021-03-03 trnsz@pobox.c: flexibility, in these lessons code discussed within the text will be
5f892713c3 2021-03-03 trnsz@pobox.c: written in upper case to make it stand out, but code to be actually
5f892713c3 2021-03-03 trnsz@pobox.c: executed by REDUCE will be written in lower case.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: Now I will give you an opportunity to try some analogous computations.
5f892713c3 2021-03-03 trnsz@pobox.c: To do so, type the letter n or N followed by a carriage return in
5f892713c3 2021-03-03 trnsz@pobox.c: response to the question "Cont?". (You could type y or Y if you wish
5f892713c3 2021-03-03 trnsz@pobox.c: to relinquish this opportunity, but I strongly recommend reinforced
5f892713c3 2021-03-03 trnsz@pobox.c: learning through active participation.) After trying an example or
5f892713c3 2021-03-03 trnsz@pobox.c: two, type the command "cont" (with any capitalization) terminated by a
5f892713c3 2021-03-03 trnsz@pobox.c: semicolon and carriage return when you wish to proceed with the rest
5f892713c3 2021-03-03 trnsz@pobox.c: of the lesson. To avoid interference with our examples, please don't
5f892713c3 2021-03-03 trnsz@pobox.c: assign anything to any variable names beginning with the letters E
5f892713c3 2021-03-03 trnsz@pobox.c: through I. To avoid lengthy delays, I recommend keeping all of your
5f892713c3 2021-03-03 trnsz@pobox.c: examples approximately as trivial as ours, saving your more ambitious
5f892713c3 2021-03-03 trnsz@pobox.c: experiments until after the lesson. If you happen to initiate a
5f892713c3 2021-03-03 trnsz@pobox.c: calculation requiring an undue amount of time to evaluate or display,
5f892713c3 2021-03-03 trnsz@pobox.c: you can abort that computation with an interrupt (Ctrl-C) to terminate
5f892713c3 2021-03-03 trnsz@pobox.c: REDUCE. Restart REDUCE, followed by the statement "in less1.red",
5f892713c3 2021-03-03 trnsz@pobox.c: followed by a semicolon and return, to restart the lesson at the
5f892713c3 2021-03-03 trnsz@pobox.c: beginning.;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: pause;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT Now watch this example illustrating some more dramatic
5f892713c3 2021-03-03 trnsz@pobox.c: differences from traditional scientific programming systems:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: e1 := 2*g + 3*g + h^3/h;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT Note how we are allowed to use variables to which we have
5f892713c3 2021-03-03 trnsz@pobox.c: assigned no values! Note too how similar terms and similar factors
5f892713c3 2021-03-03 trnsz@pobox.c: are combined automatically. REDUCE also automatically expands
5f892713c3 2021-03-03 trnsz@pobox.c: products and powers of sums, together with placing expressions over
5f892713c3 2021-03-03 trnsz@pobox.c: common denominators, as illustrated by the examples:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: e2 := e1*(f+g);
5f892713c3 2021-03-03 trnsz@pobox.c: e2 := e1^2;
5f892713c3 2021-03-03 trnsz@pobox.c: e1+1/e1;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT Our last example also illustrates that there is no need to
5f892713c3 2021-03-03 trnsz@pobox.c: assign an expression if we do not plan to use its value later. Try
5f892713c3 2021-03-03 trnsz@pobox.c: some similar examples.;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: pause;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT It is not always desirable to expand expressions over a common
5f892713c3 2021-03-03 trnsz@pobox.c: denominator, and we can use the OFF statement to turn off either or
5f892713c3 2021-03-03 trnsz@pobox.c: both computational switches which control these transformations. The
5f892713c3 2021-03-03 trnsz@pobox.c: switch named EXP controls EXPansion, and the switch named MCD controls
5f892713c3 2021-03-03 trnsz@pobox.c: the Making of Common Denominators;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: off exp, mcd;
5f892713c3 2021-03-03 trnsz@pobox.c: e2 := e1^2$
5f892713c3 2021-03-03 trnsz@pobox.c: e2 := e2*(f+g) + 1/e1;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT To turn these switches back on, we type:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: on exp, mcd;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT Try a few relevant examples with these switches turned off
5f892713c3 2021-03-03 trnsz@pobox.c: individually and jointly;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: pause;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: on exp; % Just in case you turned it off!
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT The "%" character is another way to introduce a comment that
5f892713c3 2021-03-03 trnsz@pobox.c: extends as far as the end of the line.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: Now consider the example:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: e2 := (2*(f*h)^2 - f^2*g*h - (f*g)^2 - f*h^3 + f*h*g^2 - h^4
5f892713c3 2021-03-03 trnsz@pobox.c: + g*h^3)/(f^2*h - f^2*g - f*h^2 + 2*f*g*h - f*g^2
5f892713c3 2021-03-03 trnsz@pobox.c: - g*h^2 + g^2*h);
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT It is not obvious, but the numerator and denominator of this
5f892713c3 2021-03-03 trnsz@pobox.c: expression share a nontrivial common divisor which can be canceled.
5f892713c3 2021-03-03 trnsz@pobox.c: To make REDUCE automatically cancel greatest common divisors, we turn
5f892713c3 2021-03-03 trnsz@pobox.c: on the computational switch named GCD:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: on gcd;
5f892713c3 2021-03-03 trnsz@pobox.c: e2;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT The switch is not on by default because
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: 1. It can consume a lot of time.
5f892713c3 2021-03-03 trnsz@pobox.c: 2. Often we know in advance the few places where a nontrivial
5f892713c3 2021-03-03 trnsz@pobox.c: GCD can occur in our problem.
5f892713c3 2021-03-03 trnsz@pobox.c: 3. Even without GCD cancellation, expansion and common
5f892713c3 2021-03-03 trnsz@pobox.c: denominators guarantee that any rational expression which is
5f892713c3 2021-03-03 trnsz@pobox.c: equivalent to zero simplifies to zero.
5f892713c3 2021-03-03 trnsz@pobox.c: 4. When the denominator is the greatest common divisor, such
5f892713c3 2021-03-03 trnsz@pobox.c: as for (X^2 - 2*X + 1)/(X - 1), REDUCE cancels the
5f892713c3 2021-03-03 trnsz@pobox.c: greatest common divisor even when GCD is OFF.
5f892713c3 2021-03-03 trnsz@pobox.c: 5. GCD cancellation sometimes makes expressions more
5f892713c3 2021-03-03 trnsz@pobox.c: complicated, such as with (F^10 - G^10)/(F^2 + F*G - 2*G^2).
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: Try the examples mentioned in this comment, together with one or two
5f892713c3 2021-03-03 trnsz@pobox.c: other relevant ones.;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: pause;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT Exact rational arithmetic can consume an alarming amount of
5f892713c3 2021-03-03 trnsz@pobox.c: computer time when the constituent integers have quite large
5f892713c3 2021-03-03 trnsz@pobox.c: magnitudes, and the results become awkward to interpret qualitatively.
5f892713c3 2021-03-03 trnsz@pobox.c: When this is the case and somewhat inexact numerical coefficients are
5f892713c3 2021-03-03 trnsz@pobox.c: acceptable, we can have the arithmetic done using floating point by
5f892713c3 2021-03-03 trnsz@pobox.c: turning on the computational switch ROUNDED. With this switch on, any
5f892713c3 2021-03-03 trnsz@pobox.c: non-integer rational numbers are approximated by floating-point
5f892713c3 2021-03-03 trnsz@pobox.c: numbers, and the result of any arithmetic operation is floating-point
5f892713c3 2021-03-03 trnsz@pobox.c: when any of its operands is floating point. For example:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: on rounded;
5f892713c3 2021-03-03 trnsz@pobox.c: e1 := (12.3456789e3*f + 3*g)^2 + 1/2;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT With ROUNDED off, any floating-point constants are
5f892713c3 2021-03-03 trnsz@pobox.c: automatically represented as explicit rational numbers:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: off rounded;
5f892713c3 2021-03-03 trnsz@pobox.c: e1 := 12.35*g;
5f892713c3 2021-03-03 trnsz@pobox.c: pause;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT A number of elementary functions, such as SIN, COS and LOG,
5f892713c3 2021-03-03 trnsz@pobox.c: are built into REDUCE. Moreover, the letter E represents the base of
5f892713c3 2021-03-03 trnsz@pobox.c: the natural logarithms, so the exponentiation operator enables us to
5f892713c3 2021-03-03 trnsz@pobox.c: represent the exponential function as well as fractional powers. For
5f892713c3 2021-03-03 trnsz@pobox.c: example:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: e1:= sin(-f*g) + log(e) + (3*g^2*cos(-1))^(1/2);
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT What automatic simplifications can you identify in this
5f892713c3 2021-03-03 trnsz@pobox.c: example?
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: Note that REDUCE never approximates the values of these functions,
5f892713c3 2021-03-03 trnsz@pobox.c: even for numerical arguments, and exact computations are generally
5f892713c3 2021-03-03 trnsz@pobox.c: impossible for non-trivial numerical arguments.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: Experimentally determine some other built-in simplifications for these
5f892713c3 2021-03-03 trnsz@pobox.c: functions.;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: pause;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT Later you will learn how to introduce additional
5f892713c3 2021-03-03 trnsz@pobox.c: simplifications and additional functions. To compute numerical
5f892713c3 2021-03-03 trnsz@pobox.c: approximations for examples such as COS(1) simply turn on ROUNDED.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: Differentiation is also built-into REDUCE. For example, to
5f892713c3 2021-03-03 trnsz@pobox.c: differentiate E1 with respect to F:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: e2 := df(e1,f);
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT To compute the second derivative of E2 with respect to G, we
5f892713c3 2021-03-03 trnsz@pobox.c: can type either DF(E2,G,2) or DF(E1,F,1,G,2) or DF(E1,F,G,2) or
5f892713c3 2021-03-03 trnsz@pobox.c: DF(E1,G,2,F,1) or;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: df(e1,g,2,f);
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT Surely you can't resist trying a few derivatives of your own!
5f892713c3 2021-03-03 trnsz@pobox.c: (Careful, high-order derivatives can be alarmingly complicated.);
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: pause;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT REDUCE uses the name I to represent (-1)^(1/2), incorporating
5f892713c3 2021-03-03 trnsz@pobox.c: some simplification rules such as replacing I^2 by -1. Here is an
5f892713c3 2021-03-03 trnsz@pobox.c: opportunity to experimentally determine other simplifications such as
5f892713c3 2021-03-03 trnsz@pobox.c: for I^3, 1/I^23, and (I^2-1)/(I-1).;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: pause;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT Clearly it is inadvisable to use E or I as a variable. T is
5f892713c3 2021-03-03 trnsz@pobox.c: also inadvisable for reasons that will become clear later.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: The value of a variable is said to be "bound" to the variable. Any
5f892713c3 2021-03-03 trnsz@pobox.c: variable to which we have assigned a value is called a bound variable,
5f892713c3 2021-03-03 trnsz@pobox.c: and any variable to which we have not assigned a value is called an
5f892713c3 2021-03-03 trnsz@pobox.c: indeterminate. Occasionally it is desirable to make a bound variable
5f892713c3 2021-03-03 trnsz@pobox.c: into an indeterminate, and this can be done using the CLEAR command.
5f892713c3 2021-03-03 trnsz@pobox.c: For example:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: clear r2d2, e1, e2;
5f892713c3 2021-03-03 trnsz@pobox.c: e2;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT If you suspect that a degenerate assignment, such as E1:=E1,
5f892713c3 2021-03-03 trnsz@pobox.c: would suffice to clear a bound variable, try it on one of your own
5f892713c3 2021-03-03 trnsz@pobox.c: bound variables.;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: pause;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT REDUCE also supports matrix algebra, as illustrated by the
5f892713c3 2021-03-03 trnsz@pobox.c: following:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: matrix e1(4,1), f;
5f892713c3 2021-03-03 trnsz@pobox.c: e1; f;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT This declaration establishes E1 as a matrix with 4 rows and 1
5f892713c3 2021-03-03 trnsz@pobox.c: column, while establishing F as a matrix of unspecified size. To
5f892713c3 2021-03-03 trnsz@pobox.c: establish element values (and sizes if not already established in the
5f892713c3 2021-03-03 trnsz@pobox.c: MATRIX declaration), we can use the MAT function, as illustrated by
5f892713c3 2021-03-03 trnsz@pobox.c: the following example:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: h := mat((log(g), g+3), (g, 5/7));
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT Only after establishing the size of a matrix by declaring it
5f892713c3 2021-03-03 trnsz@pobox.c: or executing a matrix assignment can we refer to an individual element
5f892713c3 2021-03-03 trnsz@pobox.c: or to the matrix as a whole. For example to increase the last element
5f892713c3 2021-03-03 trnsz@pobox.c: of H by 1 then form twice the transpose of H, we can type:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: h(2,2) := h(2,2) + 1;
5f892713c3 2021-03-03 trnsz@pobox.c: 2*tp(h);
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT To compute the determinant of H:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: det(h);
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT To compute the trace of H:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: trace(h);
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT To compute the inverse of H, we can use H^(-1) or 1/H. To
5f892713c3 2021-03-03 trnsz@pobox.c: compute the solution to the equation H*F = MAT((G),(2)), we can
5f892713c3 2021-03-03 trnsz@pobox.c: left-multiply the right-hand side by the inverse of H:;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: f := 1/h*mat((g),(2));
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: COMMENT Notes:
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: 1. MAT((G),(2))/H would denote right-multiplication by the
5f892713c3 2021-03-03 trnsz@pobox.c: inverse, which is not what we want.
5f892713c3 2021-03-03 trnsz@pobox.c: 2. Solutions for a set of right-hand-side vectors are most
5f892713c3 2021-03-03 trnsz@pobox.c: efficiently computed simultaneously by collecting the right-
5f892713c3 2021-03-03 trnsz@pobox.c: hand sides together as the columns of a single multiple-column
5f892713c3 2021-03-03 trnsz@pobox.c: matrix.
5f892713c3 2021-03-03 trnsz@pobox.c: 3. Sub-expressions of the form 1/H*... or H^(-1)*... are computed
5f892713c3 2021-03-03 trnsz@pobox.c: more efficiently than if the inverse is computed separately in
5f892713c3 2021-03-03 trnsz@pobox.c: a previous statement, so separate computation of the inverse
5f892713c3 2021-03-03 trnsz@pobox.c: is advisable only if several solutions are desired and if
5f892713c3 2021-03-03 trnsz@pobox.c: they cannot be computed simultaneously.
5f892713c3 2021-03-03 trnsz@pobox.c: 4. MAT must have parentheses around each row of elements even if
5f892713c3 2021-03-03 trnsz@pobox.c: there is only one row or only one element per row.
5f892713c3 2021-03-03 trnsz@pobox.c: 5. References to individual matrix elements must have exactly two
5f892713c3 2021-03-03 trnsz@pobox.c: subscripts, even if the matrix has only one row or one column.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: Congratulations on completing lesson 1! I urge you to try a sequence
5f892713c3 2021-03-03 trnsz@pobox.c: of more ambitious examples for the various features that have been
5f892713c3 2021-03-03 trnsz@pobox.c: introduced, in order to gain some familiarity with the relationship
5f892713c3 2021-03-03 trnsz@pobox.c: between problem size and computing time for various operations. (The
5f892713c3 2021-03-03 trnsz@pobox.c: command "ON TIME" causes computing time to be output.) I also urge
5f892713c3 2021-03-03 trnsz@pobox.c: you to bring to the next lesson appropriate examples from textbooks,
5f892713c3 2021-03-03 trnsz@pobox.c: articles, or elsewhere, in order to experience the decisive learning
5f892713c3 2021-03-03 trnsz@pobox.c: reinforcement afforded by meaningful personal examples that are not
5f892713c3 2021-03-03 trnsz@pobox.c: arbitrarily contrived.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: To avoid the possibility of interference from assignments and
5f892713c3 2021-03-03 trnsz@pobox.c: declarations in lesson 1, it is wise to execute lesson 2 in a fresh
5f892713c3 2021-03-03 trnsz@pobox.c: REDUCE session, when you are ready.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: ;end;