=begin
= Polynomials

== GSL::Poly Class

=== Singleton methods
--- GSL::Poly::new(c0, c1, c2, ....)
    This creates an instance of the (({GSL::Poly})) class, 
    which represents a polynomial
        c0 + c1 x + c2 x^2 + ....

    * ex: x^2 - 3 x + 2 = 0
        poly = GSL::Poly::new([2, -3, 1])

--- GSL::Poly::complex_solve(c0, c1, c2, ....)
--- GSL::Poly::solve(c0, c1, c2, ....)
    These methods find the complex roots of the polynomial equation,
      c0 + c1 z + c2 z^2 + .... = 0

    * ex: z^2 - 3 z + 2 = 0
        z = Poly::solve([2, -3, 1])
        printf("%f %f\n", z[0].re, z[0].im)     <----- 1.000000 0.000000
        printf("%f %f\n", z[1].re, z[1].im)     <----- 2.000000 0.000000

=== Instance Methods
--- GSL::Poly#eval(x)
    This method evaluates the polynomial 
    c[0] + c[1] x + c[2] x^2 + ... + c[len-1] x^{len-1} 
    using Horner's method for stability. 

--- GSL::Poly#complex_solve
--- GSL::Poly#solve
    These methods find the complex roots of the quadratic equation,
      c0 + c1 z + c2 z^2 + .... = 0

    * ex: z^2 - 3 z + 2 = 0:
        poly = Poly::new([2, -3, 1])    
        z = poly.solve
        printf("%f %f\n", z[0].re, z[0].im)     <----- 1.000000 0.000000
        printf("%f %f\n", z[1].re, z[1].im)     <----- 2.000000 0.000000

== Quadratic and Cubic Equations
Ruby/GSL provides simple methods to solve quadratic or cubic equations, 
by just giving three coefficients, without creating (({GSL::Poly})) objects.

=== Quadratic Equations
--- GSL::Poly::solve_quadratic(a, b, c)
--- GSL::Poly::solve_quadratic([a, b, c])
    These methods find the real roots of the quadratic equation,
      a x^2 + b x + c = 0
    The coefficients are given by 3 numbers or a Ruby array, 
    or a (({GSL::Vector})) object. The roots are returned as a Ruby array.

    Note that the order of the arguments are the same as the GSL function
    (({gsl_poly_solve_quadratic})), different from those of the 
    class methods (({GSL::Poly::new})) and (({GSL::Poly::solve})).

    * ex: x^2 - 3x + 2 = 0
          p Poly::solve_quadratic([1, -3, 2])    <----- [-2.0, -1.0]
          p Poly::solve_quadratic(1, -3, 2)      <----- [-2.0, -1.0]

--- GSL::Poly::complex_solve_quadratic(a, b, c)
--- GSL::Poly::complex_solve_quadratic([a, b, c])
    These methods find the complex roots of the quadratic equation,
      a z^2 + b z + z = 0
    The coefficients are given by 3 numbers or a Ruby array, or a 
    (({GSL::Vector})).
    The roots are returned as a Ruby array of elements of two 
    (({GSL::Complex})) objects.
    
    * ex: z^2 - 3z + 2 = 0
          z = Poly::complex_solve_quadratic([1, -3, 2])    
          printf("%f %f\n", z[0].re, z[0].im)     <----- 1.000000 0.000000
          printf("%f %f\n", z[1].re, z[1].im)     <----- 2.000000 0.000000

=== Cubic Equations
--- GSL::Poly::solve_cubic(same as solve_quadratic)
    These method find the real roots of the cubic equation,
      x^3 + a x^2 + b x + c = 0

--- GSL::Poly::complex_solve_cubic(same as solve_cubic)
    These method find the complex roots of the cubic equation,
      z^3 + a z^2 + b z + c = 0


--- GSL::Poly::dd_init(xa, ya)
--- GSL::Poly::DividedDifferenceRepresentation#eval(x)
--- GSL::Poly::DividedDifferenceRepresentation#taylor(xp)

== Extensions
--- GSL::Poly#conv
--- GSL::Poly#deconv
--- GSL::Poly#reduce
--- GSL::Poly#deriv
--- GSL::Poly#integ

((<back|URL:index.html>))
=end

