rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

incorrect result for simplify_sum applied to binomials #2876

Open rtoy opened 2 months ago

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:13:28 Created by zmth on 2021-09-17 03:24:41 Original: https://sourceforge.net/p/maxima/bugs/3856


(assume_pos:true,
load(simplify_sum),
simpsum:true,
load("lrats"),
letrat:true,
ratfac:true,
algebraic:true );   

(declare([n,p],integer),
assume(n>=p,p>0),
t:simplify_sum(sum(binomial(2*n+1,2*p+2*k+1)*binomial(p+k,k),k,0,max(0,n-p))));

gives error "lower bound 0 greater than upper bound -p" which it should NOT because upper bound is also 0 .

Anyway though if leave off the -p it's ok except it gives answer in an inconvenient form of negative factorials and is also WRONG ans. for when n=p=1 the sum is 1 but maxima's answer is 0.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:13:29 Created by robert_dodier on 2021-09-17 04:55:47 Original: https://sourceforge.net/p/maxima/bugs/3856/#8415


Dan, I don't see a bug here. When I try the input shown above, I get back the same summation, unchanged except max(0, n-p) is replaced by n - p, which is okay, although it is a little disappointing that simplify_sum couldn't find a solution.

What is the output you are getting? Also, what does build_info(); report?

Enabling the (admittedly obscure) flag for debugging simplify_sum, verbose_level: 2, seems to indicate the message about "lower bound greater than upper bound" comes from the code for simpsum, which is an older part of the summation code, separate from simplify_sum. I'm not sure whether that message represents an error or not.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:13:33 Created by macrakis on 2021-09-17 16:10:53 Original: https://sourceforge.net/p/maxima/bugs/3856/#1e2f


Since the code declares p>0, it is true that 0>-p.

As for the inconvenient form with negative factorials, as I mentioned in another comment, unfortunately Maxima doesn't have very good methods for simplifying expressions with factorials.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:13:36 Created by zmth on 2021-09-29 21:27:21 Original: https://sourceforge.net/p/maxima/bugs/3856/#8415/ac22


also if i just take lower limit 0 and upper limit 0 it gives the wrong ans. as i explained. The correct ans. is 1 while the maxima ans. is 0 since maxima output is a factorial of a negative integer in the denom. and NOT one in the num.{all other terms are finite} is equal to 0 On Thursday, September 16, 2021, 11:55:55 PM CDT, Robert Dodier via Maxima-bugs maxima-bugs@lists.sourceforge.net wrote:

Dan, I don't see a bug here. When I try the input shown above, I get back the same summation, unchanged except max(0, n-p) is replaced by n - p, which is okay, although it is a little disappointing that simplify_sum couldn't find a solution.

What is the output you are getting? Also, what does build_info(); report?

Enabling the (admittedly obscure) flag for debugging simplify_sum, verbose_level: 2, seems to indicate the message about "lower bound greater than upper bound" comes from the code for simpsum, which is an older part of the summation code, separate from simplify_sum. I'm not sure whether that message represents an error or not.

