# [Maxima] strange behavior of tex()

Kostas Oikonomou ko at research.att.com
Thu Jan 17 09:44:50 CST 2008

```Stavro,

rat() doesn't seems to do what I want.  I have this function

f3(a,r) := block([n], n:length(a),
sum(sum(sum((a[i]+a[j]+a[k])*r[i]*r[j]*r[k], k,j+1,n),
j,i+1,n), i,1,n)
)

and I am trying to arrange

f3([a[1],a[2],a[3],a[4]],[r[1],r[2],r[3],r[4]])

so that the a's come before the r's, i.e. like

(a1+a2+a3)r1r2r3 + (a1+a2+a4)r1r2r4 + ...

Maybe this is not possible?

Kostas

Stavros Macrakis wrote:
> On Jan 17, 2008 9:42 AM, Kostas Oikonomou <ko at research.att.com> wrote:
>> Does maxima have a way other than ordergreat() to order the
>> variables in a multivariate polynomial?
>
> If canonical rational expression (CRE) form will work for you, take a
> look at rat(..., var1, var2, ...) and at ratvars.  CRE form is a
> polynomial of polynomials:
>
>     p:x+x*y+y^2+1
>            => y^2+x*y+x+1
>     rat(p,x,y)
>            => y^2+x*y+x+1
>     rat(p,y,x)
>            => (y+1)*x+y^2+1
>
> Otherwise, I think you have to use ordergreat. Still, variables should
> print correctly despite ordergreat.
>
> Best,
>
>              -s
```