Message Boards Message Boards

0
|
3449 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Difficulties implementing recurring formula

Posted 9 years ago

Hi,

I want to construct an algorithm in Mathematica to obtain certain number of othonormal polynomials under specific conditions (using recurring formula). In constructing a definition of my main function I ran into a problem, where it appears that my function goes into a loop of some sort. While debugging I came to this test program which results in the same error:

Test[n1_] := Module[{q},
   q = Table[0, {n1}];
   q[[1]] := 1;
   q[[2]] := q[[1]];
   Print[q];
   ];

Error I get:

$RecursionLimit::reclim: Recursion depth of 1024 exceeded. >>

I obviously don't understand some part of assining values...I'm kind of lost. Any help would be much appriciated.

Thnx.

BR

Natasa

POSTED BY: Natasa T

Use Set rather than SetDelayed for q[[1]] and q[[2]]

Test[n1_] := Module[{q},
   q = Table[0, {n1}];
   q[[1]] = 1;
   q[[2]] = q[[1]];
   q];

Test[4]

{1, 1, 0, 0}

POSTED BY: Robert Hanlon
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