![]() | ![]() | ![]() | Exercise 1 - Usual operations over polynomials | Documentation and user's manual | Table of contents | OCaml programs |
Assume an Objective Caml toplevel in which the following modules (download an archive containing them) have been loaded and opened:
List_1 : to deal with lists.
Rat : provides the type rat to deal with rational numbers.
Rat_poly : provides the type rat_poly to deal with polynomials in one variable and whose coefficients are rational numbers.
Ex_rat_poly : provides some rat_poly values.
|
Name: eq_poly .
Type: rat_poly * rat_poly -> bool .
Tests two polynomials for equality.
|
|
Name: add_poly .
Type: rat_poly * rat_poly -> rat_poly .
Adds two polynomials.
|
|
Name: x_times .
Type: rat_poly -> rat_poly .
Multiply a polynomial by the monomial X.
|
|
Name: deriv_poly .
Type: rat_poly -> rat_poly .
Computes the derivative of a polynomial.
|
|
Name: rat_times_poly .
Type: rat * rat_poly -> rat_poly .
Computes the polynomial ap given the pair (a,p) where a is a rational and p is a polynomial.
|
|
Name: mult_poly .
Type: rat_poly * rat_poly -> rat_poly .
Multiplies two polynomials.
|
|
Name: degree .
Type: rat_poly -> int .
Computes the degree of a non-zero polynomial.
Fails if the polynomial is zero.
|
|
Name: leading_coef .
Type: rat_poly -> rat .
Computes the leading coefficient of a non-zero polynomial.
Fails if the polynomial is zero.
|
|
Name: monomial .
Type: rat * int -> rat_poly .
Computes the monomial aXd from a pair (a,d) where a is a non-zero rational and d is a non-negative integer.
Fails if a=0 or d<0.
|
|
Name: euclid_div_poly .
Type: rat_poly * rat_poly -> rat_poly * rat_poly .
Computes the pair (q,r) where q is the quotient and r is the remainder in the euclidean division of p1 by p2, given a pair (p1,p2) of polynomials where the divisor p2 is non-zero.
Fails if p2 is zero.
|
|
Name: quotient_poly .
Type: rat_poly * rat_poly -> rat_poly .
Computes the quotient in the euclidean division of p1 by p2, given a pair (p1,p2) of polynomials where the divisor p2 is non-zero.
Fails if p2 is zero.
|
|
Name: mod_poly .
Type: rat_poly * rat_poly -> rat_poly .
Computes the remainder in the euclidean division of p1 by p2, given a pair (p1,p2) of polynomials where the divisor p2 is non-zero.
Fails if p2 is zero.
|
|
Name: gcd_poly .
Type: rat_poly * rat_poly -> rat_poly .
Computes the gcd (greatest common divisor) of a pair of non-zero polynomials.
Fails if a component of the pair is zero.
|
|
Name: eval_poly .
Type: rat_poly * rat -> rat .
Evaluation of a polynomial.
|
|
Name: function_of_poly .
Type: rat_poly -> (rat -> rat) .
Computes the polynomial function associated with a polynomial.
|
|
Name: poly_of_coef_list .
Type: rat list -> rat_poly .
Computes the polynomial given a list of its coefficients ordered according to decreasing degrees (it is written a list rather than the list because this list can begin with useless zeros).
|
![]() | ![]() | ![]() | Exercise 1 - Usual operations over polynomials | Documentation and user's manual | Table of contents | OCaml programs |