Skip to content

Instantly share code, notes, and snippets.

@rbtbr
Created November 26, 2009 09:27
Show Gist options
  • Save rbtbr/243360 to your computer and use it in GitHub Desktop.
Save rbtbr/243360 to your computer and use it in GitHub Desktop.
Haskell Quadratic Equation
-- ax^2 + bx + c = 0
qEquation :: (Float, Float, Float) -> (Float, Float)
qEquation (a, b, c) = (x1, x2)
where
x1 = e + sqrt d / (2 * a)
x2 = e - sqrt d / (2 * a)
d = b * b - 4 * a * c
e = - b / (2 * a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment