|
From: Eduardo O. <edu...@gm...> - 2023-07-20 15:19:06
|
On Wed, 19 Jul 2023 at 12:48, Richard Fateman <fa...@gm...> wrote:
>
>>>
>>> f : sin(x)^4 * cos(x)^2;
>>> f1 : expand(exponentialize(f));
>>> f2 : subst([x=1/%i, %e=E], f1);
>>> f3 : rat(f2, E);
>>>
>>> converts f to a rational function on E. What do I need to use instead
>>> of the "rat" in the last step to convert f to a _Laurent polynomial_
>>> on E instead of a _rational function_ on E?
>>>
>>>>
>>>>> powerdisp:true;
> ratexpand(f3) produces this display (it looks better in 2-D)...
> 1/16+1/(64*E^6)-1/(32*E^4)-1/(64*E^2)-E^2/64-E^4/32+E^6/64.
> It takes the E^0 term out front, which may not fit the pattern you are
> looking for.
>
> or just
> powerdisp:true;
> ratexpand(ratsubst(E, exp(%i*x),exponentialize(f)));
>
> I am not aware, offhand, of any advantage of this representation over the
> original form.
> RJF
>
>
Hi all,
I found a messy solution that uses declare_index_properties...
it didn't like it much, so I didn't clean it much. Here it is:
f : sin(x)^4 * cos(x)^2;
f1 : expand(exponentialize(f));
f2a : ratexpand(ratsubst(E, exp(%i*x), f1));
f2 : subst([x=1/%i, %e=E], f1);
f3 : rat(f2, E);
powerdisp:false;
exptdispflag:false;
declare_index_properties(EE, [postsuperscript]);
f4 : ratexpand(f3);
f5 : makelist(ratcoef(f4,E,k)*EE[k], k, 6, -6, -2);
f6 : apply("+", f5);
And I also found a really nice solution that displays Laurent
polynomials as horizontal matrixes, like this:
(%i2) lpx(4*x^2 + 5*x^1 + 6*x^0 + 7*x^-1 + 8*x^-2);
(%o2) [ 4 5 6 . 7 8 ]
It is here,
http://anggtwu.net/MAXIMA/laurent1.mac.html
http://anggtwu.net/MAXIMA/laurent1.mac
and you can test it with:
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))
)$
Exponentialize(f) := subst([x=1/%i,%e=E], expand(exponentialize(f)))$
lpx(lp) := lpdot(expand(lp),x)$
lpE(f) := lpdot(Exponentialize(f),E)$
lpe(f) := expand(demoivre(expand(exponentialize(f))))$
lpx(4*x^2 + 5*x^1 + 6*x^0 + 7*x^-1 + 8*x^-2);
icos(x) := 2 * cos(x);
isin(x) := 2*%i * sin(x);
lpE(icos(x));
lpE(isin(x));
lpE(isin(3*x));
lpE(isin(3*x) * icos(x));
lpE(isin(4*x) + isin(2*x));
lpe( sin(4*x) + sin(2*x));
Cheers =),
Eduardo Ochs
http://anggtwu.net/eev-maxima.html
|