Menu

#3521 simplify_sum(sum(binomial(1,n),n,0,inf)) gives 3 instead of 2

None
closed
nobody
5
2019-10-26
2019-01-22
No

As reported on Ask SageMath and traced back to Maxima:

(%i1) load("simplify_sum");
(%i2) simplify_sum(sum(binomial(1,n),n,0,inf));
(%o2)                                  3

This contradicts reality and Maxima itself:

(%i3) create_list(binomial(1,n), n, [0,1,2,3,4,5,6]);
(%o3)                        [1, 1, 0, 0, 0, 0, 0]

Discussion

  • Robert Dodier

    Robert Dodier - 2019-01-26

    Confirmed with Maxima 5.42.0.

    After load(simplify_sum), I can say verbose_level:2 to get some debugging outputs, which suggests the problem is in to_hypergeometric.

    I tried to trace(to_hypergeometric, to_hypergeometric1) to get some more info, but I haven't been able to figure out what's going on yet.

     
  • Robert Dodier

    Robert Dodier - 2019-01-26

    I am guessing that to_hypergeometric is making a divide and conquer approach around line 758. It appears to me that the summation limits are incorrect in the sense that -min_ni is counted twice. After applying this patch:

    $ diff -u  simplify_sum.mac-original simplify_sum.mac 
    --- simplify_sum.mac-original   2019-01-25 18:05:32.000000000 -0800
    +++ simplify_sum.mac    2019-01-25 18:05:58.000000000 -0800
    @@ -755,7 +755,7 @@
         [use_simpsum:false, use_harmonic:false, use_integral:false,
          use_ratfun:false, use_gosper:false, use_zeilberger:false,
          use_telescoping:false, min_ni: lmin(ni_coeffs)],
    -    apply('sum, [expr, var, lo, -min_ni]) + simplify_sum(apply(sum, [expr, var, -min_ni, hi])))
    +    apply('sum, [expr, var, lo, -min_ni - 1]) + simplify_sum(apply(sum, [expr, var, -min_ni, hi])))
       else to_hypergeometric1(expr, var, lo, hi))$
    

    I get the expected result (namely 2).

    Running batch(rtest_simplify_sum, test) yields one error, problem 57, which is listed as an expected error in share/share_testsuite.lisp, so this patch doesn't introduce any new errors.

    I guess that the change could be made to either the first or second term in line 758. I changed the first term. If the second is changed, -min_ni would be changed to -min_ni + 1. I didn't try that. I don't know if there's reason to favor one or the other.

     
  • Ricardo Buring

    Ricardo Buring - 2019-03-26

    Thanks Robert! Looks like you found the source and a fix.

    I don't know if it matters much which term is changed. Maybe at least a comment could be added to indicate explicitly that a choice has been made.

    It would be good to have this fix committed; then both this ticket and the SageMath ticket downstream can be closed (as soon as Sage's Maxima is updated).

     
  • Ricardo Buring

    Ricardo Buring - 2019-07-10

    Can the one-line fix be commited?

     
  • Robert Dodier

    Robert Dodier - 2019-10-26
    • status: open --> closed
     
  • Robert Dodier

    Robert Dodier - 2019-10-26

    Fixed by commit 0e34c4b, closing this report.

     

Log in to post a comment.