I'm trying to reproduce Buchholz Polynomials in Maple as outlined by J. Sesma and J. Abad in their paper (equation 14).
The definition given above is a recursive one and so is the code I've created in Maple. I run into problems when using the index of the sum() command in the recursive call. The MWE that produces this error is:
P0 := 1:
P := []:
Pz := proc(n, b, z, P, P0)
local exp1, exp2, k;
option trace;
exp1 := (2*k-1)*(2^(2*k)*bernoulli(2*k))/factorial(2*k);
exp2 := (2^(2*k)*bernoulli(2*k))/factorial(2*k);
print(n);
if n <= 0 then
return P0;
else
return [op(P), (z/2)*sum(exp1*thisproc(n-2*k+1,b,z,P,P0),k=1..(n+1)/2) + (b-2)*sum(exp2*thisproc(n-2*k,b,z,P,P0),k=1..n/2)];
end if:
end proc:
Pz(1,b,z,P,P0);
The error I get is:
Error, (in Pz) cannot determine if this expression is true or false: -2*k <= -2
Which I believe suggests the sum() command is not passing the current value of the indexing variable k as the sum() command runs the recursive call.
Based on the definition provided by J. Sesma and J. Abad I would expect that P[1]=z/6.
I don't understand what you are trying to do by having it return a list.
But as far as the use of the index
kgoes, perhaps this is what you're after.