5. pygsl.poly
Polynomials

Wrapper over the functions as described in Chaper 6 of the GNU Scientific Libraryreference manual.

There are routines for finding real and complex roots of quadratic and cubic equations using analytic methods. An iterative polynomial solver is also available for finding the roots of general polynomials with real coefficients (of any order).

eval( c, a)
evaluate the equation $ c[0] + c[1] x + c[2] x^2 + \dots + c[len-1] x^{len-1}$ using Horner's method for stability at x. ``len'' is the number of coefficients (equal to the length of the python object)

class dd( xa,ya)
This class computes a divided-difference representation of the interpolating polynomial for the points (xa, ya).

get_dd( )
Get the devided-difference representation

eval( x)
evaluate the representation at x

taylor( x)
convert the internal representation to a Taylor expansion

solve_quadratic( a,b,c)
computes the real roots of the equation $ \var{a} \cdot x^2 + \var{b} \cdot x + \var{c} = 0$ all variables are real varibales using a ``C double type'' for internal representation. returns the number of roots and their value.

complex_solve_quadratic( a,b,c)
computes the complex roots of the equation $ \var{a} \cdot x^2 + \var{b} \cdot x + \var{c} = 0$ . all variables are complex varibales. Returns the number of roots and their value.

solve_cubic( a,b,c)
computes the real roots of the equation $ x^3 + \var{a} \cdot x^2 + \var{b} \cdot x + \var{c} = 0$ . All variables are real varibales using a ``C double type'' for internal representation. Returns the number of roots and their value.

complex_solve_cubic( a,b,c)
computes the complex roots of the equation $ x^3 + \var{a} \cdot x^2 + \var{b} \cdot x + \var{c} = 0$ . all variables are complex variables. returns the number of roots and their value.

class poly_complex( n)
intialise the class giving the dimension of the problem
solve( a)
This method computes the roots of the general polynomial $ P(x) = a_0 + a_1 x + a_2 x^2 + ... + a_{n-1} x^{n-1}$ using balanced-QR reduction of the companion matrix. The parameter n specifies the length of the coefficient array. The coefficient of the highest order term must be non-zero. The n-1 roots are returned in a complex array.

The method raises GSL_EFAILED if the QR reduction does not converge.