Sequence defined by an algorithm

A sequence of real numbers (numerical sequence) is a function from IN to IR.

The variable is called "index". In Casyopée the sequence index is the letter* n*.

To define sequences, choose this letter from the list at the top left of the algebra tab.

In the menu of the algebra tab, the *Create Function *entry is replaced by *Create Sequence*.

There are two ways to create a sequence.

## Sequence defined by a formula

This choice corresponds to an explicit definition. The input box opens.

The identifier (name) of the suite is a letter to choose from the list at the bottom left.

The index *n* is entered on the keyboard or by the button on the right.

The syntax is that of the Casyopée formulas.

After creation, the sequence appears with its definition in the list of expressions.

The buttons at the bottom of the graphics tab provide a graphical plot and the limit.

On the graphical plot, the trace makes it possible to obtain the values of the sequence.

It is also possible to obtain a table of values with a button at the top of the graphics tab.

The purpose of the other buttons is the same as for the graphs of functions.

Like for functions, the *Calculate *button allows to perform symbolic calculations.

Choose for instance **Expand**.

The expanded expression appears in the list of expressions.

## Sequence defined by an algorithm.

When choosing this subentry, a list allows to choose the identifier (the name) of the sequence

The input box of the algorithm opens. The initial values of n and of the sequence are given in lines 1 and 2.It is possible to modify line 2 for another initial value.

The form of iteration proposed is the FOR ... ENDFOR loop which allows programming a given number of values.

We enter in the loop a recursion formula by the button *Assign Variable in the loop*.

One must then test before clicking the Create button. It is possible to put a comment on the bottom right.

After creation, the result is displayed with the comment in the list of functions. The graphical plots of *u* and *v* are superimposed.

Casyopée does not calculate a limit for *v* because, as a difference with *u*, this sequence has no formal definition.

It is possible to create sequences bymore complex algorithms, using global variables (Casyopée parameters) and local variables (button **Declare variable**).See the page *Functions Defined by an Algorithm *.

In the example below, the sequence converges towards the arithmetico-geometric mean of two numbers A and B.

## Sequences in the geometry tab

In the geometry tab, it is possible to display sequences in the same screen as function curves and other geometric objects. It is also possible to create a free point following the values of the sequence.

Below, we define by an algorithm a sequence *u* converging towards the fixed point of the cosine function. The free point P follows the valuesof the sequence. Using a parallel to the *x*-axis passing through P, and dragging this point, we observe that the values of the sequence straddle the y-coordinate of the point of intersection of the representation of the cosine function and the first bisector.