## How to write proc to find factorial n?...

How to write procedure to find factorial n? Induction to be used.

## Strange Behavior - Bug?...

This is reduced from another forum.

restart;
e1 := 12*g^2+12*h^2+4*i^2+3*j^2=684;
e2 :=  12*l^2+12*m^2+4*n^2+3*o^2=684;
e3 := 12*q^2+12*r^2+4*s^2+3*t^2=172;
e4 := 12*v^2+12*w^2+4*x^2+3*y^2=108;
e5 := 12*g*l+12*h*m+4*n*i+3*j*o=-84;
e6 := 12*g*q+12*h*r+4*s*i+3*j*t=-84;
e7 := 12*g*v+12*h*w+4*x*i+3*j*y=-84;
e8 := 12*l*q+12*m*r+4*n*s+3*o*t=-84;
e9 := 12*l*v+12*m*w+4*n*x+3*o*y=-84;
e10 := 12*q*v+12*r*w+4*s*x+3*y*t=-84;
e11 := g+h+i+j=-1;
e12 := l+m+n+o=-1;
e13 := q+r+s+t=-1;
e14 := v+w+x+y=-1;
e15 := h*i+m*n+3*s*r+4*x*w=-21;
e16 := g*i+l*n+3*s*q+4*x*v=-21;
e17 := i+n+3*s+4*x=-3;
e18 := g*h+m*l+3*q*r+4*w*v=-7;
e19 := h+m+3*r+4*w=-1;
e20 := g+l+3*q+4*v=-1;
e21 := i*j+o*n+3*s*t+4*x*y=-84;
e22 := j*h+o*m+3*r*t+4*y*w=-28;
e23 := j*g+o*l+3*q*t+4*y*v=-28;
e24 := j+o+3*t+4*y=-4;
e25 := j^2+o^2+3*t^2+4*y^2=144;
e26 := i^2+n^2+3*s^2+4*x^2=129;
e27 := h^2+m^2+3*r^2+4*w^2=57;
e28 := g^2+l^2+3*q^2+4*r^2=57;

eqset := {e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15,
e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28};
for s in eqset do print(s) end do;

Error, too many levels of recursion

If I then do

S := {1,2,3,6,3,6,8,2,3,6};

for s in S do print(s) end do;

Then,

for s in eqset do print(s) end do;

has the correct output.

What am I doing wrong?

Tom Dean

## How do I generate the recursion...

Please Sir/Ma, I'm trying to generate a recurrent relations of this series and I try to use "if" "else" condition but I didn't get it right. Any one with useful suggestions. Appreciate

restart;
Y[0] := A; Y[1] := B;
if k = a then delta(k-a) := 1 else 0 end if;
0
for k from 0 to 10 do Y[k+2] := solve(add(delta(i-1)*(k-i+1)*(k-i+2)*Y[k-i+2], i = 0 .. k)+add((delta(i)-delta(i-1))*(k-i+1)*Y[k-i+1], i = 0 .. k)+lambda*Y[k] = 0, Y[k+2]) end do;
y := sum(Y[j]*x^j, j = 0 .. 10);

## too many levels of recursion...

I copy a program from a book and try to run it, but when i try to run it return:

too many levels of recursion

Here is my program:

Hope every one can help me solve this problem. Thank!

## Error, too many levels of recursion...

In Maple V, Release 4 (1996):

 T:=table():i:=1:N:=5000;for i from i to N  do   T[i]:=T[i+1]:   T[i+1]:=1;   eval(T[1]);od:print(i);for i from i to N  do   T[i]:=T[i+1]:   T[i+1]:=1;   eval(T[1]);od:print(i);

N := 5000
Error, too many levels of recursion
3607
5001

Can You explain this occurence, as well as the following one:

In Maple V, Release 4 (1996):

 T:=table():i:=1:N:=5000;for i from i to N  do  T[i]:=T[i+1]:  eval(T[1]);od:print(i); for i from i to N  do  T[i]:=T[i+1]:  eval(T[1]);od:print(i);;

gives:

N := 5000
Error, too many levels of recursion
3607
Error, too many levels of recursion
3607

How does one control allowance for recursion depth?

## Recursive procedure of piecewise ...

Hi, I'm new to Maple and I have to produce a recursive procedure with the nomenclature Puis:=proc(X,n::integer) which calculates X^n with:

for n<0   ->   1/(X^(-n))

for n=0  ->   1

for n being an even integer   ->   X^(n/2) * X^(n/2)

for n being an odd integer   ->   X*X^(n-1)

The procedure I produced is:

