Toggle navigation
Egison
Documentations
Try It Out
Online Tools
Online Egison Interpreter
Online Egison Tutorial
Online Demonstrations
Poker Hands
Mahjong
Prime Numbers
Trees
Graph (Bellman-Ford Algorithm)
Randomized 3-SAT
Time-Series Data
Math
Blog
Community
Quadratic Equation
Nov 17 2016
def quadraticFormula := qF def qF f x := match coefficients f x as list mathExpr with | [$a_0, $a_1, $a_2] -> qF' a_2 a_1 a_0 def qF' a b c := match (a, b, c) as (mathExpr, mathExpr, mathExpr) with | (#1, #0, _) -> (sqrt (- c), - sqrt (- c)) | (#1, _, _) -> (2)#((- (b / 2)) + %1, (- (b / 2)) + %2) (withSymbols [x, y] qF (substitute [(x, y - b / 2)] (x ^ 2 + b * x + c)) y) | (_, _, _) -> qF' 1 (b / a) (c / a) qF (x ^ 2 + x + 1) x -- ((-1 + i * sqrt 3) / 2, (-1 - i * sqrt 3) / 2) qF (x ^ 2 + b * x + c) x -- ((- b + sqrt (b^2 - 4 * c)) / 2, (- b - sqrt (b^2 - 4 * c)) / 2) qF (a * x ^ 2 + b * x + c) x -- ((- b + sqrt (b^2 - 4 * a * c)) / (2 * a), (- b - sqrt (b^2 - 4 * a * c)) / (2 * a)) qF (a * x ^ 2 + 2 * b * x + c) x -- ((- b + sqrt (b^2 - a * c)) / a, (- b - sqrt (b^2 - a * c)) / a)
Links
Back to the Table of Contents
This website in other langauge:
English
,
日本語