rtoy / maxima

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

fails to signal error in function definition #2868

Open rtoy opened 3 months ago

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-07 00:08:05 Created by zmth on 2021-07-09 05:25:45 Original: https://sourceforge.net/p/maxima/bugs/3809


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

(hyp(k):=block(S2b:sum(ind1[in2+j]x^(lisn[iLn2+j]/2)exp(-rlis[iLn2+j]*x).j,1,n2)))

fails to signal error {a period instead of comma before the j in sum} in the definition function. Waits till make use of it then gives error

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-07 00:08:06 Created by peterpall on 2021-07-09 08:33:40 Original: https://sourceforge.net/p/maxima/bugs/3809/#c0c9


I wonder if this is a real bug or if it is a feature that allows you to define a function that after the changes done later and before using it will make the function work.

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-07 00:08:09 Created by macrakis on 2021-07-09 16:45:46 Original: https://sourceforge.net/p/maxima/bugs/3809/#21d8


The statement as given is syntactically invalid and gives an error on parse -- it needs multiplication signs between the terms in several places. It be helpful if bug reports (a) were tested before being included in bug reports and (b) included minimal examples without extraneous detail -- why the block? Why the assignment to the free variable S2b? Why the complicated argument when a simple one would do to demonstrate the problem?

As for the incorrect sum arguments, Maxima is a purely interpretive system and does not check things like number of arguments when functions are defined, only when they are called:

(%i32) s(n):=sum(n);

(%o32)                          s(n) := sum(n)
(%i33) translate(s);

(%o33)                                [s]
(%i33) s(3);

sum: expected exactly 4 arguments but got 1: [n]
 -- an error. To debug this try: debugmode(true);

As it happens, not even translate and compile know that sum requires four arguments, though they do do argument checking for some functions:

(%i39) t(x):=cons(x)$

(%i40) translate(t);
; in: PROGN (DEFPROP $T T TRANSLATED)
;     (MAXIMA::$CONS MAXIMA::$X)
; ==>
;   (MAXIMA::CONS-IMPL MAXIMA::$X)
; 
; caught STYLE-WARNING:
;   The function CONS-IMPL is called with one argument, but wants exactly two.
; 
; compilation unit finished
;   caught 1 STYLE-WARNING condition

It is arguably a bug that such checking isn't done for sum, but the translate system in general is known not to be robust.

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-07 00:08:13 Created by macrakis on 2021-07-09 19:47:53 Original: https://sourceforge.net/p/maxima/bugs/3809/#b155


Diff:


--- old
+++ new
@@ -1,4 +1,3 @@
-
 "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")

 (hyp(k):=block(S2b:sum(ind1[in2+j]*x^(lisn[iLn2+j]/2)*exp(-rlis[iLn2+j]*x).j,1,n2)))