Search code examples
polynomial-mathparipari-gp

Polynomials in Pari


I have some problems dealing with polynomials in Pari and finding the right commands in the documentation.

  1. is it possible to define Polynomials with multiple variables, e.g. f(x,y)=x^2+y^2-1
  2. How can I evaluate a previously defined polynomial (by using Pol() ) at a specific value?

Solution

  • Yes it is possible to use polynomials with multiple variables. For example x^2 + y^2 - 1 is a polynomial in the variables x and y. Use subst to evaluate a polynomial at a specific value. For example, subst(x^2 + y^2 - 1, y, 3) gives x^2 + 8.

    PARI assumes any undefined variables are polynomials. The above works because x and y have not been given another definition. For this reason it is best to avoid using x and y for other things. For example if you enter x=5, then x is defined to be 5 and will no longer be interpreted as a polynomial.

    Now f(x,y)=x^2+y^2-1 is not a polynomial, but rather a function definition with two formal arguments x and y. You can call f with the polynomial arguments x and y to get a polynomial and can also call f with other arguments. For example, f(x,y) returns the polynomial x^2 + y^2 - 1 and f(x, 3) returns x^2 + 8.

    The purpose of Pol() is rather to convert something else such as a vector into a polynomial. For example, Pol([3,1,5]) gives 3*x^2 + x + 5.