[bugs:#3856] incorrect result for simplify_sum applied to binomials

Status: open Group: None Labels: sum simplify_sum Created: Fri Sep 17, 2021 03:24 AM UTC by dan hayes Last Updated: Fri Sep 17, 2021 04:49 AM UTC Owner: nobody (assume_pos:true, load(simplify_sum), simpsum:true, load("lrats"), letrat:true, ratfac:true, algebraic:true );

(declare([n,p],integer), assume(n>=p,p>0), t:simplify_sum(sum(binomial(2n+1,2p+2k+1)binomial(p+k,k),k,0,max(0,n-p))));

gives error "lower bound 0 greater than upper bound -p" which it should NOT because upper bound is also 0 .

Anyway though if leave off the -p it's ok except it gives answer in an inconvenient form of negative factorials and is also WRONG ans. for when n=p=1 the sum is 1 but maxima's answer is 0.

Sent from sourceforge.net because maxima-bugs@lists.sourceforge.net is subscribed to https://sourceforge.net/p/maxima/bugs/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/maxima/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.


Maxima-bugs mailing list Maxima-bugs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/maxima-bugs

Attachments:

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:13:40 Created by zmth on 2021-09-29 21:37:54 Original: https://sourceforge.net/p/maxima/bugs/3856/#8415/c122


lower limit is 0 and obviously upper limit is 0 so it is a bogus message to say lower limit is greater than upper because it is NOT. If it replaces max(0,n-p) by n-p that is obviously wrong if n-p is negativeso that is NOT ok.Besides that it gives wrong answer to simplify_sum...even when that is not the issue. build_info(version="branch_5_44_base_231_g5c411f69f",timestamp="2021-01-12 23:51:42",host="x86_64-w64-mingw32",lisp_name="SBCL",lisp_version="2.0.0",maxima_userdir="C:/Users/zmth1/maxima",maxima_tempdir="C:/Users/zmth1/AppData/Local/Temp",maxima_objdir="C:/Users/zmth1/maxima/binary/branch_5_44_base_231_g5c411f69f/sbcl/2_0_0",maxima_frontend="wxMaxima",maxima_frontend_version="20.12.2-DevelopmentSnapshot_MSW_OpenMP201511+Locks")build_info(version="branch_5_44_base_231_g5c411f69f",timestamp="2021-01-12 23:51:42",host="x86_64-w64-mingw32",lisp_name="SBCL",lisp_version="2.0.0",maxima_userdir="C:/Users/zmth1/maxima",maxima_tempdir="C:/Users/zmth1/AppData/Local/Temp",maxima_objdir="C:/Users/zmth1/maxima/binary/branch_5_44_base_231_g5c411f69f/sbcl/2_0_0",maxima_frontend="wxMaxima",maxima_frontend_version="20.12.2-DevelopmentSnapshot_MSW_OpenMP201511+Locks")(version="branch_5_44_base_231_g5c411f69f",timestamp="2021-01-12 23:51:42",host="x86_64-w64-mingw32",lisp_name="SBCL",lisp_version="2.0.0",maxima_userdir="C:/Users/zmth1/maxima",maxima_tempdir="C:/Users/zmth1/AppData/Local/Temp",maxima_objdir="C:/Users/zmth1/maxima/binary/branch_5_44_base_231_g5c411f69f/sbcl/2_0_0",maxima_frontend="wxMaxima",maxima_frontend_version="20.12.2-DevelopmentSnapshot_MSW_OpenMP201511+Locks")

On Thursday, September 16, 2021, 11:55:55 PM CDT, Robert Dodier via Maxima-bugs <maxima-bugs@lists.sourceforge.net> wrote:  

Dan, I don't see a bug here. When I try the input shown above, I get back the same summation, unchanged except max(0, n-p) is replaced by n - p, which is okay, although it is a little disappointing that simplify_sum couldn't find a solution.

What is the output you are getting? Also, what does build_info(); report?

Enabling the (admittedly obscure) flag for debugging simplify_sum, verbose_level: 2, seems to indicate the message about "lower bound greater than upper bound" comes from the code for simpsum, which is an older part of the summation code, separate from simplify_sum. I'm not sure whether that message represents an error or not.

[bugs:#3856] incorrect result for simplify_sum applied to binomials

Status: open Group: None Labels: sum simplify_sum Created: Fri Sep 17, 2021 03:24 AM UTC by dan hayes Last Updated: Fri Sep 17, 2021 04:49 AM UTC Owner: nobody (assume_pos:true, load(simplify_sum), simpsum:true, load("lrats"), letrat:true, ratfac:true, algebraic:true );

(declare([n,p],integer), assume(n>=p,p>0), t:simplify_sum(sum(binomial(2n+1,2p+2k+1)binomial(p+k,k),k,0,max(0,n-p))));

gives error "lower bound 0 greater than upper bound -p" which it should NOT because upper bound is also 0 .

Anyway though if leave off the -p it's ok except it gives answer in an inconvenient form of negative factorials and is also WRONG ans. for when n=p=1 the sum is 1 but maxima's answer is 0.

Sent from sourceforge.net because maxima-bugs@lists.sourceforge.net is subscribed to https://sourceforge.net/p/maxima/bugs/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/maxima/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.


Maxima-bugs mailing list Maxima-bugs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/maxima-bugs

Attachments:

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:13:44 Created by zmth on 2021-10-04 06:56:13 Original: https://sourceforge.net/p/maxima/bugs/3856/#dcaa


In fact maxima should not give any error even if upper limit really is lower than lower limit. It just creates an unnecessary bottle neck and halts your routine for NO reason and in that case it should just give 0 whenever that is the case just like fortran or even maxima eg for n=L thru H for H<L then it ignores that step as it should and so should the sum.... There is absolutely NO reason for giving an error ever! It's bad enough maxima gives countless bogus error messages of quotient by 0 or 0 to negative exponent bogus errors all the time sure don't need any more unnecessary error messages.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:13:48 Created by macrakis on 2021-10-04 14:46:31 Original: https://sourceforge.net/p/maxima/bugs/3856/#dcaa/4a15


This isn't really the right forum for discussing the error checking. But see https://sourceforge.net/p/maxima/bugs/3871/ for an example where not checking the limits results in an incorrect answer.