Menu

#3874 various complicated examples

None
not-a-bug
nobody
user error (1)
5
2021-10-08
2021-10-08
dan hayes
No

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")

(fl:true,fp:binomial(n+1,k)^2/ binomial(2*n+2,n+1),f: binomial(n,k)^2/binomial(2*n,n), dg:(-3*n+2*k-1)*n!^2/(2*n+1)/k!^2/(n-k)!^2/binomial(2*n,n)/2
-(-3*n+2*k-3)*n!^2/(2*n+1)/(k-1)!^2/(n-k+1)!^2/binomial(2*n,n)/2,for n:2 thru 4 do for k thru n-1 do(t:fp-f-dg,if t#0 then(fl:false,disp(["n",n,"k",k,t]))),fl);

gives the result without evaluation but just using symbols - how ignorant can u get ?
if change to

(fl:true,fp:binomial(n+1,k)^2/ binomial(2*n+2,n+1),f: binomial(n,k)^2/binomial(2*n,n), dg:(-3*n+2*k-1)*n!^2/(2*n+1)/k!^2/(n-k)!^2/binomial(2*n,n)/2
-(-3*n+2*k-3)*n!^2/(2*n+1)/(k-1)!^2/(n-k+1)!^2/binomial(2*n,n)/2,for n:2 thru 4 do for k thru n-1 do(t:ev(fp-f-dg,numer),if t#0 then(fl:false,disp(["n",ns,"k",ks,t]))),fl);

then it does evaluate but in floating point when did not want floating point

(fl:true,fp:binomial(n+1,k)^2/ binomial(2*n+2,n+1),f: binomial(n,k)^2/binomial(2*n,n), dg:(-3*n+2*k-1)*n!^2/(2*n+1)/k!^2/(n-k)!^2/binomial(2*n,n)/2
-(-3*n+2*k-3)*n!^2/(2*n+1)/(k-1)!^2/(n-k+1)!^2/binomial(2*n,n)/2,for n:2 thru 4 do for k thru n-1 do(t:lratsubst([n=n,k=k],fp-f-dg) 
,if t#0 then(fl:false,disp(["n",n,"k",k,t]))),fl);

now it gives ridiculous not evaluated but general symbols again

(fl:true,fp:binomial(n+1,k)^2/ binomial(2*n+2,n+1),f: binomial(n,k)^2/binomial(2*n,n), dg:(-3*n+2*k-1)*n!^2/(2*n+1)/k!^2/(n-k)!^2/binomial(2*n,n)/2
-(-3*n+2*k-3)*n!^2/(2*n+1)/(k-1)!^2/(n-k+1)!^2/binomial(2*n,n)/2,for ns:2 thru 4 do for ks thru ns-1 do(t:lratsubst([n=ns,k=ks],fp-f-dg)
 ,if t#0 then(fl:false,disp(["n",ns,"k",ks,t]))),fl);

NOw this does work as it should but with the ridiculous requirement that had to use ns,ks rather than just the obvious n,k symbols
now the next is truly a bug as again give bogus error messages which DO NOT IN any way apply.

(fl:true,fp:binomial(n+1,k)^2/ binomial(2*n+2,n+1),f: binomial(n,k)^2/binomial(2*n,n), dg:(-3*n+2*k-1)*n!^2/(2*n+1)/k!^2/(n-k)!^2/binomial(2*n,n)/2
-(-3*n+2*k-3)*n!^2/(2*n+1)/(k-1)!^2/(n-k+1)!^2/binomial(2*n,n)/2,for n':2 thru 4 do for k' thru n'-1 do(t:lratsubst([n=n',k=k'],fp-f-dg)
 ,if t#0 then(fl:false,disp(["n",n',"k",k',t]))),fl);

**also gives bogus error messages if replace ' by . Though surprisingy it works if replace the ' by _ eg as in n_ , k_

Discussion

  • dan hayes

    dan hayes - 2021-10-08

    sorry there was one repeat but since there is no way to edit a post will have to keep it as is. That is a feature request would like to have: the ability to edit ones post.

     
  • Stavros Macrakis

    • summary: Some more totally unnecessary bottlenecks that should not be but just to cause user frustration and extra trouble but may not be called bugs except for the last which is definitely a bug giving false bogus error messages again when it should not. --> various complicated examples
     
  • Stavros Macrakis

    a) There is a way of editing posts. Try the "Edit" button.
    b) Your examples are unnecessarily elaborate. For your first example, I think this shows the issue:

    ex: k$ for k thru 2 do print(ex)$
    

    This prints k two times, and not `1 and 2. That is, ex is not re-evaluated in this context.
    c) Your last example, with n', can't work, since Maxima treats ' as an operator, but it is not defined as a postfix operator.

    Closing as user error.

     
  • Stavros Macrakis

    • status: open --> not-a-bug
     
  • Jaime E. Villate

    This "bug" report shows that the author has not understood how Maxima works.
    An statement such as

    f: n-k$
    

    associates the expression n-k to the symbol f, but if the symbols n and k are later associated to numbers, the expression associated to f continues to be n-k, and not the "value" of n minus the value of k.
    Try something such as:

    fp(n,k):=binomial(n+1,k)^2/ binomial(2*n+2,n+1)$
    f(n,k):=binomial(n,k)^2/binomial(2*n,n)$
    dg(n,k):=(-3*n+2*k-1)*n!^2/(2*n+1)/k!^2/(n-k)!^2/binomial(2*n,n)/2
    -(-3*n+2*k-3)*n!^2/(2*n+1)/(k-1)!^2/(n-k+1)!^2/binomial(2*n,n)/2$
    for n:2 thru 4 do
    for k thru n-1 do (
      t: fp(n,k)-f(n,k)-dg(n,k),
      print(n,k,t));
    

    (and please use the "preview" button before posting your messages)

     
  • Stavros Macrakis

    For this example:

    (fl:true,fp:binomial(n+1,k)^2/ binomial(2*n+2,n+1),f: binomial(n,k)^2/binomial(2*n,n), dg:(-3*n+2*k-1)*n!^2/(2*n+1)/k!^2/(n-k)!^2/binomial(2*n,n)/2
    -(-3*n+2*k-3)*n!^2/(2*n+1)/(k-1)!^2/(n-k+1)!^2/binomial(2*n,n)/2,for n:2 thru 4 do for k thru n-1 do(t:ev(fp-f-dg,numer),if t#0 then(fl:false,disp(["n",ns,"k",ks,t]))),fl);
    

    then it does evaluate but in floating point when did not want floating point

    It evaluates the variables because you used ev. It evaluates in floating-point because you used the numer argument to ev. This is all as documented. If you remove the numer flag and just write ev(...) you will get what you expected, though in general it's better to use subst or defined functions (as Villate suggested) rather than ev.

     
  • Stavros Macrakis

    • labels: --> user error
     

Log in to post a comment.