Message Boards Message Boards

0
|
2702 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Avoid an element identification problem from a matrix in a "For" loop ?

Posted 6 years ago

Dear Friends,

I am struggling with a minor looking problem and could not figure out a solution. Looking forward for any help. Attached is the *.nb file containing my code. Followings are the important points

  1. In the beginning of the code I have defined a six element table (blue font in *.nb file)

    f[m_] := Table[f[m, n], {n, 1, 6}];
    

and the elements of f[0] are given as follows (magenta color in *.nb file)

f[0, 1] = f[0, 2] = f[0, 3] = f[0, 4] = f[0, 5] = f[0, 6] = 1/6;

2- In the end of the code, there is a "For" loop to determine f[m] for m > 0

Ignoring the other mathematical complexities, for determine each f[m], elements of f[m-1] are required to fed in DSC3[m] (substitutions shown in red color).

3- The loop works fine for first cycle of m = 1 since elements of f[0] are defined initially as f[0, 1]....etc and I get f[1] = {1/3,0,1/6,1/6,1/6,1/6}.

4- Though the second cycle for m = 2 does not work as when I ask (red color in *.nb file)

    {f[m, i] ->   0, f[m, j] ->   f[m - 1, j] + f[m - 1, i], f[m, x_] -> f[m - 1, x]}

Mathematica does not recognize that f[m-1, j] is jth element of f[m-1] and does not take its value from the o/p of m = 1 cycle (f[1]).

In addition, if I try to tell mathematica separately that f[m, n] = f[m][[n]], I get the error message -

$RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of ...

Will be greatful for any suggestion to this problem

thanks

POSTED BY: S G
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract