# [Maxima] Feature request

S. Newhouse sen1 at math.msu.edu
Mon Apr 21 12:32:21 CDT 2008

```Richard Hennessy wrote:
> I wanted something like this so thanks.  The only thing is the degree of the polynomials.  I used the quadratic case as an example but really the reason I asked about this is that I have a power series in x and y and I needed to keep a lot of terms for accuracy.  In one case to get sufficient accuracy I used 500 terms.
>
> Rich
>
>
>
>
>
>  ------------Original Message------------
> From: Harald Geyer <harald at lefant.net>
> To: "Richard Hennessy" <rvh2007 at comcast.net>
> Cc: "Maxima List" <maxima at math.utexas.edu>
> Date: Mon, Apr-21-2008 12:01 PM
> Subject: Re: [Maxima] Feature request
>
> Hi Richard.
>
>
>>  I would really like it if you could have some control over the order
>> of terms in a polynomial by using some external package which could be
>>
>
> I don't think that needs an extra package. All you need to do is keep
> the core simplifier from reordering terms. Perhaps the following
> is able to give you some ideas, how to do that. The important
> part ist the "simp:false" statement - but be careful, maxima heavily
> depends on it's core simplifier...
>
> myprint(expr, pred):=block([simp:false],
>         print(apply("+", sort(subst("[", "+", expr), pred))));
> (%i31) expr:y+x^2+x+b+a;
> (%i32) myprint(expr, lambda([u,v], orderlessp(u,v)))\$
> a+b+x+x^2+y
> (%i33) myprint(expr, lambda([u,v], orderlessp(v,u)))\$
> y+x^2+x+b+a
> (%o34) mypred(x,y):=if atom(x) and not atom(y) then true
>         else (if not atom(x) and atom(y) then false
>                 else orderlessp(x,y))
> (%i35) myprint(expr, mypred)\$
> a+b+x+y+x^2
>
> Of course you can invent any other predicate you like...
>
> HTH,
> Harald
>
>
>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
> .
>
>
You can get the terms of order n easily as follows:

I will suppress the outputs since the exponents get shifted in the 'cut
and paste'

Try the following commands.

(%i12) p: a*x^2 + b*y^2 + d*x*y + e*x + f*y + g;

(%i13) t1: taylor(p,[x,y],0,2);

(%i14) part(t1,3);

(%i14) p1: taylor(x*exp(x+y),[x,y],0,5);

(%i15) part(p1,5);

HTH,
-sen

```