### The Maxima on-line user's manual

Algebra Calculator

#### Rat

Function: rat (<expr>)

Function: rat (<expr>, <x_1>, ..., <x_n>) Converts <expr> to canonical rational expression (CRE) form by expanding and combining all terms over a common denominator and cancelling out the greatest common divisor of the numerator and denominator, as well as converting floating point numbers to rational numbers within a tolerance of `ratepsilon`. The variables are ordered according to the <x_1>, ..., <x_n>, if specified, as in `ratvars`.

`rat` does not generally simplify functions other than addition `+`, subtraction `-`, multiplication `*`, division `/`, and exponentiation to an integer power, whereas `ratsimp` does handle those cases. Note that atoms (numbers and variables) in CRE form are not the same as they are in the general form. For example, `rat(x)- x` yields `rat(0)` which has a different internal representation than 0.

When `ratfac` is `true`, `rat` yields a partially factored form for CRE. During rational operations the expression is maintained as fully factored as possible without an actual call to the factor package. This should always save space and may save some time in some computations. The numerator and denominator are still made relatively prime (e.g. `rat ((x^2 - 1)^4/(x + 1)^2)` yields `(x - 1)^4 (x + 1)^2)`, but the factors within each part may not be relatively prime.

`ratprint` if `false` suppresses the printout of the message informing the user of the conversion of floating point numbers to rational numbers.

`keepfloat` if `true` prevents floating point numbers from being converted to rational numbers.

See also `ratexpand` and `ratsimp`.

```     Examples:
(%i1) ((x - 2*y)^4/(x^2 - 4*y^2)^2 + 1)*(y + a)*(2*y + x) /
(4*y^2 + x^2);
4
(x - 2 y)
(y + a) (2 y + x) (------------ + 1)
2      2 2
(x  - 4 y )
(%o1)         ------------------------------------
2    2
4 y  + x
(%i2) rat (%, y, a, x);
2 a + 2 y
(%o2)/R/                    ---------
x + 2 y```

There are also some inexact matches for `rat`. Try `?? rat` to see them.

```(%o1)                                true
(%i2) ```

### Related Examples

##### rat

n: 10000;

rat((k+1)*n^k-n^(k+1)...

Calculate

##### rat-sqrt

eq1:1/((- a*w+I*w*sqr...

eq2:rat(eq1);

Calculate

##### rat-sum

N:2;

su: sum(a[2*ii]*(s-1/...

rat(su,s);

Calculate

##### rat-taylor

f1:x^7-x^2+1-x^1+x^5;

f2:x^14-x^4+1-x^2+x^10;

f4:x^28-x^8+1-x^4+x^20;

Calculate

##### rat-resultant

A:x^4+4*a*x^2+b*x+c;

B:p0*y^2+p2-x*y;

C:rat(resultant(A,B,x...

Calculate

##### rat

p(z):= a*z^2+b;

q(z):= c*z^2+d;

nxt(ns) := rat(ns[1]^...

Calculate

##### rat-remainder-resultant

A:u^4+4*p*u^2+q*u+r;

B:a*v^2+b*v+c-u*(v+d);

C:rat(resultant(A,B,u...

Calculate

##### rat-solve

r1: k1 * Pa * (1-Ta-T...

r3: k3 * Pb * (1-Ta-T...

solve([r1,r3],[Ta,Tb]);

Calculate

a = 10;

b = rat(a + 1);

Calculate

##### rat-remainder-resultant

A:u^4+p*u^2+q*u+r;

B:v^2+b-u*(c*v^2+e);

C:v^4+k*v+m;

Calculate