4.6 Operations on standard forms

Arithmetic with standard forms is performed by the functions12

null(f)test f = 0
minusf(f)test f < 0 (formally)
domainp(f)test if f is a domain element (e.g. number)
addf(f1,f2)f1 + f2
addf(f1,negf f2)f1-f2
mksp**(f1,n)compute f1**n
quotf(f1,f2)f1∕f2 if divisible, else nil
quotfx(f1,f2)f1∕f2 divisiblity assumend, no check
qremf(f1,f2)pair (quotient.remainder)

As standard forms are a superset of domain elements these functions also can be used for arithmetic with domain elements or for combining standard forms with integer numbers. They can even be used to compute with integers as long as these are regarded as “degenerate” polynomials.

For access of the components of a standard form there are functions

mvar(f)extract leading kernel
ldeg(f)extract leading degree
lc(f)extract leading coefficient
red(f)extract reductum f

These functions can be applied only if the form is not a domain element. The following example presents a typical function evaluating a standard form; it looks for the maximum power of a specified kernel y in a standard form f:

  symbolic procedure my_maxpow(f,y);  
    if domainp f then 0 else  
    if mvar f eq y then ldeg f else  
    max(my_maxpow(lc f,d),my_maxpow(red f,d));

This function has a double recursion which is typically for functions traversing standard forms: if the top node is not trivial (domainp) or not a power of y the procedure branches to the coefficient form and to the reductum form - both can contain references to the kernel y. Kernels are unique in the system and therefore the equality test is performed by eq.

For the initial construction of a standard form a safe and efficient way is to build an algebraic expression first and convert it using simp (see below) or to use the arithmetic functions above too. For elementary conversions use

*k2f(k)convert unique kernel k to  SF
numr simp(a)convert algebraic expression a to SF
prepf(f)convert a SF f to an algebraic expression

Note that integers are already an SF and so need not be converted.

Although the are infix macros .** , .* , .+ to construct standard forms, they should be avoided unless you are completely sure what you are doing: they construct without any consistency checks, and wrong structures may lead to inconsistent results; such cases are difficult to debug.