Subject: different meaning of function parameters?
From: andre maute
Date: Mon, 26 May 2008 21:58:06 +0200
Okay. still no answer, :-)
I post my maxima output below.
The question:
"Why is the result of the last my_factor2 statement 1 and not a/c ?"
Am I supposed to always prefix my function parameters?
I have added some print's for debug info.
Regards Andre
> -----------------------------------------------------
> my_factor1(a,x,q) := block(
> [res],
> res : ratcoef(q,x,1)/a,
> return(res)
> )$
>
> my_factor2(a,x,q) := block(
> [res,lhsc,rhsc,my_factor_c,sols],
> lhsc : ratcoef(q,x,1),
> rhsc : a*my_factor_c,
> sols : solve( [lhsc=rhsc], [my_factor_c] ),
> res : factor(rhs( sols[1] )),
> return(res)
> )$
>
> p : c*x;
> cp : my_factor1(a,x,p);
>
> p : a*x;
> cp : my_factor1(c,x,p);
>
> p : c*x;
> cp : my_factor2(a,x,p);
>
> p : a*x;
> cp : my_factor2(c,x,p);
> -----------------------------------------------------
-------------------------------------------------------
Maxima 5.15.0 http://maxima.sourceforge.net
Using Lisp SBCL 1.0.11.debian
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) batch(test3.max)
batching /home/seirios/test3.max
(%i2) display2d : false
(%o2) false
(%i3) my_factor1(a,x,q):=block([res],res:ratcoef(q,x,1)/a,return(res))
(%i4) my_factor2(a,x,q):=block([res,lhsc,rhsc,my_factor_c,sols],
lhsc:ratcoef(q,x,1),print("lhsc ",lhsc),rhsc:a*my_factor_c,
print("rhsc ",rhsc),sols:solve([lhsc = rhsc],[my_factor_c]),
print("sols ",sols),res:factor(rhs(sols[1])),return(res))
(%i5) p:c*x
(%o5) c*x
(%i6) cp:my_factor1(a,x,p)
(%o6) c/a
(%i7) p:a*x
(%o7) a*x
(%i8) cp:my_factor1(c,x,p)
(%o8) a/c
(%i9) p:c*x
(%o9) c*x
(%i10) cp:my_factor2(a,x,p)
lhsc c
rhsc a*my_factor_c
sols [my_factor_c = c/a]
(%o10) c/a
(%i11) p:a*x
(%o11) a*x
(%i12) cp:my_factor2(c,x,p)
lhsc a
rhsc c*my_factor_c
sols [my_factor_c = 1]
(%o12) 1
-------------------------------------------------------