You are on page 1of 4

Sequences in Mathcad

Creating and displaying a sequence


Two special types of Mathcad variable are required to create a sequence.

The two variables can be obtained from the palette 1 icons and
Subscripted variables
These are used to represent sequences. In the notation un, n is called the subscript of
u.

For example - Define u := 2 u := 4 u := 8 2


0 1 2
and u= 4
Display u =4
u =2 1 u =8
0 2 8
Here u refers to the sequence as a whole, which Mathcad displays as a
column of numbers.
Keyboard alternative

The keyboard alternative for the palette icon is [ ( left square bracket ) .
For example, u[3 gives u
3

Range variables
Range variables are used to do repeated calculations.
Whereas a conventional variable takes only one value at any given time, a range
variable takes
on a range of values, separated by uniform steps. The definition contains three
numbers which
give the starting value, next value .. and final value of the range.

In this example the range variable i takes the five values 1, 2, 3, 4 and 5.
Define i := 1 , 2 .. 5
The number 1 is the first value taken by the range variable.Display
i =
The number 2 is the second value in the range. 1
The difference between this and the first value is the step size . 2
The final number 5 is the last value in the range. 3
4
Keyboard alternative 5
The keyboard alternative for the palette icon is ; ( semicolon ) .

For example, to define the range variable j above you could type j:0,1;3

MST Sequences in Mathcad


Task

Enter the three expressions below.

ORIGIN := 1
First term of the sequence has subscript 1 ....................................

Define a range variable n going from 1 to 12 in steps of 1.

; type 12
Type n ; click ; type 1,2 ; click

( Alternatively, just type n:1,2;12 )

Define the subscripted variable bn .

Type b ; click ; type n ; click ; type 5+3*(n-1)

( Alternatively, just type b[n:5+3*(n-1) )

Finally, display all the terms of the sequence.


Type b= ( or type b and click )

Solution

This is our solution.


( The expressions have been positioned so that you can see them all on a single
screen. )

First term of the sequence has subscript 1 ..................ORIGIN := 1 1


1 5
2 8
Define a range variable n going from 1 to 12 in steps of 1 n := 1 , 2 .. 12 3 11
4 14
5 17
bn := 5 + 3⋅ ( n − 1)
Define the subscripted variable bn ............................... b= 6 20
7 23
8 26
Display all the terms of the sequence ....................................................... 9 29
10 32
Next we will plote the graph of this sequence ( bn) 11 35
12 38

MST Sequences in Mathcad


Plotting a graph of a sequence

To create a graph of the arithmetic sequence, by plotting bn against n,


follow the four steps below.

(A) Click on the graph button ( or type @ - the keyboard alternative ) .

(B)Mathcad creates an empty graph.The selection box should be on the place holder in
the middle of the horizontal axis. Type n

(C) Now click on the placeholder in the middle of the vertical axis. Put bn on this

axis, by using the icon or typing b[n

(D) Click anywhere outside the graph and Mathcad will calculate and graph the points.
Comments

The four stages of graph creation are shown below :

Mathcad automatically draws a line graph ( the default graph type ).


Unfortunately this is not what we want ! We are graphing a sequence of separate
values b1, b2, ..., b12 and want the graph to show these as individual points.
Fortunately we can change the format of the graph display .

(Next we will change the format of ( bn) graph)

MST Sequences in Mathcad


How to format a graph in Mathcad
To change the format of a graph, follow these steps.
(A) Click in the graph to select it. Mathcad surrounds the graph in a blue selection box
and the Graphics menu is replaced by the X-Y Plot menu.

(B) Choose Format... from the X-Y Plot menu ( or double-click on the graph itself ) .
The Format option box ( titled 'Formatting Currently Selected X-Y Plot' ) appears.

(C) Change the desired settings in the Format option box - see below.
Changing the settings
The trace settings, in the middle of the Format option box, control how each trace (
curve )
will be displayed on the graph. The diagram below shows how to change these
settings to
mark the individual points on the curve with crosses and remove the line.

(C1) Click on ' trace 1'.

The trace details


appear in the five
boxes below.

(C2) Click on the arrow beside the box in the 'Symbol' column to see a drop-down list
of marker types and select x's .

(C3) Click on the arrow beside the box for 'Line' and select none from the list.

(D) That's it ! Finally click the large 'OK' button to see the results.

40

bn 20

0
0 5 10 15
n

The bn graph after the previous format

MST Sequences in Mathcad

You might also like