## Name:

canonical brings all polynomial subexpressions of an expression to canonical form or activates, deactivates or checks canonical form printing

## Library names:

void sollya_lib_set_canonical_and_print(sollya_obj_t) void sollya_lib_set_canonical(sollya_obj_t) sollya_obj_t sollya_lib_canonical(sollya_obj_t) sollya_obj_t sollya_lib_get_canonical()

## Usage:

canonical(function) : function -> function canonical = activation value : on|off -> void canonical = activation value ! : on|off -> void

## Parameters:

• function represents the expression to be rewritten in canonical form
• activation value represents on or off, i.e. activation or deactivation

## Description:

• The command canonical rewrites the expression representing the function function in a way such that all polynomial subexpressions (or the whole expression itself, if it is a polynomial) are written in canonical form, i.e. as a sum of monomials in the canonical base. The canonical base is the base of the integer powers of the global free variable. The command canonical does not endanger the safety of computations even in Sollya's floating-point environment: the function returned is mathematically equal to the function function.
• An assignment canonical = activation value, where activation value is one of on or off, activates respectively deactivates the automatic printing of polynomial expressions in canonical form, i.e. as a sum of monomials in the canonical base. If automatic printing in canonical form is deactivated, automatic printing yields to displaying polynomial subexpressions in Horner form.

If the assignment canonical = activation value is followed by an exclamation mark, no message indicating the new state is displayed. Otherwise the user is informed of the new state of the global mode by an indication.

## Example 1:

> print(canonical(1 + x * (x + 3 * x^2)));
1 + x^2 + 3 * x^3
> print(canonical((x + 1)^7));
1 + 7 * x + 21 * x^2 + 35 * x^3 + 35 * x^4 + 21 * x^5 + 7 * x^6 + x^7

## Example 2:

> print(canonical(exp((x + 1)^5) - log(asin(((x + 2) + x)^4 * (x + 1)) + x)));
exp(1 + 5 * x + 10 * x^2 + 10 * x^3 + 5 * x^4 + x^5) - log(asin(16 + 80 * x + 160 * x^2 + 160 * x^3 + 80 * x^4 + 16 * x^5) + x)

## Example 3:

> canonical;
off
> (x + 2)^9;
512 + x * (2304 + x * (4608 + x * (5376 + x * (4032 + x * (2016 + x * (672 + x * (144 + x * (18 + x))))))))
> canonical = on;
Canonical automatic printing output has been activated.
> (x + 2)^9;
512 + 2304 * x + 4608 * x^2 + 5376 * x^3 + 4032 * x^4 + 2016 * x^5 + 672 * x^6 + 144 * x^7 + 18 * x^8 + x^9
> canonical;
on
> canonical = off!;
> (x + 2)^9;
512 + x * (2304 + x * (4608 + x * (5376 + x * (4032 + x * (2016 + x * (672 + x * (144 + x * (18 + x))))))))