DifferentialGeometry[Tools] - Maple Programming Help

Home : Support : Online Help : Mathematics : DifferentialGeometry : Tools : DifferentialGeometry/Tools/CalculationHistory

DifferentialGeometry[Tools]

 CalculationHistory

 Calling Sequence CalculationHistory:-Update(S, exp) CalculationHistory:-Get(S) CalculationHistory:-Clear()

Parameters

 S - an unassigned name or string exp - any Maple expression

Description

 • The CalculationHistory module is a collection of three simple commands for storing and retrieving the results of intermediate calculations.  The command Update(S, exp) stores the Maple expression exp in a table (called the HistoryTable) with table index S.  Only the 10 most current values of exp are retained in the HistoryTable.  The command Get(S) retrieves these values.  The command Clear() clears all stored values in the HistoryTable.
 • At present, the commands Query/Indecomposable, Decompose and Nilradical use the CalculationHistory module and store intermediate results which can be recalled.
 • The number of calculations stored in the HistoryTable can be specified by the DifferentialGeometry:-Preferences command.
 • This command is part of the DifferentialGeometry:-Tools package, and so can be used in the form CalculationHistory:-Update(...) only after executing the commands with(DifferentialGeometry) and with(Tools) in that order.  It can always be used in the long form DifferentialGeometry:-Tools:-CalculationHistory:-Update.  The commands Get and Clear work the same way.

Examples

 > $\mathrm{with}\left(\mathrm{DifferentialGeometry}\right):$$\mathrm{with}\left(\mathrm{Tools}\right):$$\mathrm{with}\left(\mathrm{LieAlgebras}\right):$
 > $\mathrm{exports}\left(\mathrm{CalculationHistory}\right)$
 ${\mathrm{Clear}}{,}{\mathrm{Get}}{,}{\mathrm{Update}}$ (1)

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.

 > $\mathrm{Test}\left(25\right)$
 ${5525}$ (2)

Retrieve the calculated values from the HistoryTable -- only 10 values are stored.

 > $\mathrm{Tools}:-\mathrm{CalculationHistory}:-\mathrm{Get}\left("Test"\right)$
 $\left[\left[{25}{,}{625}\right]{,}\left[{24}{,}{576}\right]{,}\left[{23}{,}{529}\right]{,}\left[{22}{,}{484}\right]{,}\left[{21}{,}{441}\right]{,}\left[{20}{,}{400}\right]{,}\left[{19}{,}{361}\right]{,}\left[{18}{,}{324}\right]{,}\left[{17}{,}{289}\right]{,}\left[{16}{,}{256}\right]\right]$ (3)

Clear all calculated values.

 > $\mathrm{Tools}:-\mathrm{CalculationHistory}:-\mathrm{Clear}\left("Test"\right)$
 $\left[{}\right]$ (4)

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."

 > $L≔\mathrm{_DG}\left(\left[\left["LieAlgebra",\mathrm{Alg3},\left[4\right]\right],\left[\left[\left[1,3,2\right],-2\right],\left[\left[1,4,1\right],-1\right],\left[\left[2,3,1\right],-1\right],\left[\left[2,4,2\right],-1\right]\right]\right]\right)$
 ${L}{≔}\left[\left[{\mathrm{e1}}{,}{\mathrm{e3}}\right]{=}{-}{2}{}{\mathrm{e2}}{,}\left[{\mathrm{e1}}{,}{\mathrm{e4}}\right]{=}{-}{\mathrm{e1}}{,}\left[{\mathrm{e2}}{,}{\mathrm{e3}}\right]{=}{-}{\mathrm{e1}}{,}\left[{\mathrm{e2}}{,}{\mathrm{e4}}\right]{=}{-}{\mathrm{e2}}\right]$ (5)
 > $\mathrm{DGsetup}\left(L\right)$
 ${\mathrm{Lie algebra: Alg3}}$ (6)
 > $\mathrm{Decompose}\left(\right):$
 > $\mathrm{CalculationHistory}:-\mathrm{Get}\left("Decompose"\right)$
 $\left[\left[{"Alg3"}{,}\left[{-}{1}{+}{\mathrm{_z5}}{,}{-}\frac{{1}}{{2}}{+}{{\mathrm{_z5}}}^{{2}}\right]\right]\right]$ (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.

 > $\mathrm{Decompose}\left(\mathrm{hint}=\left[x,\left[{x}^{2}-\frac{1}{2},\left[x-\frac{1}{\sqrt{2}},x+\frac{1}{\sqrt{2}}\right]\right]\right]\right)$
 $\left[\left[\begin{array}{cccc}\frac{{1}}{{2}}& \frac{{1}}{{4}}{}\sqrt{{2}}& {0}& {0}\\ {0}& {0}& \frac{{1}}{{2}}& \frac{{1}}{{4}}{}\sqrt{{2}}\\ \frac{{1}}{{2}}& {-}\frac{{1}}{{4}}{}\sqrt{{2}}& {0}& {0}\\ {0}& {0}& \frac{{1}}{{2}}& {-}\frac{{1}}{{4}}{}\sqrt{{2}}\end{array}\right]{,}\left[{\mathrm{e1}}{+}\sqrt{{2}}{}{\mathrm{e2}}{,}{\mathrm{e3}}{+}\sqrt{{2}}{}{\mathrm{e4}}{,}{\mathrm{e1}}{-}\left(\sqrt{{2}}{}{\mathrm{e2}}\right){,}{\mathrm{e3}}{-}\left(\sqrt{{2}}{}{\mathrm{e4}}\right)\right]\right]$ (8)
 Alg3 >