Puis:=proc(X,n::integer)
option remember;
if n<0 then Puis(X,-n);
elif n=0 then 1;
elif rem(n,2,x)=0 then Puis(X,n);
else X*Puis(X,n-1);
end if;
end proc;

i don't have any eror up to this point, but when I try to evaluate, only Puis(4,0) works

Puis(4,-1);
Error, (in content) too many levels of recursion
Puis(4,0);
1
Puis(4,3);
Error, (in content) too many levels of recursion
Puis(4,4);
Error, (in content) too many levels of recursion

I was wondering what was wrong with my procedure, I changed the 1/(X^(-n)) with X^n and X^(n/2)*X^(n/2) for X^n because it is equivalent. I think I should put some sort of initial value to limit the recursion, but with that kind of function i really don't know how. I also tried with the X^(n/2)*X^(n/2) for the even numbers, but it says Puis expects its 2nd argument, n, to be of type integer, but received 1/2.

## How to solve that recursion?...

Given the sequence defined by the recursive relation a[n+1] = r*a[n](1-a[n])
You need to use the procedure iterate.
Throughout this problem you should choose initial values in the interval 0<a0<1.
(a) Let r=3/2. Calculate a moderate number of terms in the sequence (between 10 and 20). Does the sequence appear to be converging? If so to what value? Does the limit depend upon your choice of initial value? Plot the terms you have calculated
(b) Let r=2.8. Calculate a moderate number of terms in the sequence (between 10 and 20). Does the sequence appear to be converging? If so to what value? Does the limit
depend upon your choice of initial value? Plot the terms you have calculated How does this sequence differ from that in part (a).
(c) Let r=3.2. Calculate a moderate number of terms in the sequence (between 10 and 20). Show that the sequence does not appear to converging. Plot the terms you have calculated and describe how the sequence behaves in this case.
(d) Consider intermediate values between 2.8 and 3.2 to determine more precisely where the transition in behaviour takes place. Provide a few plots (no more than 4) showing the values you have investigated.
(e) Consider the values of r in the range 3.43<r<3.46. Determine as accurately as you can the value of r for which the period of oscillation doubles.
(f) As r increase further period doubling occurs. Try to find the when the sequence appears to oscillate between 8 values.
(g) Let r =3.65 and calculate a considerable number of terms (at least a few hundred) and plot your values.
(h) For r=3.65 choose a0=0.3 and then a0=0.301. Find and plot some terms in the sequence for each initial value. Determine how long the terms in the two sequences remain close together and when they begin to depart significantly from each other.

## Too many levels of recursion...

Hello,
I have defined a function f (x, e, y).  I give values of n: = i * h as follows:

f (x (n), w (n), t) = w * t * x;
n: = i * h;
r (n) = n;
Then I need to do this operation:
w (n) = w (n) + r (n);

w(n):=15; r(n):=30;

w(n):=w(n)+r(n);

w(n);
Error, (in w) too many levels of recursion.

How i can operate?.

Regards.

## error in simplify...

> coth;
coth
> restart;
> c := 0;
0
> w := -2*mu;
-2 mu
> a[-1] := 0;
0
> a[0] := mu*lambda*sqrt(-6*a);
(1/2)
mu lambda (-6 a)
> a[1] := (6*(mu*lambda^2+1))/sqrt(-6*a);
/         2    \
6 \mu lambda  + 1/
------------------
(1/2)
(-6 a)
> b[-1] := 0;
0
> b[0] := 0;
0
> b[1] := 0;
0
> xi := x+w*t;
x - 2 mu t
> P := sqrt(-mu)*coth(A+sqrt(-mu)*xi);
(1/2)     /         (1/2)             \
(-mu)      coth\A + (-mu)      (x - 2 mu t)/
> u := a[0]+a[1]*P/(1+lambda*P)+a[-1]*(1+lambda*P)/P+b[0]*sqrt(sigma*(1+P^2/mu))/P+b[1]*sqrt(sigma*(1+P^2/mu))+b[-1]*sqrt(sigma*(1+P^2/mu))/P^2;
(1/2)
mu lambda (-6 a)

/         2    \      (1/2)     /         (1/2)             \
6 \mu lambda  + 1/ (-mu)      coth\A + (-mu)      (x - 2 mu t)/
+ ---------------------------------------------------------------------
(1/2) /                (1/2)     /         (1/2)             \\
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)//
> Diff(u, t)+a*u^2*(Diff(u, x))+Diff(u, \$(x, 3));
/    /
| d  |                (1/2)
|--- |mu lambda (-6 a)
| dt |
\    \

/         2    \      (1/2)     /         (1/2)             \   \\     /
6 \mu lambda  + 1/ (-mu)      coth\A + (-mu)      (x - 2 mu t)/   ||     |
+ ---------------------------------------------------------------------|| + a |mu lambda
(1/2) /                (1/2)     /         (1/2)             \\||     |
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)////     \

