# MPSolve input format

## Polynomial format

The MPSolve input file should contain:

• Some optional comment lines starting with "!":
for instance:
! This is the Wilkinson polynomial of degree n
! defined by p(x)=(x-1)(x-2)...(x-n)
• Three characters related to the nature of the input polynomial:
• the first character can take the values:
• d  for dense polynomial
• s  for sparse polynomial
• u  for user polynomial
• the second character can take the values:
• r  for real coefficients
• c  for complex coefficients
• the third character can take the values
• i  for integer coefficients
• q  for rational coefficients
• f for float coefficients

For instance, "dri" stands for a dense real polynomial with integer coefficients.

• The precision of the coefficients in decimal digits, where 0 denotes the infinite precision typical of integer and rational coefficients.
• The degree of the polynomial, as an integer.
• The list of coefficients, i.e.,
• the list of all coefficients arranged in increasing degree, for polynomials coded as dense;
• the number of nonzero coefficient followed by their list given as degree and coefficient, for polynomials coded as sparse.

### Examples:

The polynomial x4 + 2 x + 5 can be coded as follows (extra spaces are ignored):

 in dense form or in sparse form ! p(x)=x^4+2x+5 dri 0 4 5 2 0 0 1 ! p(x)=x^4+2x+5 sri 0 4 3 0 5 1 2 4 1

Clearly, polynomials like x500 + 1 are more easily written in their sparse form as follows:

! p(x)=x^500+1
sri
0
500
2
0
1
500
1

## Coefficient formats

Integer coefficients of any length can be used such as real coefficients in scientific format.

Complex values are coded as the real part followed the imaginary part.

Rational numbers are written as the numerator followed by the denominator.

Complex numbers with rational real and imaginary parts are coded as a quadruples as follows:

• numerator of the real part
• denominator of the real part
• numerator of the imaginary part
• denominator of the imaginary part.

### Examples:

Below we report some examples of input formats where the coefficients are:

• complex integer (Gaussian) numbers,

! Example 1, complex/integer
! p(x)=x^200+(1+3i)x^70 +1
sci
0
200
3

0
1
0
70
1
3
200
1
0

• real rational numbers,

! Example 2, real/rational
! p(x)=(3/4)x^200 + (1/3)x^70 + 1
srq
0
200
3

0
1
1
70
1
3
200
3
4

• complex rational numbers (extra blank lines  are skipped),

! Example 3, complex/rational
! p(x)=x^2 + (3/2+i*5/7)x + 2
dcq
0
2

2
1
0
1

3
2
5
7

1
1
0
1

• real floating point numbers

! Example 4, real/float
! p(x)=1.234e200 x^3 + 1.5e-200 x^2 + 1.3e-200
! the precision of the coefficients is 15 digits
drf
15
3

1.3e-200
0.0e0
1.5e-200
1.234e200

any other mix is allowed and the input form follows the above lines.

Many coding examples can be found among the test suite.

home