# default format for [polynomials]

Some languages do not have native ways of representing polynomials, others do. Many times a list of coefficients (in one or the other order) works well. In order to avoid explicitly specifying this over and over again in all challenge, I'd like add that to the tag info.

• I'd avoid declaring a default format that needs to be looked up in the tag wiki or on meta. It should be clear from the challenge how I/O can be formatted. That said, having some guidance for the challenge author on what I/O formats to allow would certainly be helpful, much like the recent question on what outputs decision problems should allow. May 14 '17 at 17:09
• I'm usually for defaults, but I think polynomials are something challenge authors should specify the format for. Our defaults are generally for common programmatic elements (inputs, strings, graphics) to be clarified and standardized across languages. But polynomials are something most languages don't have a existing concept for, so a default would really be making a definition from scratch.
– xnor
May 14 '17 at 20:22
• @xnor I disagree, many languages (certainly algebraic or numerical langauges) do have built in polynomial types or at least packages that support them. May 14 '17 at 21:10
• @MartinEnder I think there are just a few accepted ways to represent a polynomial anyway, and I think (similarly as in code-golf or string or popularity-contest or quine) to define a default would give us a base to avoid repeating the definition over and over again, as we also do not explicitly say that we use characters to measure code length by default. May 14 '17 at 21:22

### List of coefficients

A list of coefficients

• in ascending order [a(0),a(1),a(2),...,a(n)] OR
• in descending order [a(n),a(n-1),...,a(0)]

If the degree is known, it may be zero padded as

[a(0),...,a(n),0,...,0]


or

[0,...,0,a(n),...,a(0)]

• And this 3*x^2*y+4*z; is it not a polynomial?
– user58988
May 16 '17 at 5:19
• Multivariable polynomials can be writen as polynomial in one variable with polynomials of the remaining variable as coefficients. May 16 '17 at 18:24

### Default representation in [language]

Many langauges, especially ones that include a CAS have native ways of representing polynomials.

## Beware function representations

Be careful about allowing a polynomial to be represented by a function that computes it, in languages where functions are objects. For example, in Python the polynomial 3*x^2+2 could be represented by the function object lambda x:3*x*x+2.

Take the challenge to compose polynomials. One could submit

(.)

where . is Haskell's function composition operator: if f and g are functions, then f.g is a function that takes x to f(g(x)). This would cut off the possibility for a much more interesting answer in the coefficient list representation.
lambda f,g:lambda x:f(g(x))

• Same goes for expressions representing the polynomial in languages with symbolic names, e.g. 3x^2+2 is a valid Mathematica expression that will remain unevaluated (unless it can be simplified). While not a function, it can be manipulated and evaluated quite easily. That said, most Mathematica answers would probably start by converting to this format first, so I'm not sure it's a bad thing to allow the expression right away. May 15 '17 at 9:04