[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 9. Univariate polynomials

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 9.1 Univariate polynomial rings

CLN implements univariate polynomials (polynomials in one variable) over an arbitrary ring. The indeterminate variable may be either unnamed (and will be printed according to `default_print_flags.univpoly_varname`, which defaults to ``x'`) or carry a given name. The base ring and the indeterminate are explicitly part of every polynomial. CLN doesn't allow you to (accidentally) mix elements of different polynomial rings, e.g. `(a^2+1) * (b^3-1)` will result in a runtime error. (Ideally this should return a multivariate polynomial, but they are not yet implemented in CLN.)

The classes of univariate polynomial rings are

                               Ring
                             cl_ring
                           <cln/ring.h>
                                |
                                |
                     Univariate polynomial ring
                          cl_univpoly_ring
                          <cln/univpoly.h>
                                |
               +----------------+-------------------+
               |                |                   |
     Complex polynomial ring    |    Modular integer polynomial ring
     cl_univpoly_complex_ring   |        cl_univpoly_modint_ring
     <cln/univpoly_complex.h>   |        <cln/univpoly_modint.h>
                                |
               +----------------+
               |                |
       Real polynomial ring     |
       cl_univpoly_real_ring    |
       <cln/univpoly_real.h>    |
                                |
               +----------------+
               |                |
     Rational polynomial ring   |
     cl_univpoly_rational_ring  |
     <cln/univpoly_rational.h>  |
                                |
               +----------------+
               |
     Integer polynomial ring
     cl_univpoly_integer_ring
     <cln/univpoly_integer.h>

and the corresponding classes of univariate polynomials are

                       Univariate polynomial
                              cl_UP
                          <cln/univpoly.h>
                                |
               +----------------+-------------------+
               |                |                   |
       Complex polynomial       |      Modular integer polynomial
            cl_UP_N             |                cl_UP_MI
     <cln/univpoly_complex.h>   |        <cln/univpoly_modint.h>
                                |
               +----------------+
               |                |
         Real polynomial        |
            cl_UP_R             |
      <cln/univpoly_real.h>     |
                                |
               +----------------+
               |                |
       Rational polynomial      |
            cl_UP_RA            |
     <cln/univpoly_rational.h>  |
                                |
               +----------------+
               |
       Integer polynomial
            cl_UP_I
     <cln/univpoly_integer.h>

Univariate polynomial rings are constructed using the functions

`cl_univpoly_ring find_univpoly_ring (const cl_ring& R)`
`cl_univpoly_ring find_univpoly_ring (const cl_ring& R, const cl_symbol& varname)`

  This function returns the polynomial ring ``R[X]'`, unnamed or named. `R` may be an arbitrary ring. This function takes care of finding out about special cases of `R`, such as the rings of complex numbers, real numbers, rational numbers, integers, or modular integer rings. There is a cache table of rings, indexed by `R` and `varname`. This ensures that two calls of this function with the same arguments will return the same polynomial ring.

`cl_univpoly_complex_ring find_univpoly_ring (const cl_complex_ring& R)`
`cl_univpoly_complex_ring find_univpoly_ring (const cl_complex_ring& R, const cl_symbol& varname)`
`cl_univpoly_real_ring find_univpoly_ring (const cl_real_ring& R)`
`cl_univpoly_real_ring find_univpoly_ring (const cl_real_ring& R, const cl_symbol& varname)`
`cl_univpoly_rational_ring find_univpoly_ring (const cl_rational_ring& R)`
`cl_univpoly_rational_ring find_univpoly_ring (const cl_rational_ring& R, const cl_symbol& varname)`
`cl_univpoly_integer_ring find_univpoly_ring (const cl_integer_ring& R)`
`cl_univpoly_integer_ring find_univpoly_ring (const cl_integer_ring& R, const cl_symbol& varname)`
`cl_univpoly_modint_ring find_univpoly_ring (const cl_modint_ring& R)`
`cl_univpoly_modint_ring find_univpoly_ring (const cl_modint_ring& R, const cl_symbol& varname)`

  These functions are equivalent to the general `find_univpoly_ring`, only the return type is more specific, according to the base ring's type.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 9.2 Functions on univariate polynomials

Given a univariate polynomial ring `R`, the following members can be used.

`cl_ring R->basering()`

  This returns the base ring, as passed to ``find_univpoly_ring'`.

`cl_UP R->zero()`

  This returns `0 in R`, a polynomial of degree -1.

`cl_UP R->one()`

  This returns `1 in R`, a polynomial of degree == 0.

`cl_UP R->canonhom (const cl_I& x)`

  This returns `x in R`, a polynomial of degree <= 0.

`cl_UP R->monomial (const cl_ring_element& x, uintL e)`

  This returns a sparse polynomial: `x * X^e`, where `X` is the indeterminate.

`cl_UP R->create (sintL degree)`

  Creates a new polynomial with a given degree. The zero polynomial has degree `-1`. After creating the polynomial, you should put in the coefficients, using the `set_coeff` member function, and then call the `finalize` member function.

The following are the only destructive operations on univariate polynomials.

`void set_coeff (cl_UP& x, uintL index, const cl_ring_element& y)`

  This changes the coefficient of `X^index` in `x` to be `y`. After changing a polynomial and before applying any "normal" operation on it, you should call its `finalize` member function.

`void finalize (cl_UP& x)`

  This function marks the endpoint of destructive modifications of a polynomial. It normalizes the internal representation so that subsequent computations have less overhead. Doing normal computations on unnormalized polynomials may produce wrong results or crash the program.

The following operations are defined on univariate polynomials.

`cl_univpoly_ring x.ring ()`

  Returns the ring to which the univariate polynomial `x` belongs.

`cl_UP operator+ (const cl_UP&, const cl_UP&)`

  Returns the sum of two univariate polynomials.

`cl_UP operator- (const cl_UP&, const cl_UP&)`

  Returns the difference of two univariate polynomials.

`cl_UP operator- (const cl_UP&)`

  Returns the negative of a univariate polynomial.

`cl_UP operator* (const cl_UP&, const cl_UP&)`

  Returns the product of two univariate polynomials. One of the arguments may also be a plain integer or an element of the base ring.

`cl_UP square (const cl_UP&)`

  Returns the square of a univariate polynomial.

`cl_UP expt_pos (const cl_UP& x, const cl_I& y)`

  `y` must be > 0. Returns `x^y`.

`bool operator== (const cl_UP&, const cl_UP&)`
`bool operator!= (const cl_UP&, const cl_UP&)`

  Compares two univariate polynomials, belonging to the same univariate polynomial ring, for equality.

`bool zerop (const cl_UP& x)`

  Returns true if `x` is `0 in R`.

`sintL degree (const cl_UP& x)`

  Returns the degree of the polynomial. The zero polynomial has degree `-1`.

`sintL ldegree (const cl_UP& x)`

  Returns the low degree of the polynomial. This is the degree of the first non-vanishing polynomial coefficient. The zero polynomial has ldegree `-1`.

`cl_ring_element coeff (const cl_UP& x, uintL index)`

  Returns the coefficient of `X^index` in the polynomial `x`.

`cl_ring_element x (const cl_ring_element& y)`

  Evaluation: If `x` is a polynomial and `y` belongs to the base ring, then ``x(y)'` returns the value of the substitution of `y` into `x`.

`cl_UP deriv (const cl_UP& x)`

  Returns the derivative of the polynomial `x` with respect to the indeterminate `X`.

The following output functions are defined (see also the chapter on input/output).

`void fprint (std::ostream& stream, const cl_UP& x)`
`std::ostream& operator<< (std::ostream& stream, const cl_UP& x)`

  Prints the univariate polynomial `x` on the `stream`. The output may depend on the global printer settings in the variable `default_print_flags`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 9.3 Special polynomials

The following functions return special polynomials.

`cl_UP_I tschebychev (sintL n)`

  Returns the n-th Chebyshev polynomial (n >= 0).

`cl_UP_I hermite (sintL n)`

  Returns the n-th Hermite polynomial (n >= 0).

`cl_UP_RA legendre (sintL n)`

  Returns the n-th Legendre polynomial (n >= 0).

`cl_UP_I laguerre (sintL n)`

  Returns the n-th Laguerre polynomial (n >= 0).

Information how to derive the differential equation satisfied by each of these polynomials from their definition can be found in the `doc/polynomial/` directory.

[ << ] | [ >> ] |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by Richard B. Kreckel on April, 5 2008 using texi2html 1.76.