### 10.1.10 Rewriting an expression with different options

Xcas has many commands to convert expressions into different forms; the convert command (or its infixed version =>) is a different way to call most of these functions.

- convert takes two or more arguments:
  - expr, an expression.
  - option, an option specifying which rewrite rules to use. A third argument might be necessary for some options. Possible values of option are:
    - sin, to convert an expression like trigsin (see Section 10.2.23).
    - cos, to convert an expression like trigcos (see Section 10.2.24).
    - sincos, to convert an expression like sincos (see Section 10.2.13).
    - trig, to convert an expression like sincos (see Section 10.2.13).
    - tan, to convert an expression like halftan (see Section 10.2.19).
    - exp, to convert an expression like trig2exp (see Section 10.2.21).
    - ln, to convert an expression like trig2exp (see Section 10.2.21).
    - expln, to convert an expression like trig2exp (see Section 10.2.21).
    - string, to convert a expression into a string.
    - matrix, to convert a list of lists into a matrix.
    - array, to turn a table into an array (see Section 14.4.2).
    - polynom, to convert a series (see Section 13.5.2) into a polynomial by removing the remainder (see Section 11.1.25) or to convert a list representing a polynomial into a polynomial in internal sparse multivariate form (see Section 11.1.2 and Section 11.1.6).
    - parfrac (or partfrac or fullparfrac), to convert a rational function into its partial fraction decomposition (see Section 11.6.9).
    - interval, to convert an expression which evaluates to a number into an interval (see Section 6.6.8).
    - list (or no argument), to convert a polynomial in internal sparse multivariate format (see Section 11.1.2) into a list.
    - unit, a unit, to convert a unit object to a new compatible unit (see Section 24.1.4).
    The values of option that require a third argument:
    - contfrac, to convert a number into a continued fraction. (See Section 7.2.7.) The third argument will be the name of a variable to store the continued fraction into (which must be quoted the variable was assigned).
    - base, to convert a number into a different base (beginning with the units digit). If expr is a number, then the third argument will be base to convert to (see Section 5.4.2), if expr is a list of numbers, then the third argument will be the base to convert from (and expr will be a list of the digits in this base, starting with the units digit).
    Finally, if expr is an expression with units (see Section 24.1.1), then option can be new units to convert to (see Section 24.1.4).
- convert(expr,option⟨,extraop⟩) returns the expression with the requested conversions done.

#### Examples

convert(1.2,confrac,'fc')

| ⎡ ⎣ | 1,5 | ⎤ ⎦

and fc contains the continued fraction equal to 1.2.

convert(123,base,10)

| ⎡ ⎣ | 3,2,1 | ⎤ ⎦

convert([3,2,1],base,10)

123 |  |  |  |  |  |  |  |  |  |

convert(1000_g,_kg)

1.0 kg |  |  |  |  |  |  |  |  |  |