This article deals with using Maxima under CoCalc (earlier SageMath).
The reason for this usage is that wxMaxima does not print properly,
and I needed to print some incorrect code to find my error(s) in peace
and quiet.
Using the starting line "%maxima", which tells SageMath that the following
code is to be passed to Maxima, one gets an immediate error with
code which is longer than about 20 lines.
Sage Help (Stein) acknowledges
that there is a programming error in Sage causing this problem,
He suggested a work-around, which is used below.
With the workaround, there still are several pitfalls. Comments are not accepted, blank lines fail also.
No spaces, no comments, no $ terminators, only ;. Further, the maxima command tex(); fails.
In spite of the problems, it is worth passing this information along until wxMaxima maintainers fix the printing bug.
Here is an example of how to structure your Maxima code for SageMath(CoCalc):
def maxima2(s):
print(maxima.eval(s, allow_use_file=False))
%maxima2
dotscrules:true;
Lxsq:Lx.Lx;
Lysq: Ly.Ly;
Lzsq: Lz.Lz;
Lsq: Lxsq+Lysq+Lzsq;
Lminus : Lx - %i*Ly;
Aminus:(Ax-%i*Ay);
AminusLsq : Aminus.Lsq;
etc..