Trajectory Points - Maple Help

CodeTools[ProgramAnalysis]

 TrajectoryPoints
 generate points from a WhileLoop

 Calling Sequence TrajectoryPoints(loop, seedpoints, n, p, trajectorytype)

Parameters

 loop - seedpoints - list of integers, or a list or a set thereof; initial points for the generated trajectories n - posint, number of trajectory points to generate per seed point p - (optional) posint, compute the trajectories modulo this number trajectorytype - (optional) one of plain (default), inductive, or absolute, the type of trajectory to generate

Description

 • This command computes loop trajectories for the WhileLoop loop.  The trajectories start the point(s) given by seedpoints.  These points are formed of loop's parameters and variables, formed as the list $\left[\mathrm{loop}:-{\mathrm{variables}}_{},\mathrm{loop}:-{\mathrm{parameters}}_{}\right]$.  The loop is iterated for each of these seed points and new values are computed.
 • This command operates in three modes depending on the trajectorytype:
 – trajectorytype = plain (default) : the loop is executed as in the original procedure.  loop's  guard and branch conditions are evaluated at every iteration, causing a single trajectory to be generate per initial point and terminating as the guard condition evaluates to false or as the requested number of points is reached.
 – trajectorytype = inductive : the guard condition is ignored while iterating the loop so that the generated trajectories may continue beyond their natural end points.
 – trajectorytype = absolute : both the guard and branch conditions of the loop are ignored.  At each iteration, the trajectory is split so that it follows each branch in the loop's if statement as if the branches were all simultaneously taken.
 • The loop will be iterated until at least n distinct points are generated, if possible.  The number of returned points may be fewer than n if the loop terminates prematurely due to the guard condition or if the trajectories loop back onto themselves and cease to generate new points.
 • The evaluation of the loop trajectories can optionally be conducted modulo p.  By default, the computations are done without modular arithmetic in a characteristic zero field.

Examples

 > $\mathrm{with}\left(\mathrm{CodeTools}\left[\mathrm{ProgramAnalysis}\right]\right):$

Generating a Sufficient Number of Points

 • The following procedure counts up from 1 to $a$:
 > p := proc(a)     local n:     n := 1:     while n < a do         n := n + 1:     end do:     return n: end proc:
 • Create the WhileLoop data structure:
 > $\mathrm{loop}≔\mathrm{CreateLoop}\left(p\right)$
 ${\mathrm{loop}}{≔}{\mathrm{Record}}{}\left({\mathrm{WhileLoop}}{,}{\mathrm{variables}}{=}\left[{n}\right]{,}{\mathrm{parameters}}{=}\left[{a}\right]{,}{\mathrm{initialization}}{=}\left[{1}\right]{,}{\mathrm{transitions}}{=}\left[\left[\left[\right]{,}\left[{n}{+}{1}\right]\right]\right]{,}{\mathrm{guard}}{=}\left({n}{<}{a}\right){,}{\mathrm{precondition}}{=}\left[\right]{,}{\mathrm{postcondition}}{=}\left[\right]{,}{\mathrm{returnvalue}}{=}\left[{n}\right]\right)$ (1)
 • Ask for 20 trajectory points to be generated, starting with $n=1$ and taking $a=10$:
 > $\mathrm{trajcetory_points_1}≔\mathrm{TrajectoryPoints}\left(\mathrm{loop},\left[1,10\right],20\right)$
 ${\mathrm{trajcetory_points_1}}{≔}\left[\left[{6}{,}{10}\right]{,}\left[{10}{,}{10}\right]{,}\left[{2}{,}{10}\right]{,}\left[{5}{,}{10}\right]{,}\left[{4}{,}{10}\right]{,}\left[{7}{,}{10}\right]{,}\left[{9}{,}{10}\right]{,}\left[{8}{,}{10}\right]{,}\left[{3}{,}{10}\right]{,}\left[{1}{,}{10}\right]\right]$ (2)
 • Fewer than 20 points were generated in counting from 1 to 10:
 > $\mathrm{numelems}\left(\mathrm{trajcetory_points_1}\right)$
 ${10}$ (3)
 • Additional seed points can be given to generate more trajectory points:
 > $\mathrm{trajcetory_points_2}≔\mathrm{TrajectoryPoints}\left(\mathrm{loop},\left[\left[1,10\right],\left[1,20\right]\right],20\right)$
 ${\mathrm{trajcetory_points_2}}{≔}\left[\left[{6}{,}{10}\right]{,}\left[{1}{,}{20}\right]{,}\left[{10}{,}{10}\right]{,}\left[{9}{,}{20}\right]{,}\left[{2}{,}{10}\right]{,}\left[{5}{,}{10}\right]{,}\left[{10}{,}{20}\right]{,}\left[{4}{,}{10}\right]{,}\left[{7}{,}{20}\right]{,}\left[{8}{,}{20}\right]{,}\left[{5}{,}{20}\right]{,}\left[{11}{,}{20}\right]{,}\left[{6}{,}{20}\right]{,}\left[{7}{,}{10}\right]{,}\left[{3}{,}{20}\right]{,}\left[{9}{,}{10}\right]{,}\left[{4}{,}{20}\right]{,}\left[{2}{,}{20}\right]{,}\left[{8}{,}{10}\right]{,}\left[{3}{,}{10}\right]{,}\left[{1}{,}{10}\right]\right]$ (4)
 > $\mathrm{numelems}\left(\mathrm{trajcetory_points_2}\right)$
 ${21}$ (5)

Compatibility

 • The CodeTools[ProgramAnalysis][TrajectoryPoints] command was introduced in Maple 2016.
 • For more information on Maple 2016 changes, see Updates in Maple 2016.