Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.7K Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

unintended recursion

Posted 10 years ago

/Users/bruceackerson/Desktop/UpdateVariable.tiff

I understand getting recursion when the Vx variable is on the rhs and lhs. But what do I do, for the recursion in the image?

In case the image doesn't show

Clear[S1, Vx, [Delta], [CapitalSigma]yyMinusP];

S1 = Vx[i1, j1];

Vx[i1, j1] = S1 + [Delta]/2 + [CapitalSigma]yyMinusP/2;

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

POSTED BY: Bruce Ackerson
5 Replies

Thanks, I thought I was losing my mind.

POSTED BY: Bruce Ackerson
POSTED BY: Sean Clarke

Has something changed in Mathematica? I looked back at older programs.

S[i] = S[i] + 1

Updated S[i] without recursion. Now it does, even inside a For loop. If I can't do this without recursion, how does one update a variable to plug back into a function?

POSTED BY: Bruce Ackerson

The definition of S1 depends on Vx[i1, j1] and the definition of Vx[i1, j1] depends on S.

A simplified example would be:

a = b
b = a + 2

This is how the evaluator thinks about this.

a = b
(* Every instance of the symbol a will now be replaced by the symbol b *)

b = a + 2
(* Oh look! It's the symbol a. Better replace it with b *)

b = b + 2
( * All instances of b should be replaced with b + 2 *)

(* Oh look! it's the symbol b. Better replace it with b+2 *)
b = b + 2 + 2

(* Oh look! it's the symbol b. Better replace it with b+2 *)
b = b + 2 + 2 + 2

(* Oh look! it's the symbol b. Better replace it with b+2 *)
b = b + 2 + 2 + 2 + 2

.....
POSTED BY: Sean Clarke

As you have it written, S1 needs Vx, which, in turn needs S1, etc. Thus an endless loop. You might try indexing the variables S[i], Vx[i,j], which would enable finite loops.

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