Message Boards Message Boards

Recursion depth exceeded error when calling Module in Manipulate

Posted 4 months ago

I was trying to create a spring pedulum demonstration when I find the following problem:

enter image description here

POSTED BY: Giovanni Melo
Posted 4 months ago

Your time varies from 0 to 50. You use recursion to evaluate that at every 0.01 time step. That means you may use up to 5000 recursions to calculate each time step. Usually people don't do more than 1000 recursions unless something has gone wrong in their code. That is the reason for the recursion error check in the system.

You can raise that error limit with

$RecursionLimit=6000;

You are also using machine precision floating point values in your calculations and the error may accumulate to the point where you don't get accurate results.

You can replace your decimal approximations with exact rational values, but that will slow your code down.

There may be other problems in your code, but perhaps these will help you make some progress.

POSTED BY: Bill Nelson
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