I have the following code, but I dont know why I could not make it work :S

Please help.

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}]]]

Printable View

- Sep 26th 2008, 03:44 AMbkarpuzMathematica and Sequences
I have the following code, but I dont know why I could not make it work :S

Please help.

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, 03:57 AMshawsend
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, 04:00 AMbkarpuz
- Sep 26th 2008, 04:14 AMbkarpuz
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]

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}]]