Copyright | Joe Jevnik 2013 |
---|---|
License | GPL-2 |
Maintainer | joejev@gmail.org |
Stability | stable |
Portability | GHC |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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 -> Equation Source
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 -> Solution Source
Solves for Equation
s in the form of dx + ey + f = 0
WARNING: This expects that the Equation
is actually a LinearEquation
;
it is safer to just call solve unless you have already verified that
the equation is linear.
solveSimpleHyperbolic :: Equation -> Solution Source
Solves for Equation
s in the form of bxy + dx + ey + f = 0
WARNING: This expects that the Equation
is actually a
SimpleHyperbolicEquation
; it is safer to just call solve unless you have
already verified that the equation is simple hyperbolic.
solveEliptical :: Equation -> Solution Source
Solves for Equation
s in the form of ax^2 + bxy + cy^2 + dx + ey + f = 0
when b^2 - 4ac < 0
WARNING: This expects that the Equation
is actually an ElipticalEquation
;
it is safer to just call solve unless you have already verified that the
equation is eliptical.
solveParabolic :: Equation -> Solution Source
Solves for Equation
s in the form of ax^2 + bxy + cy^2 + dx + ey + f = 0
when b^2 - 4ac = 0
WARNING: This expects that the Equation
is actually a ParabolicEquation
;
it is safer to just call solve unless you have already verified that the
equation is parabolic.