# `plot`::`Sequence`

Sequences

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```plot::Sequence(`y`, `n = n1 .. n2`, <`a = amin .. amax`>, `options`)
plot::Sequence(`x`, `y`, `n = n1 .. n2`, <`a = amin .. amax`>, `options`)
```

## Description

`plot::Sequence(y(n), n = n_1 .. n_2 )` creates the points .

`plot::Sequence(x(n), y(n), n = n_1 .. n_2 )` creates the sequence of points .

`plot::Sequence` creates graphs of sequences, i.e., functions and curves defined over (some subset of) the integers.

`plot::Sequence(y(n), n = n_1..n_2 )` is functionally equivalent to the call ```plot::PointList2d([[n, y(n)] \$ n = n_1..n_2 )```, and ```plot::Sequence(x(n), y(n), n = n_1..n_2 )``` creates the same image as `plot::PointList2d([[x(n), y(n)] \$ n = n_1..n_2 )`. See Example 2 for some extra functionality.

## Attributes

AttributePurposeDefault Value
`AffectViewingBox`influence of objects on the `ViewingBox` of a scene`TRUE`
`AntiAliased`antialiased lines and points?`TRUE`
`Color`the main color`RGB::Blue`
`Frames`the number of frames in an animation`50`
`Legend`makes a legend entry
`LegendText`short explanatory text for legend
`LegendEntry`add this object to the legend?`FALSE`
`LineColor`color of lines`RGB::Blue`
`LineWidth`width of lines`0.35`
`LineColor2`color of lines`RGB::DeepPink`
`LineStyle`solid, dashed or dotted lines?`Solid`
`LinesVisible`visibility of lines`FALSE`
`LineColorType`line coloring types`Flat`
`LineColorFunction`functional line coloring
`Name`the name of a plot object (for browser and legend)
`ParameterEnd`end value of the animation parameter
`ParameterName`name of the animation parameter
`ParameterBegin`initial value of the animation parameter
`ParameterRange`range of the animation parameter
`PointSize`the size of points`2`
`PointStyle`the presentation style of points`FilledCircles`
`PointsVisible`visibility of mesh points`TRUE`
`TimeEnd`end time of the animation`10.0`
`TimeBegin`start time of the animation`0.0`
`TimeRange`the real time span of an animation`0.0` .. `10.0`
`Title`object title
`TitleFont`font of object titles[`" sans-serif "`, `11`]
`TitlePosition`position of object titles
`TitleAlignment`horizontal alignment of titles w.r.t. their coordinates`Center`
`TitlePositionX`position of object titles, x component
`TitlePositionY`position of object titles, y component
`UMax`final value of parameter “u”
`UMin`initial value of parameter “u”
`UName`name of parameter “u”
`URange`range of parameter “u”
`Visible`visibility`TRUE`
`VisibleAfter`object visible after this time value
`VisibleBefore`object visible until this time value
`VisibleFromTo`object visible during this time range
`VisibleAfterEnd`object visible after its animation time ended?`TRUE`
`VisibleBeforeBegin`object visible before its animation time starts?`TRUE`
`XFunction`function for x values
`YFunction`function for y values

## Examples

### Example 1

When given one expression and a range, `plot::Sequence` plots the sequence in function style:

`plot(plot::Sequence((-1)^n/n, n=1..10))` `plot::Sequence` accepts a variety of attributes to influence the appearance of the plot:

```plot(plot::Sequence((-1)^n/n, n=1..10, PointStyle = FilledDiamonds, PointSize = 4*unit::mm, Color = RGB::Red), plot::Sequence(1/n, n=1..10, PointsVisible = FALSE, LinesVisible = TRUE), plot::Sequence(-1/n, n=1..10, PointsVisible = FALSE, LinesVisible = TRUE))``` ### Example 2

By giving two expressions, we can make `plot::Sequence` plot a sequence of points given by two expressions, for the x- and y-coordinate:

```plot(plot::Sequence(sin(2*PI*n/60), cos(2*PI*n/60), n = 1..60), Scaling=Constrained)``` In contrast to the `plot::PointList2d` call listed above as equivalent, `plot::Sequence` allows to easily animate the number of points:

```plot(plot::Sequence(sin(2*PI*n/60), cos(2*PI*n/60), n = 1..nmax, nmax = 1..60), Scaling=Constrained, Frames = 60, TimeRange = 1..60)``` ### Example 3

By including the animation parameter in the expressions `x` and `y`, more complex animations are possible. As an example, we animate Newton iteration for different starting values. First of all, we define the iteration step which maps an approximation to its refinement:

`newton := x -> x - f(x)/f'(x):`

For concrete calculations, we will need to use a specific function `f`:

`f := x -> sin(2*x) + x^2:`

To get successive iteration steps, we will employ the function iteration operator `@@`. For example, the third improvement of the starting value `1.0` is calculated as follows:

`(newton@@3)(1.0)`
` `

For our animation, we want to show the approximations, the corresponding function values, and the order in which the approximations are found. Additionally, we display the function itself:

```function := plot::Function2d(f, x = -2..2): steps := plot::Sequence((newton@@n)(x0), f((newton@@n)(x0)), n = 0..5, x0 = -1.25..1.5, Color = RGB::Green, LinesVisible = TRUE): plot(function, steps, ViewingBox = [-2..2, -1..5], PointSize = 2.5)``` To further increase the number of iteration steps, we should reuse previously computed approximations. To this end, we use a function with ```option remember```:

```newtonIter := proc(x0, n) option remember; begin if domtype(n) <> DOM_INT then return(procname(args())); end_if; if iszero(n) then x0 else newton(newtonIter(x0, n-1)); end_if; end_proc:```

Additionally, we use `plot::Point2d` to display the initial point in a different color.

```steps := plot::Sequence(newtonIter(x0, n), f(newtonIter(x0, n)), n = 0..10, x0 = -1.25..1.5, Color = RGB::Green, LinesVisible = TRUE): start := plot::Point2d(x0, f(x0), x0 = -1.25..1.5): plot(function, steps, start, ViewingBox = [-2..2, -1..5], PointSize = 2.5)``` Since `f` was evaluated in our object definitions, we will need to reissue the corresponding commands when changing `f`.

## Parameters

 `x`, `y` Real-valued arithmetical expressions in `n` and possibly the animation parameter `a`. `x`, `y` are equivalent to the attributes `XFunction`, `YFunction`. `n` The index of the sequence: an identifier or an indexed identifier. `n` is equivalent to the attribute `UName`. `n1 .. n2` The range of the index `n`: real-valued expressions, possibly of the animation parameter `a`. `n1` .. `n2` is equivalent to the attributes `URange`, `UMin`, `UMax`. `a` Animation parameter, specified as `a```` = amin..amax```, where `amin` is the initial parameter value, and `amax` is the final parameter value.