Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
/*
 * This file:
 *   http://anggtwu.net/MAXIMA/laurent2.mac.html
 *   http://anggtwu.net/MAXIMA/laurent2.mac
 *          (find-angg "MAXIMA/laurent2.mac")
 * Author: Eduardo Ochs <eduardoochs@gmail.com>
 * See: (find-es "maxima" "laurent")
 *      http://anggtwu.net/eev-maxima.html
 *
 * Dot notation for Laurent polynomials, version 2.
 * I used it in:
 *
 *   2hT233 (c2m232ncp 5 "maxima")
 *          (c2m232nca   "maxima")
 *          http://anggtwu.net/LATEX/2023-2-C2-Tudo.pdf#page=233
 *   2hT250 (c2m232tap 3 "caixinhas")
 *          (c2m232taa   "caixinhas")
 *          http://anggtwu.net/LATEX/2023-2-C2-Tudo.pdf#page=250
 *
 * The next block is a copy of the comments from the version 1, that
 * is here:
 *   (find-angg "MAXIMA/laurent1.mac")
 *
 * Dot notation for Laurent polynomials, version 1.
 * Idea: 456.78 is
 *
 *   4*10^2 + 5*10^1 + 6*10^0 + 7*10^-1 + 8*10^-2,
 *
 * and we write it (roughly) as:
 *
 *   [ 4  5  6  .  7  8 ]
 *
 * We can generalize the 10 to x.
 * With the functions of this file we have:
 *
 *   (%i2) lpx(4*x^2 + 5*x^1 + 6*x^0 + 7*x^-1 + 8*x^-2);
 *   (%o2)           [ 4  5  6  .  7  8 ]
 *
 * The "[ 4 5 6 . 7 8 ]" is a horizontal matrix that has the string
 * "." in its fourth position; the "." separates the "integer part"
 * from the "fractional part".
 *
 * These Laurent polynomials are also great for teaching trigonomotric
 * identities:
 *
 *   If we define          E = e^(ix),
 *                   icos(x) = E + E^-1,
 *            and    isin(x) = E - E^-1,
 *   then we have     cos(x) =    1/2 * icos(x)
 *            and     sin(x) = 1/(2i) * isin(x).
 *
 * Using Laurent polynomials on E instead of on x we have:
 *
 *   (%i1) lpE(icos(x));
 *   (%o1)                           [ 1  0  .  1 ]
 *   (%i2) lpE(isin(x));
 *   (%o2)                          [ 1  0  .  - 1 ]
 *   (%i3) lpE(isin(3*x));
 *   (%o3)                    [ 1  0  0  0  .  0  0  - 1 ]
 *   (%i4) lpE(isin(3*x) * icos(x));
 *   (%o4)                [ 1  0  1  0  0  .  0  - 1  0  - 1 ]
 *   (%i5) lpE(isin(4*x) + isin(2*x));
 *   (%o5)                [ 1  0  1  0  0  .  0  - 1  0  - 1 ]
 *   (%i6) lpe( sin(4*x) +  sin(2*x));
 *   (%o6)                         sin(4 x) + sin(2 x)
 *   (%i7) 
 *
 * See: (find-es "maxima" "laurent")
 * (defun e () (interactive) (find-angg "MAXIMA/laurent1.mac"))
 *
 * (defun e () (interactive) (find-angg "MAXIMA/laurent2.mac"))
 * (defun o () (interactive) (find-angg "MAXIMA/laurent1.mac"))
*/

lpdegrees(lp,var) := block(
  [revlp,origposdeg,orignegdeg,posdeg,negdeg],
  revlp      : subst([var=var^-1], lp),
  origposdeg :  hipow(   lp, var),
  orignegdeg : -hipow(revlp, var),
  posdeg     : max(origposdeg, 0),
  negdeg     : min(orignegdeg, 0),
  [posdeg,negdeg])$

lpcoeffs0(lp,var,hilo) := makelist(ratcoef(lp,var,k), k, hilo[1],hilo[2], -1)$
lpcoeffs (lp,var)      := apply('lpcoeffs0, [lp,var, lpdegrees(lp,var)]);
lpdot    (lp,var)      := block([hi,lo,posdigits,negdigits],
  [hi,lo]    : lpdegrees(lp,var),
  posdigits  : lpcoeffs0(lp,var,[hi,0]),
  negdigits  : lpcoeffs0(lp,var,[-1,lo]),
  matrix(append(posdigits, ["."], negdigits))
  )$

E_th : E = exp(%i*th);
E_x  : E = exp(%i*x);
th_E : th = log(E)/%i;
x_E  : x  = log(E)/%i;

fourierize (f) := expand(demoivre(expand(exponentialize(f))));
fourierizeE(f) :=      subst(th_E,expand(exponentialize(f)));
lpE(f)         := lpdot(fourierizeE(f),E);
lpx(f)         := lpdot(expand(f),x)$
lpe(f)         := expand(demoivre(expand(exponentialize(f))))$

ccos(th) := 2*cos(th);
csin(th) := 2*%i*sin(th);

/*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("laurent2.mac");
p : 4*x^2 + 5*x^1 + 6*x^0 + 7*x^-1 + 8*x^-2;
q : 4*E^2 + 5*E^1 + 6*E^0 + 7*E^-1;
lpdot(p, x);
lpdot(q, E);
f :  cos(th)^3;
g : ccos(th)^3;
lpe(f);
lpe(g);

                       exponentialize(f);
                expand(exponentialize(f));
       demoivre(expand(exponentialize(f)));
expand(demoivre(expand(exponentialize(f))));
     subst(th_E,expand(exponentialize(f)));
     subst(th_E,expand(exponentialize(g)));

lpE(f);
lpE(g);
lpE(  ccos(th)^3);
lpE(  ccos(th));
lpE(3*ccos(th));
lpE(ccos(3*th));
lpE(ccos(3*th)+3*ccos(th));

lpE( ccos(th)   );
lpE( ccos(th)^2 );
lpE( ccos(th)^3 );
lpE( csin(th)     );
lpE( csin(th)^2   );
lpE( csin(th)^3   );
lpE( csin(2*th)   );
lpE( csin(2*th)^2 );

*/



/*
 * Local Variables:
 * coding:  utf-8-unix
 * End:
*/