>
|
|
>
|
|
Example 1.
We begin with a simple example to illustrate the use of the three exports of the CalculationHistory module. The program Test computes the sum of squares of the first n integers. The Update command stores the individual terms in the sum.
>
|
Test := proc(n)
local i, s, t;
s := 0;
for i to n do
t := i^2;
Tools:-CalculationHistory:-Update("Test", [i, t]);
s := s + t;
od;
s
end:
|
Run the program test.
Retrieve the calculated values from the HistoryTable -- only 10 values are stored.
>
|
|
| (3) |
Clear all calculated values.
>
|
|
Example 2.
The following example is taken from the help file for the LieAlgebras command Decompose. A critical step in the algorithm involves factoring a certain polynomial. This polynomial is stored in the HistoryTable under the index "Decompose."
>
|
|
| (5) |
>
|
|
| (7) |
To perform the decomposition of the algebra, a factorization of the polynomial -1/2 + _z1^2 is required. We perform this factorization by hand and rerun the DecomposeLieAlgebra program using the hint option to pass the program the information it needs.
>
|
|
| (8) |