rtoy / maxima

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

various complicated examples #2894

Open rtoy opened 2 months ago

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:18:06 Created by zmth on 2021-10-08 05:24:02 Original: https://sourceforge.net/p/maxima/bugs/3874


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_

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:18:07 Created by zmth on 2021-10-08 05:28:16 Original: https://sourceforge.net/p/maxima/bugs/3874/#fb00


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.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:18:11 Created by macrakis on 2021-10-08 14:35:51 Original: https://sourceforge.net/p/maxima/bugs/3874/#7d29


rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:18:14 Created by macrakis on 2021-10-08 14:40:14 Original: https://sourceforge.net/p/maxima/bugs/3874/#c7d3


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.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:18:18 Created by macrakis on 2021-10-08 14:40:35 Original: https://sourceforge.net/p/maxima/bugs/3874/#ed02


rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:18:21 Created by villate on 2021-10-08 15:14:33 Original: https://sourceforge.net/p/maxima/bugs/3874/#db5a


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)

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:18:25 Created by macrakis on 2021-10-08 16:46:51 Original: https://sourceforge.net/p/maxima/bugs/3874/#9e33


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.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 00:18:29 Created by macrakis on 2021-10-08 16:47:17 Original: https://sourceforge.net/p/maxima/bugs/3874/#7339