# How do assign an interval of values to a variable in order to use them in a function?

From my code (below) I have K1 and K2 set to zero in order to test this numerical method. However, K1 is on an interval from 0 to 32, and K2 is on an interval from 0 to 8. I would like to know if there is a way to set these intervals to the associated variables, so that it will run the program for the interval itself. That way I don't have to run a combination of 32 or 8 separate calculations, etc.

Here is my code pasted directly from the nb.

Subscript[x, 0] := 0; Subscript[y, 0] := 1;
Subscript[u, 3] := 0; h := 0.1;
Subscript[K, 1] := 0; Subscript[K, 2] := 0
x[n_] := (Subscript[x, n] = Subscript[x, 0] + n h);
y[n_] := (Subscript[y, n ] = Subscript[y, 0] + n h);
Table[x[n], {n, 0, 5}];
Table[y[n], {n, 0, 5}]

f[n_] := (Subscript[f,
n] = -Subscript[K, 1] Subscript[x,
n] + -Subscript[K, 2] Subscript[y, n]);
Table[f[n], {n, 0, 5}]

System = {Subscript[u,
0] == {1/
80 (-27 h Subscript[f, 0] - 102 h Subscript[f, 1] -
72 h Subscript[f, 2] - 42 h Subscript[f, 3] +
3 h Subscript[f, 4] + 80 Subscript[u, 3])},
Subscript[u,
1] == {1/
90 (h Subscript[f, 0] - 34 h Subscript[f, 1] -
114 h Subscript[f, 2] - 34 h Subscript[f, 3] +
h Subscript[f, 4] + 90 Subscript[u, 3])},
Subscript[u,
2] == {1/
720 (-11 h Subscript[f, 0] + 74 h Subscript[f, 1] -
456 h Subscript[f, 2] - 346 h Subscript[f, 3] +
19 h Subscript[f, 4] + 720 Subscript[u, 3])},
Subscript[u,
4] == {1/
720 (-19 h Subscript[f, 0] + 106 h Subscript[f, 1] -
264 h Subscript[f, 2] + 646 h Subscript[f, 3] +
251 h Subscript[f, 4] + 720 Subscript[u, 3])},
Subscript[u,
5] == {1/
90 (29 h Subscript[f, 0] - 146 h Subscript[f, 1] +
294 h Subscript[f, 2] - 266 h Subscript[f, 3] +
269 h Subscript[f, 4] + 90 Subscript[u, 3])}};

variables = {Subscript[u, 0], Subscript[u, 1], Subscript[u, 2],
Subscript[u, 4], Subscript[u, 5]};

Solve[System, variables]

• Welcome, user. People here greatly prefer that you include copyable code in your question rather than an image of a Notebook. I can tell you from much observation that you are far more likely to receive good answers if you do. Apr 11, 2014 at 1:00
• Attempting to revise my code via code blocks, messes with the way it looks. Unless it is displayed differently after posting? Apr 11, 2014 at 1:09
• post your code without code blocks and I shall try to edit it as I hope is appropriate. If it is correct you can then view the post by clicking edit to see how it was done. Apr 11, 2014 at 1:13
• I posted the code directly from nb. Thank you. Apr 11, 2014 at 1:16
• Thank you for responding to my request. I formatted your code but it doesn't look too good due to the heavy use of Subscript. It will however copy and paste correctly. Apr 11, 2014 at 1:20

Subscript[K, 1] := Interval[{0, 32}];
Subscript[K, 2] := Interval[{0, 8}];

Produces this result:

{Subscript[u, 0] -> Interval[{-0.09, 4.29}],
Subscript[u, 1] -> Interval[{-0.0355556, 3.23556}],
Subscript[u, 2] -> Interval[{-0.186667, 1.98667}],
Subscript[u, 4] -> Interval[{-2.80778, 0.607778}],
Subscript[u, 5] -> Interval[{-12.6578, 7.85778}]}

Does this agree with your expectation?

• I just tried that method a few moments ago and received the same results. It would seem we are in concurrence. The results are expected, now its just a process of analyzing them. Thank you very much for your help. Apr 11, 2014 at 1:30