Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
/*
 * This file:
 *   http://anggtwu.net/MAXIMA/2025-caixinhas-1.mac.html
 *   http://anggtwu.net/MAXIMA/2025-caixinhas-1.mac
 *          (find-angg "MAXIMA/2025-caixinhas-1.mac")
 * Author: Eduardo Ochs <eduardoochs@gmail.com>
 * Version: 2025may25
 *
 * This file contains [the 2005 version of] some tools that I use for
 * teaching operations with polynomiais in Calculus 2.
 *
 * The students are arriving in C2 with only very vague memories of
 * how to divide polynomials, so this is mostly to convince them to
 * use a positional notation with boxes ("caixinhas").
 *
 * If you can read Portuguese please take a look here
 *   http://anggtwu.net/2025.1-C2.html#o-puro-e-um-lixo
 * for some stories about the campus in which I work -
 * solidarity is inevitable. =S
 *
 * See: (c2m251fpp 22 "notacoes-posicionais")
 *      (c2m251fpa    "notacoes-posicionais")
 *      (c2m251fpp 23 "notacoes-posicionais-2")
 *      (c2m251fpa    "notacoes-posicionais-2")
 *
 * TODO: MacLaurin series (with the "..."s).
 *  See: (find-anggfile "MAXIMA/mac1.mac")
 *
 * «.load»		(to "load")
 * «.ccc»		(to "ccc")
 * «.ccc-tests»		(to "ccc-tests")
 * «.poly»		(to "poly")
 * «.poly-tests»	(to "poly-tests")
 * «.E»			(to "E")
 * «.E-tests»		(to "E-tests")
*/


/* «load»  (to ".load")
 * See: (find-es "maxima" "load_pathname")
 *      (find-angg "MAXIMA/2025-caixinhas-1.lisp")
 *      (find-angg "MAXIMA/2025-methods.mac")
*/
caixinhas_dir : pathname_directory(load_pathname);
load(concat(caixinhas_dir, "2025-caixinhas-1.lisp"));
load(concat(caixinhas_dir, "2025-methods.mac"));


/* «ccc»  (to ".ccc")
 * For example,      ccc_([10,20,30],[40,50]);
 * is displayed as:  [ 10 : 20 : 30 . 40 : 50 ]
*/
aaa_(list)        := if     length(list) > 1 then apply('aaa,list)
                     elseif length(list) = 1 then list[1]
                     else   0;
bbb_(listL,listR) := if     length(listR) = 0 then aaa_(listL)
                     else   bbb(aaa_(listL), aaa_(listR));
ccc_(listL,listR) := ccc(bbb_(listL, listR));        

/* «ccc-tests»  (to ".ccc-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-caixinhas-1.mac");
ccc_(        [],[]);
ccc_(       [0],[]);
ccc_(      [30],[]);
ccc_(   [20,30],[]);
ccc_([10,20,30],[]);
ccc_([10,20,30],[40]);
ccc_([10,20,30],[40,50]);

*/


/* «poly»  (to ".poly")
*/
defstruct(poly(poly, var));
poly_in_x  (poly0) := new(poly(expand(poly0),'x));
poly__rev  (p)     := subst([p@var=p@var^-1], p@poly);
poly__hi   (p)     :=  hipow(p@poly,   p@var);
poly__low  (p)     := -hipow(p@@rev(), p@var);
poly__coef (p,k)   := ratcoef (p@poly, p@var, k);
poly__coefs(p,ks)  := makelist(p@@coef(k), k, ks);
poly__L    (p)     := p@@coefs(seqby(p@@hi(),0,-1));
poly__R    (p)     := p@@coefs(seqby(-1,p@@low(),-1));
poly__ca   (p)     := ccc_(p@@L(), p@@R());

/* «poly-tests»  (to ".poly-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-caixinhas-1.mac");
myp0 :                  0;
myp0 : 10*x^2 + 20*x + 30;
myp0 : 10*x^2 + 20*x + 30 + 40*x^-1;
myp0 : 10*x^2 + 20*x + 30 + 40*x^-1 + 50*x^-2 + 60*x^-3;
myp  : poly_in_x(myp0);
myp@@hi();
myp@@low();
myp@@coef(2);
myp@@coefs([3,2,1,0]);
myp@@ca();

*/


/* «E»  (to ".E")
*/
E_to_th         :  E = exp(%i*th);
th_to_E         :  th = log(E)/%i;
th_to_E     (f) := subst(th_to_E, expand(exponentialize(f)));
E_to_th     (f) := expand(demoivre(subst(E_to_th, f)));
poly_in_E   (f) := new(poly(th_to_E(f),'E));  /* constructor */
poly__to_th (p) := E_to_th(p@poly);           /* method      */
Cos        (th) :=    2*cos(th);              /* cos without the fraction */
Sin        (th) := 2*%i*sin(th);              /* sin without the fraction */

/* «E-tests»  (to ".E-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-caixinhas-1.mac");
myp : poly_in_E(Cos(th)^2);
myp@@ca();
myp@@to_th();

*/