(1/2)
(-6 a)

/         2    \      (1/2)     /         (1/2)             \   \
6 \mu lambda  + 1/ (-mu)      coth\A + (-mu)      (x - 2 mu t)/   |
+ ---------------------------------------------------------------------|^2
(1/2) /                (1/2)     /         (1/2)             \\|
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)///

/    /
| d  |                (1/2)
|--- |mu lambda (-6 a)
| dx |
\    \

/         2    \      (1/2)     /         (1/2)             \   \\
6 \mu lambda  + 1/ (-mu)      coth\A + (-mu)      (x - 2 mu t)/   ||
+ ---------------------------------------------------------------------|| +
(1/2) /                (1/2)     /         (1/2)             \\||
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)////

/ 3 /
|d  |                (1/2)
|-- |mu lambda (-6 a)
|   |
\   \

/         2    \      (1/2)     /         (1/2)             \   \\
6 \mu lambda  + 1/ (-mu)      coth\A + (-mu)      (x - 2 mu t)/   ||
+ ---------------------------------------------------------------------||
(1/2) /                (1/2)     /         (1/2)             \\||
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)////
> value(%);
/                                     2\
/         2    \   2 |        /         (1/2)             \ |
12 \mu lambda  + 1/ mu  \1 - coth\A + (-mu)      (x - 2 mu t)/ /
--------------------------------------------------------------------- -
(1/2) /                (1/2)     /         (1/2)             \\
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)//

/
1                                    |
---------------------------------------------------------------------- \12
2
(1/2) /                (1/2)     /         (1/2)             \\
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)//

/
/         2    \      (1/2)     /         (1/2)             \          2 |
\mu lambda  + 1/ (-mu)      coth\A + (-mu)      (x - 2 mu t)/ lambda mu  \1

2\\     /
/         (1/2)             \ ||     |                (1/2)
- coth\A + (-mu)      (x - 2 mu t)/ // + a |mu lambda (-6 a)
|
\

/         2    \      (1/2)     /         (1/2)             \   \
6 \mu lambda  + 1/ (-mu)      coth\A + (-mu)      (x - 2 mu t)/   |
+ ---------------------------------------------------------------------|^2
(1/2) /                (1/2)     /         (1/2)             \\|
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)///

/                           /                                     2\
|       /         2    \    |        /         (1/2)             \ |
|     6 \mu lambda  + 1/ mu \1 - coth\A + (-mu)      (x - 2 mu t)/ /
|- --------------------------------------------------------------------- +
|        (1/2) /                (1/2)     /         (1/2)             \\
|  (-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)//
\

/
1                                    |  /
---------------------------------------------------------------------- \6 \mu
2
(1/2) /                (1/2)     /         (1/2)             \\
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)//

/
2    \      (1/2)     /         (1/2)             \           |
lambda  + 1/ (-mu)      coth\A + (-mu)      (x - 2 mu t)/ lambda mu \1

\
2\\|
/         (1/2)             \ |||
- coth\A + (-mu)      (x - 2 mu t)/ //|
|
|
/

2
/                                     2\
/         2    \   2 |        /         (1/2)             \ |
12 \mu lambda  + 1/ mu  \1 - coth\A + (-mu)      (x - 2 mu t)/ /
- --------------------------------------------------------------------- +
(1/2) /                (1/2)     /         (1/2)             \\
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)//

/
1                                   |   /
--------------------------------------------------------------------- \24 \mu
(1/2) /                (1/2)     /         (1/2)             \\
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)//

2 /
2    \   2     /         (1/2)             \  |
lambda  + 1/ mu  coth\A + (-mu)      (x - 2 mu t)/  \1

2\\
/         (1/2)             \ ||
- coth\A + (-mu)      (x - 2 mu t)/ // +

/
|
1                                    |
---------------------------------------------------------------------- \84
2
(1/2) /                (1/2)     /         (1/2)             \\
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)//

/         2    \   2     /         (1/2)             \
\mu lambda  + 1/ mu  coth\A + (-mu)      (x - 2 mu t)/

2                  \
/                                     2\                   |
|        /         (1/2)             \ |       (1/2)       |
\1 - coth\A + (-mu)      (x - 2 mu t)/ /  (-mu)      lambda/

3
/                                     2\
/         2    \   3 |        /         (1/2)             \ |        2
36 \mu lambda  + 1/ mu  \1 - coth\A + (-mu)      (x - 2 mu t)/ /  lambda
- ------------------------------------------------------------------------- +
3
(1/2) /                (1/2)     /         (1/2)             \\
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)//

