Download MuPAD from SciFace

MuPAD Pro Computing Essentials - Examples 

Example 12.1 - Plotting Sequences  

In school practice we often need to plot a sequence of numbers. Here are two pieces of the code showing how to plot given number of terms of a sequence. 

Let   .  We will plot first 20 terms. 

export(plot, Point, Pointlist):
 
p2 := Pointlist(
   Point(n, 2 - (-1/2)^n) $ n = 2..20,
   DrawMode=Connected
):
 
plot(p2,
   ViewingBox=[0..20, 1.5..2.25],
   GridLines=Automatic
)
  

Quite often we may need to see what is going on with further terms. For example, here it would be nice to know the behavior of terms with indexes larger than 20. Here is the code showing how to get such graph and, what is the most important, how to get a very high accurate graph.  Here we plot terms 20 - 40.

export(plot, Point, Pointlist):
  
p2 := Pointlist(
   Point(n, 2 - (-1/2)^n) $ n = 20..40,
   DrawMode=Connected
):
 
ty := 1.999999 + i*0.0000002 $ i=0..9:
Ty := [op(ty,i)=expr2text(op(ty,i)) $ i=1..9]:
 
plot(p2,
   ViewingBox=[20..40,  1.999999..2.000001],
   GridLines=Automatic,
   Ticks = [20, Ty]
)
 

 
TOP