Further routines

### Further routines

If we use the standard routine init, then we get an empty POLYNOM, which means, that the self is the NULL pointer and the next part is also NULL:
• NAME: init_polynom
• SYNOPSIS: INT init_polynom(OP result)
• DESCRIPTION: the result becomes a POLYNOMobject, which is a LISTobject, with NULL as next and NULL as self
But note that the example
```main()
{
OP c;
anfang();
c =callocobject();
init(POLYNOM,c);
println(s_po_s(c));
freeall(c);
ende();
}
```
produces an error, because the self part is not yet initialised.

If you want to get a TeX-readable output of a polynom, then the standard routine tex() calls the special routine tex_polynom() which numbers the variables of the POLYNOMobject by a,b,c,....

• NAME: tex_polynom
• SYNOPSIS: INT tex_polynom(OP a)
• DESCRIPTION: Provides a TeX-readable output of the POLYNOMobject, if the coefficient is not unity it calls tex() for the coefficient, then it prints the variables named a,b,c,... In general you should use the standard routine tex, and not the special routine tex_polynom.
The degree of a single-variable polynomial can be evaluated by
• NAME: degree_polynom
• SYNOPSIS: INT degree_polynom(OP a,b)
The evaluation of a POLYNOM at a given value of the variables can be done as follows:
• NAME: eval_polynom
• SYNOPSIS: INT eval_polynom(OP a,b,c)
• DESCRIPTION: you enter a POLYNOMobject a, and a VECTORobject b, where the ith entry of the VECTORobject b gives the value for the specialization of the ith variable. If the ith entry is an empty object, you don't specialize the ith variable. The output will be in c.
You can also evaluate Gaussian polynomials:
• NAME: gauss_polynom
• SYNOPSIS: INT gauss_polynom(a,b,c)
• DESCRIPTION:
It is a well known fact, that for n given values at n given points, there is exactly one polynomial in one variable of degree n-1 with these values at these points, it is the so called Lagrange polynomial.
• NAME: lagrange_polynom
• SYNOPSIS: INT lagrange_polynom(OP a,b,c)
• DESCRIPTION: This routine computes the Lagrange polynomial which interpolates at the points in the VECTORobject a (which must be pairwise different), with the values in the VECTOR object b, which must be of the same length as a. The result is a POLYNOMobject c in one variable.
Example:
```#include "def.h"
#include "macro.h"
main()
{
OP a,b,c;
anfang();
a=callocobject(); b=callocobject(); c=callocobject();
m_il_v(2L,a);
m_i_i(1L, s_v_i(a,0L));
m_i_i(7L, s_v_i(a,1L));
m_il_v(2L,b);
m_i_i(5L, s_v_i(b,0L));
m_i_i(7L, s_v_i(b,1L));
lagrange_polynom(a,b,c);println(c);
freeall(a); freeall(b); freeall(c);
ende();
}
```
In order easily to build monomials we have the following routine which allows to build polynomials like a + b + c+...:
• NAME: m_iindex_monom
• SYNOPSIS: INT m_iindex_monom(INT i; OP erg)
• DESCRIPTION: It builds a POLYNOMobject consisting of a single monomial which is the ith variable. At first it frees the result to an empty object. There is a check whether i³0.
• RETURN: ERROR if an error occurs, OK else.
Example:
```...
{
OP a,b;
INT i;
anfang();
a=callocobject(); b=callocobject();
for (i=0L; i<= 10L; i++)
{
mult(a,a,b); println(b);
}
freeall(a); freeall(b);
ende();
}
...
```
This routine is a special case of the following one: which allows you to generate the polynomial aiex:
• NAME: m_iindex_iexponent_monom
• SYNOPSIS:
INT m_iindex_iexponent_monom(INT i,ex; OP erg)
• DESCRIPTION: builds a POLYNOMobject consisting of a single monomial which is the ith variable, and the exponent of this variable is given by ex. First it frees the result to an empty object. There is a check whether i³0.
• RETURN: ERROR if an error occurs, OK else.
A routine that transforms an object into the constant term of a polynomial consisting of this term only:
• NAME: m_scalar_polynom
• SYNOPSIS: INT m_scalar_polynom(OP a,b)
• DESCRIPTION: a is a scalar object, b becomes the result, again a POLYNOMobject. a becomes the coefficent of the POLYNOMobject with one single monomial, namely the monomial [0], i.e. a single variable, whose exponent is zero.
The product of polynomials on different alphabets:
• NAME: mult_disjunkt_polynom_polynom
• SYNOPSIS:
INT mult_disjunkt_polynom_polynom(OP a,b,c)
• DESCRIPTION: a and b are POLYNOMobjects and c becomes the result of the multiplication of a and b, where the alphabets of the two POLYNOMobjects are taken different
Example: The following example program reads a POLYNOMobject and multiplies it with itself, assumming the two alphabets to be different
```#include "def.h"
#include "macro.h"
main()
{
OP b,d;
anfang();
b=callocobject();
d=callocobject();
scan(POLYNOM,b);
mult_disjunkt_polynom_polynom(b,b,d);
println(d);
freeall(b); freeall(d);
ende();
}
```
The next routine allows the so-called Pólya-substitution (in two variables):
• NAME: polya_sub
• SYNOPSIS: INT polya_sub(OP a,b,c)
• DESCRIPTION: a is a POLYNOMobject, b becomes the result, again a POLYNOMobject, c is an INTEGERobject, which gives the number of different variables in a. There is the substitution: xi is replaced by 1 + qi, and so the result is a POLYNOMobject in one variable.
Example: The following example program computes the Pólya-substitution in a Schur polynomial (see the file ex21.c, a Pólya-substitution into cycle indicator polynomials can be found in ex20.c):
```#include "def.h"
#include "macro.h"
main()
{
OP a,b,c,d;
anfang();
a=callocobject(); b=callocobject();
c=callocobject(); d=callocobject();
scan(PARTITION,a);println(a);
scan(INTEGER,b);println(b);
compute_schur_with_alphabet(a,b,c);println(c);
polya_sub(c,b,d); println(d);
freeall(a); freeall(b); freeall(c); freeall(d);
ende();
}
```
There is also a routine that does Pólya-substitution in a prescribable number of indeterminates:
• NAME: polya_n_sub
• SYNOPSIS: INT polya_n_sub(OP pol,n,res)
• DESCRIPTION: pol is a POLYNOMobject, res becomes the result, again a POLYNOMobject, n is an INTEGERobject, which gives the number of different indeterminates for the substitution into pol. Here is the substitution: xi is replaced by the polynomial ai+bi+..., and so the result is a POLYNOMobject in the n indeterminates a,b,....
Here is a test of the implementation of POLYNOMobjects:
• NAME: test_poly
• SYNOPSIS: INT test_poly()
• DESCRIPTION:
A routine for the test on unimodality (of a polynomial in a single variable):
• NAME: unimodalp
• SYNOPSIS: INT unimodalp(OP a)
• DESCRIPTION: tests unimodality of a POLYNOMobject
• RETURN: TRUE or FALSE

harald.fripertinger@kfunigraz.ac.at,
last changed: November 19, 2001

 Further routines