# [Maxima] MRAT

Stavros Macrakis macrakis at alum.mit.edu
Mon Jun 20 15:51:03 WEST 2005

```Robert,

I don't have time for a full explanation, but here's a basic one.

In addition to general representation, Maxima has several special
representations including Canonical Rational Expressions (CRE) (which
subsume truncated Taylor series) and truncated Poisson series.

The only one of these special representations which is consistently
(or almost so) supported across Maxima functions is CRE.  CRE form is
"contagious" across the basic arithmetic operations (+, -, *, /,
<expr>^<integer>) because they take rational expressions to rational
expressions; in other combinations, general representation is
converted to, e.g. sin(rat(x)) is not a CRE.

Essentially all Maxima operations which do not operate specifically on
CREs convert to general representation (ratdisrep) before doing their
work, so they do not have to handle CREs as special cases internally.

A CRE is a ratio of two multivariate polynomials.  The variables may
be arbitrary Maxima expressions (but not themselves rational
expressions). So for example

x+sin(x)^2

can be represented as a CRE, considering the first variable v1 and the
second v2:

with v1=x and v2=sin(x): v1+v2^2

The multivariate polynomials are represented as univariate polynomials
with multivariate coefficients.  So for example y^3+x*y+x^2+3 can be
represented as a polynomial in y:

(1)*y^3 + (x)*y^1 + (x^2+3)*y^0

The order of nesting can be controlled by the user using ratvars and
other methods.  For example, the above polynomial can also be
represented with y as the outermost variable:

rat(y^3+x*y+x^2+3,y,x) =>

(1)*x^2 + (y)*x^1 + (y^3+3)*x^0

The internal form of CREs looks like:

((MRAT SIMP value-list name-list) numerator . denominator)

Where value-list is the list of the values of the names, e.g. x and
sin(x) in the example above, and name-list is the names of the
internal variables, namely v1 and v2.  The name-list is not visible at
the Maxima level.

The numerator and denominator are lists looking like

(<variable name> <pow> <coeff> <pow> <coeff>...)

So

(1)*x^2 + (y)*x^1 + (y^3+3)*x^0

looks something like

(xxx 2 1 1 (yyy 1 1) 0 (yyy 3 1 0 3))

where xxx is the internal representative of variable x and similarly for yyy.

This handles the simple, basic case.

Truncated series are essentially the same, except with the TRUNC flag.

Ratfac:true allows polynomials as the values of the internal variables.

-s

```