# Mathematica and Sequences

• Sep 26th 2008, 04:44 AM
bkarpuz
Mathematica and Sequences
I have the following code, but I dont know why I could not make it work :S
Code:

```x = Table[1, {i, 1, 15}]; For[i = 3, i < 15, i++,  x[i + 1] = 16/9*x[i] - 2/3*x[i - 1] - 1/3*x[i - 2]  ] Graphics[Point[Table[{i, x[i]}, {i, 1, 15}]]]```
• Sep 26th 2008, 04:57 AM
shawsend
Need double brackets in an array : x[[i]]. The syntax x[i] is interpreted as the function x at the value i.
• Sep 26th 2008, 05:00 AM
bkarpuz
Quote:

Originally Posted by shawsend
Need double brackets in an array : x[[i]]. The syntax x[i] is interpreted as the function x at the value i.

Code:

```s = 12; x = Table[1, {i, 1, s}]; For[i = 3, i <= s - 1, i++,  x[[i + 1]] = 16/9*x[[i]] - 2/3*x[[i - 1]] - 1/3*x[[i - 2]];  ] Graphics[Point[Table[{i, x[[i]]}, {i, 1, s, 1}]]]```
• Sep 26th 2008, 05:14 AM
bkarpuz
I again have problems about scaling the graphic :S

Code:

```s = 50; x = Table[1, {i, 1, s}]; xmin := 1; xmax := 1; For[i = 3, i <= s - 1, i++,  c = 16/9*x[[i]] - 2/3*x[[i - 1]] - 1/3*x[[i - 2]];  x[[i + 1]] := c;  xmin = If[c < xmin, c, xmin];   xmax = If[c > xmax, c, xmax];  ] Graphics[Point[Table[{i, x[[i]]}, {i, 1, s, 1}]], Axes -> True]```
I found out that the following code is more useful:
Code:

```s = 50; x = Table[1, {i, 1, s}]; For[i = 3, i <= s - 1, i++, x[[i + 1]] = 16/9*x[[i]] - 2/3*x[[i - 1]] - 1/3*x[[i - 2]] ] ListPlot[Table[{i, x[[i]]}, {i, 1, s}]]```