/
|
1                                    |
---------------------------------------------------------------------- \36
4
(1/2) /                (1/2)     /         (1/2)             \\
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)//

/         2    \      (1/2)     /         (1/2)             \       3   3
\mu lambda  + 1/ (-mu)      coth\A + (-mu)      (x - 2 mu t)/ lambda  mu

3\
/                                     2\ |
|        /         (1/2)             \ | |
\1 - coth\A + (-mu)      (x - 2 mu t)/ / / +

/
|
1                                    |
---------------------------------------------------------------------- \72
3
(1/2) /                (1/2)     /         (1/2)             \\
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)//

2
/         2    \   3     /         (1/2)             \        2
\mu lambda  + 1/ mu  coth\A + (-mu)      (x - 2 mu t)/  lambda

2\
/                                     2\ |
|        /         (1/2)             \ | |
\1 - coth\A + (-mu)      (x - 2 mu t)/ / / -

/
1                                    |
---------------------------------------------------------------------- \24
2
(1/2) /                (1/2)     /         (1/2)             \\
(-6 a)      \1 + lambda (-mu)      coth\A + (-mu)      (x - 2 mu t)//

3        /
/         2    \   2     /         (1/2)             \         |
\mu lambda  + 1/ mu  coth\A + (-mu)      (x - 2 mu t)/  lambda \1

2\           \
/         (1/2)             \ |      (1/2)|
- coth\A + (-mu)      (x - 2 mu t)/ / (-mu)     /
> simplify(%);
Error, (in simplify/tools/_zn) too many levels of recursion
>
>
>
>
pls help

## How to remove the too many levels of recursion err...

for a to z1/T1 do ics[a*T1] := [g0(0, a*T1) = r, g0(1, a*T1) = s] end, this loop runs correctly for T1:=1, but gives the too many levels of recursion error for T1<1. In this loop i am inserting equations g0 in a list ics.

## Which is the max level of recursion, and can it be...

During a lengthy computation of mine - done using a well established and scientifically sensible external package - I get a Too many level of recursion error in PDEtools/NumerDenom.

Since it has always worked fine for simpler computation with the exact same code, I am wondering whether, with a bigger bound of the level of recursion, the computation could be succesful.

Which is the max level of recursion than maple allows?

Is it possibile to manually (at one's own risk) raise it, in the same line as raising, for instance, stacklimits kernel option?

## Recursive definition of a function using a differe...

I have a nice family of functions of the form:

W:=(p,n,mu,w)->sum(w[k] * (n-k)* mu(n-k),k=1..n)

which can be evaluated for different p's using the operator mu*diff(...,mu)

The recursion begins with p=0 and proceeds using mu*diff(W(p,n,mu,w),mu) = W(p+1,n,mu,w).

Can anybody implement this procedure in Maple

Thank you

## Why "too many levels of recursion..."??...

I am a new user of Maple (Dec 2014).  I am trying to calculate an integral related

to mechanical loss.  Temperature is a variable in the problem (as is time), and if

I use a sinusoidal (sine or cosine) temperature-time relationship, I think all works fine.

A difficulty is that the experiments have two-hour hold times(i.e., 7200 seconds) (followed by 22 hours of sinusoidal temperature variation.)

The experiments run for several weeks or months.

I tried using Heaviside functions to model the hold times.(Constant temperature periods)

Now I am receiving errors such as " Error, (in tools/eval_foo/do) too many levels of recursion..."

Probably the Maple code is crude and/or sloppy. Most of the code is simply the setting of constants in the problem.

I will be grateful for suggestions and comments--the file is attached.  Thank you.  John B

 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 > (temperature cycle repeats every 24 hours = 86,400 seconds)
 >
 >
 >
 >
 >
 >
 >
 >
 >
 (1)
 >
 >
 >
 >
 >
 >

## Defining Some Functions by Recursion...

I am trying to define some functions by recursion relations but I get this error:

Error, (in type/realcons) too many levels of recursion

Please see the attached file for details:

File.mw

## QM perturbation theory: too many levels of recursi...

Hello everyone,

I've been trying to do some perturbation theory and ran into some problems I don't quite understand. I implemented the Hamiltonian of the Bose-Hubbard model and treated the hopping as a perturbation. Calculating the second order energy shift is easily accomplished, but when I'm only interested in one of the two occuring terms, I run into problems. The calculation takes minutes to finally fail, giving me an "too many levels of recursion"-error. I need to be able to just pick a few terms for some calculations, I'm doing, and can't figure out what I might be doing wrong. Here is the source code (download is below):

 >
 >
 >
 (1)
 >
 >
 (2)
 >
 >