module Sequation: sig .. end
Solving non-linear equations.
This module is still in development.
Author(s): Maxence Guesdon
Version: 0.13

Equations.Non_linear
type solution = [ `Complex of Complex.t | `Real of float ]
val print_check : (string -> unit) Pervasives.ref
This variable is used to store a print function used
to print checks on results. Default does nothing.
val solve_deg_2 : float * float * float -> solution * solution
Solving (a X^2 + b X + c = 0.0)
Returns the two solutions
The following assertions hold:
solve_deg_2 (1.0,-2.0,1.0) = (`Real 1.0, `Real 1.0)
val solve_deg_3 : float * float * float * float ->
solution * solution * solution
Solving (a X^3 + b X^2 + c X + d = 0.0)
Returns the three solutions
The following assertions hold:
Sequation.solve_deg_3 (1.0,-2.0,-1.0,2.0) =
(`Real 2.0, `Real (-1.0), `Real 1.0)
Sequation.solve_deg_3 (1.0,-6.0,11.0,-6.0) =
(`Real 3.0, `Real 1.0, `Real 2.0)
Sequation.solve_deg_3 (1.0,-2.0,1.,-2.) =
(`Real 2.0,
`Complex { Complex.re = 0.0; im = 1.0 },
`Complex { Complex.re = 0.0; im = -1.0 })
val solve_deg_4 : ?imeps:float ->
?compeps:float ->
float * float * float * float * float ->
solution * solution * solution *
solution
Solving (a X^4 + b X^3 + c X^2 + d X + e = 0.0)
Returns the four solutions
The following assertions hold:
Sequation.solve_deg_4 (1.0, -5.0, 5.0, 5.0, -6.) =
(`Real 2.0, `Real 3.0, `Real 1.0, `Real (-1.0))
Sequation.solve_deg_4 (1.0, -1., 0.3575, -0.053, 0.002625) =
(`Real 0.35, `Real 0.30, `Real 0.25, `Real 0.10)
imeps : (for imaginary epsilon); by default it is
0.000001 and is used to consider that a solution is
real if the imaginary part of the solution is between
- imeps and +imeps.
compeps : (for comparison epsilon); by default it is
0.00000000001 and is used to consider that a number is
0.0 if it is between - compeps and +compeps. It is used
in two comparisons depending on the form of the equation.