Menu ▾ ▴

#2277 nusum: evaluation error ignored => incorrect result

open
nobody
Lisp Core (456)
5
2012-11-18
2011-09-24
No

From the mailing list: "unexpected behavior of simplify_sum"

On 09/09/2011 01:25 PM, Andrej Vodopivec wrote:

This is a bug in nusum.

(%i2) nusum(F(d,1,1,1,1,b2,l2), l2, 0, b2);
(%o2) 0

Basically, what nusum does is

(%i3) load(zeilberger)$
(%i4) ad: AntiDifference(F(d,1,1,1,1,b2,l2), l2)$
(%i5) subst(l2=b2+1, ad) - subst(l2=0, ad)$
factorial: factorial of negative integer -1 not defined.
-- an error. To debug this try: debugmode(true);

The error comes from the upper bound.

(%i6) subst(l2=b2+1, ad);
factorial: factorial of negative integer -1 not defined.
-- an error. To debug this try: debugmode(true);

My guess is that nusum does not handle this error and just returns the
substitution of the lower bound

(%i7) subst(l2=0, ad);
(%o7) 0

You could disable the nusum computation with use_gosper=false, but
then simplify_sum fails to compute the sum:

(%i12) simplify_sum(%), use_gosper=false;
Is b2-1 positive, negative, or zero? pos;
Is d-2 positive, negative, or zero? pos;
Is d-1 positive, negative, or zero? pos;
Is d+b2-1 positive, negative, or zero? pos;
expt: undefined: 0 to a negative exponent.
(%o12) sum(((-1)^l2*(l2+d-1)!*(l2+d+b2-2)!)/((b2-l2)!*l2!*(l2+d-2)!*(l2+d+1)!),l2,0,b2)

On 08/24/2011 03:57 PM, andre maute wrote:

Hi,

I have the following test, with a sum depending on b2.
For general b2 simplify_sum gives an incorrect value.

Andre

------- test-simplify_sum-1.max -----------

display2d : false;

F(d,a1,k1,a2,k2,b2,l2) := block(

[res:1],

res : res/(b2-l2)!,
res : res/l2!,
res : res*(-1)^l2,

res : res*(b2+l2+d-2)!,
res : res/(l2+d-2)!,

res : res*(k2+l2+d-2)!,
res : res/(k2+l2+d-1+k1)!,

return(res)

);

load("simplify_sum");

s:sum(F(d,1,1,1,1,b2,l2),l2,0,b2);
h : simplify_sum(s);
h : factor(minfactorial(h));

s:sum(F(d,1,1,1,1,2,l2),l2,0,2);
h : simplify_sum(s);
h : factor(minfactorial(h));

------- test-simplify_sum-1.max -----------

------- test-simplify_sum-1.txt -----------

Maxima 5.19.2 http://maxima.sourceforge.net
Using Lisp SBCL 1.0.40-1.fc14
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) batch(test-simplify_sum-1.max)

batching /home/user/progs/test-simplify_sum-1.max
(%i2) display2d : false
(%o2) false
(%i3) F(d,a1,k1,a2,k2,b2,l2):=block([res:1],res:res/(b2-l2)!,res:res/l2!,
res:res*(-1)^l2,res:res*(-2+d+l2+b2)!,res:res/(-2+d+l2)!,
res:res*(-2+d+l2+k2)!,res:res/(k1-1+d+l2+k2)!,return(res))
(%o3) F(d,a1,k1,a2,k2,b2,l2):=block([res:1],res:res/(b2-l2)!,res:res/l2!,
res:res*(-1)^l2,res:res*(-2+d+l2+b2)!,res:res/(-2+d+l2)!,
res:res*(-2+d+l2+k2)!,res:res/(k1-1+d+l2+k2)!,return(res))
(%i4) load("simplify_sum")
(%o4) "/home/user/opt/maxima/share/maxima/5.19.2/share/contrib/solve_rec/simplify_sum.mac"
(%i5) s:sum(F(d,1,1,1,1,b2,l2),l2,0,b2)
(%o5) 'sum((-1)^l2*(l2+d-1)!*(l2+d+b2-2)!/((b2-l2)!*l2!*(l2+d-2)!*(l2+d+1)!),
l2,0,b2)
(%i6) h:simplify_sum(s)
(%o6) 0
(%i7) h:factor(minfactorial(h))
(%o7) 0
(%i8) s:sum(F(d,1,1,1,1,2,l2),l2,0,2)
(%o8) (d+1)!*(d+2)!/(2*d!*(d+3)!)-d!*(d+1)!/((d-1)!*(d+2)!)
+(d-1)!*d!/(2*(d-2)!*(d+1)!)
(%i9) h:simplify_sum(s)
(%o9) (d+1)!*(d+2)!/(2*d!*(d+3)!)-d!*(d+1)!/((d-1)!*(d+2)!)
+(d-1)!*d!/(2*(d-2)!*(d+1)!)
(%i10) h:factor(minfactorial(h))
(%o10) -2/((d+1)*(d+2)*(d+3))
(%o10) "/home/user/progs/test-simplify_sum-1.max"

------- test-simplify_sum-1.txt -----------

Discussion


Log in to post a comment.