Hi!
Alas the problem you see is not in your understanding but in maxima - at
least partially. keepfloat:true and ratsubst() don't work together
very well. This isn't documented and there are also some rather
old related bugs reported already.
Look at the following session to get an idea - the behaviour is
quite similiar on gcl, clisp and recent versions of maxima. The
problem goes away, if you set keepfloat:false;
Regards,
Harald
Maxima 5.13.0 http://maxima.sourceforge.net
Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1) batch(ratsubstbug.mac)
batching #p/home/rld/ratsubstbug.mac
(%i2) keepfloat : true
(%i3) display2d : false
(%i4) cos(%pi/3)
(%o4) 1/2
(%i5) subst(%pi/3,th,1.2*cos(th))
(%o5) 0.6
(%i6) ratsubst(%pi/3,th,1.2*cos(th))
(%o6) 1.2
(%i7) cos(%pi)
(%o7) -1
(%i8) subst(%pi,th,1.2*cos(th))
(%o8) -1.2
(%i9) ratsubst(%pi,th,1.2*cos(th))
(%o9) -1.2
(%i10) sqrt(1/4)
(%o10) 1/2
(%i11) subst(4,th,1.2*sqrt(1/th))
(%o11) 0.6
(%i12) ratsubst(4,th,1.2*sqrt(1/th))
Maxima encountered a Lisp error:
Error in MACSYMA-TOP-LEVEL [or a callee]: 1.2 is not of type INTEGER.
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
(%i13) subst(9,th,1.2*sqrt(1/th))
(%o13) 0.4
(%i14) ratsubst(9,th,1.2*sqrt(1/th))
Maxima encountered a Lisp error:
Error in MACSYMA-TOP-LEVEL [or a callee]: 1.2 is not of type INTEGER.
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
(%i15) ratsubst(9,th,1.2*sqrt(th))
(%o15) 3.6
(%i16) ratsubst(4,th,1.2/sqrt(th))
Maxima encountered a Lisp error:
Error in MACSYMA-TOP-LEVEL [or a callee]: 1.2 is not of type INTEGER.
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
(%i17) log(%e^(1/2))
(%o17) 1/2
(%i18) subst(%e^(1/2),th,1.2*log(th))
(%o18) 0.6
(%i19) ratsubst(%e^(1/2),th,1.2*log(th))
(%o19) 1.2
(%i20) subst(%e^2,th,1.2*log(th))
(%o20) 2.4
(%i21) ratsubst(%e^2,th,1.2*log(th))
(%o21) 2.4