Question: Too many levels of recursion

I have constructed 2 procedures:

f(n) and h(n) which i build inside a double sum but when trying to calculate it says to many levels of recursion.

but when doing a simple example it works.

so the question is basically: why cant one put functions defined by proc within a sum??

f := proc (n) option remember; subs(c = (1+s)/(1-s), q = 2*k^2*s/(1-s)+k*(1+9*s)/(2-2*s)+k^2+2*k, a = k, b = k+1/2, g = 1/2, d = 2*k+3, s = 1/2, k = -1+((1/2)*I)*p, (q+(n-1)*(n-2+g)*(1+c)+(n-1)*(c*d+a+b+1-g-d))*f(n-1)/(c*n*(n-1+g))-(n-2+a)*(n-2+b)*f(n-2)/(c*n*(n-1+g))) end proc;

proc (n) option remember; subs(c = (1+s)/(1-s), q = 2*k^2*s/(1-s)+k*(1+9*s)/(2-2*s)+k^2+2*k, a = k, b = k+1/2, g = 1/2, d = 2*k+3, s = 1/2, k = -1+((1/2)*I)*p, (q+(n-1)*(n-2+g)*(1+c)+(n-1)*(c*d+a+b+1-g-d))*f(n-1)/(c*n*(n-1+g))-(n-2+a)*(n-2+b)*f(n-2)/(c*n*(n-1+g))) end proc

(1)

``

proc (n) option remember; subs(c = (1+s)/(1-s), q = 2*k^2*s/(1-s)+k*(1+9*s)/(2-2*s)+k^2+2*k, a = k, b = k+1/2, g = 1/2, d = 2*k+3, s = 1/2, k = -1+((1/2)*I)*p, (q+(n-1)*(n-2+g)*(1+c)+(n-1)*(c*d+a+b+1-g-d))*f(n-1)/(c*n*(n-1+g))-(n-2+a)*(n-2+b)*f(n-2)/(c*n*(n-1+g))) end proc

(2)

f(-1) := 0

0

(3)

f(0) := 1

1

(4)

h := proc (n) option remember; subs(c = (1+s)/(1-s), q = 2*k^2*s/(1-s)+k*(1+9*s)/(2-2*s)+k^2+2*k, a = k, b = k+1/2, g = 1/2, d = 2*k+3, s = 1/2, k = -1+((1/2)*I)*p, (-q+a*b+(n-1)*(n-2+d)*(2-c)+(n-1)*((1-c)*g+a+b+1-g-d))*h(n-1)/((1-c)*n*(n-1+d))-(n-2+a)*(n-2+b)*h(n-2)/((1-c)*n*(n-1+d))) end proc;

proc (n) option remember; subs(c = (1+s)/(1-s), q = 2*k^2*s/(1-s)+k*(1+9*s)/(2-2*s)+k^2+2*k, a = k, b = k+1/2, g = 1/2, d = 2*k+3, s = 1/2, k = -1+((1/2)*I)*p, (-q+a*b+(n-1)*(n-2+d)*(2-c)+(n-1)*((1-c)*g+a+b+1-g-d))*h(n-1)/((1-c)*n*(n-1+d))-(n-2+a)*(n-2+b)*h(n-2)/((1-c)*n*(n-1+d))) end proc

(5)

h(-1) := 0

0

(6)

h(0) := 1

1

(7)

h(2)

(1/8)*(-3*(-1+((1/2)*I)*p)^2+7/2-((19/4)*I)*p+(-1+((1/2)*I)*p)*(-1/2+((1/2)*I)*p))*(-3*(-1+((1/2)*I)*p)^2+15/2-((15/4)*I)*p+(-1+((1/2)*I)*p)*(-1/2+((1/2)*I)*p))/((2+I*p)*(1+I*p))+(1/4)*(-1+((1/2)*I)*p)*(-1/2+((1/2)*I)*p)/(2+I*p)

(8)

series(subs(c = (1+s)/(1-s), q = 2*k^2*s/(1-s)+k*(1+9*s)/(2*(1-s))+k^2+2*k, a = k, b = k+1/2, g = 1/2, d = 2*k+3, s = 1/2, k = -1+I*p*(1/2), HeunG(1-c, -q+a*b, a, b, d, g, 1-x)), x = 1, 3)

series(1-((1/4)*(-10+(3*I)*p-p^2)/(1+I*p))*(x-1)-((1/32)*(-24+(58*I)*p-p^2+(10*I)*p^3-p^4)/((1+I*p)*(2+I*p)))*(x-1)^2+O((x-1)^3),x = 1,3)

(9)

h(2)+(1/32)*(-24+(58*I)*p-p^2+(10*I)*p^3-p^4)/((1+I*p)*(2+I*p))

(1/8)*(-3*(-1+((1/2)*I)*p)^2+7/2-((19/4)*I)*p+(-1+((1/2)*I)*p)*(-1/2+((1/2)*I)*p))*(-3*(-1+((1/2)*I)*p)^2+15/2-((15/4)*I)*p+(-1+((1/2)*I)*p)*(-1/2+((1/2)*I)*p))/((2+I*p)*(1+I*p))+(1/4)*(-1+((1/2)*I)*p)*(-1/2+((1/2)*I)*p)/(2+I*p)+(1/32)*(-24+(58*I)*p-p^2+(10*I)*p^3-p^4)/((1+I*p)*(2+I*p))

(10)

simplify(%)

0

(11)

series(subs(c = (1+s)/(1-s), q = 2*k^2*s/(1-s)+k*(1+9*s)/(2*(1-s))+k^2+2*k, a = k, b = k+1/2, g = 1/2, d = 2*k+3, s = 1/2, k = -1+I*p*(1/2), HeunG(c, q, a, b, g, d, x)), x = 0, 3)

series(1+(-3+((1/2)*I)*p-(1/2)*p^2)*x+(4/9-((5/4)*I)*p+(11/72)*p^2-((1/4)*I)*p^3+(1/24)*p^4)*x^2+O(x^3),x,3)

(12)

f(2)-4/9+(5/4*I)*p-(11/72)*p^2+(1/4*I)*p^3-(1/24)*p^4

(1/9)*(-9/2+((27/4)*I)*p+3*(-1+((1/2)*I)*p)^2)*(2*(-1+((1/2)*I)*p)^2-5+((5/2)*I)*p)-(1/9)*(-1+((1/2)*I)*p)*(-1/2+((1/2)*I)*p)-4/9+((5/4)*I)*p-(11/72)*p^2+((1/4)*I)*p^3-(1/24)*p^4

(13)

simplify(%)

0

(14)

exp(-(2*ln(2)*I)*k)*(sum(sum((f(n)*h(m-n)+h(n)*f(m-n))*(m-n)*2^(-m+1), n = 0 .. m), m = 1 .. 10))

Error, (in f) too many levels of recursion

 

sum(sum(n+m, n = 0 .. m), m = 0 .. 10)

660

(15)

``

 

Download heun_sequence.mwheun_sequence.mw

Please Wait...