Portability | GHC |
---|---|
Stability | stable |
Maintainer | joejev@gmail.org |
Safe Haskell | Safe-Inferred |
WARNING: The internal workings of solve. These functions use error, and should only be called directly if you know the type of the equation ahead of time. For example, solveLinear will try to resolve a GeneralEquation into a linear one if possible, but if you pass a GeneralEquation of a parabolic form, then it will error.
- data Equation
- data Solution
- = ZxZ
- | NoSolutions
- | SolutionSet [(Z, Z)]
- type Z = Integer
- mergeSolutions :: Solution -> Solution -> Solution
- specializeEquation :: Equation -> Equation
- solveLinear :: Equation -> Solution
- solveSimpleHyperbolic :: Equation -> Solution
- solveEliptical :: Equation -> Solution
- solveParabolic :: Equation -> Solution
Data
A way to setup an equation in the form of:
ax^2 + bxy + cy^2 + dx + ey + f = 0
GeneralEquation Z Z Z Z Z Z | A general quadratic diophantine equation. |
LinearEquation Z Z Z | dx + ey + f = 0 |
SimpleHyperbolicEquation Z Z Z Z | bxy + dx +ey + f = 0 |
ElipticalEquation Z Z Z Z Z Z | Eliptical equations. |
ParabolicEquation Z Z Z Z Z Z | Parabolic equations. |
HyperbolicEquation Z Z Z Z Z Z | Hyperbolic equations. |
The results of attempting to solve an Equation
.
ZxZ | All Integer pairs satisfy the equation. |
NoSolutions | For all (x,y) in ZxZ |
SolutionSet [(Z, Z)] | The set of pairs (x,y) that satisfy the equation. These are not in any particular order, and may contain duplicates. |
Equation Solving
specializeEquation :: Equation -> EquationSource
Detirmines what kind of equation form a GeneralEquation
fits.
If you pass a non GeneralEquation
to this function, it is the same as id.
solveLinear :: Equation -> SolutionSource
Solves for Equation
s in the form of dx + ey + f = 0
solveSimpleHyperbolic :: Equation -> SolutionSource
Solves for Equation
s in the form of bxy + dx + ey + f = 0
solveEliptical :: Equation -> SolutionSource
Solves for Equation
s in the form of ax^2 + bxy + cy^2 + dx + ey + f = 0
when b^2 - 4ac < 0
solveParabolic :: Equation -> SolutionSource
Solves for Equation
s in the form of ax^2 + bxy + cy^2 + dx + ey + f = 0
when b^2 - 4ac = 0