Hi,

This is a bug in v13.01 (I haven't yet tried 13.02). I'm not sure it's related to the proc or recursion but using "Sum" instead of "add" in this case yields the wrong result. I have used "Sum" in recursive definitions before without a problem but this particular one reveals a bug. Given the recursive function:

rec := proc (F, eta, n, f, j) 
  if j < F-1 then 
    if j < f then 
       Sum(binomial(n, k)*('rec')(F, eta, n-k, f, j+1), k = 0 .. n) 
    else 
       Sum(binomial(n, k)*eta^k*('rec')(F, eta, n-k, f, j+1), k = 0 .. n) 
    end if; 
  else 
    if f < F then eta^n else 1 end if 
  end if 
end proc

The following two executions are equivalent:

evalf(Sum(rec(4, 0.2, 4-u, 4, 1), u = 1 .. 1))

which is equivalent to this:

evalf(rec(4, 0.2, 3, 4, 1))

The problem is that the former yields 22 and the latter 27 ... the latter being correct.

If I replace [Sum] with [add] everywhere (and ['rec'] with [rec] inside the proc) then it works fine. Has anyone experience this kind of behaviour?

Regards


Please Wait...