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
Cubic Equation
Nov 2 2016
def cubicFormula := cF def cF f x := match coefficients f x as list mathExpr with | [$a_0, $a_1, $a_2, $a_3] -> cF' a_3 a_2 a_1 a_0 def cF' a b c d := match (a, b, c, d) as (mathExpr, mathExpr, mathExpr, mathExpr) with | (#1, #0, $p, $q) -> let (s1, s2) := (2)#(rt 3 %1, rt 3 %2) (qF' 1 (27 * q) ((-27) * p ^ 3)) in ((s1 + s2) / 3, (w ^ 2 * s1 + w * s2) / 3, (w * s1 + w ^ 2 * s2) / 3) | (#1, _, _, _) -> (3)#(%1 - b / 3, %2 - b / 3, %3 - b / 3) (withSymbols [x, y] cF (substitute [(x, y - b / 3)] (x ^ 3 + b * x ^ 2 + c * x + d)) y) | (_, _, _, _) -> cF' 1 (b / a) (c / a) (d / a) def w := ((-1) + i * sqrt 3) / 2 (3)#%1 (cF (x ^ 3 + p * x + q) x) -- (rt 3 12 * rt 3 (-9 * q + sqrt 3 * sqrt (27 * q^2 + 4 * p^3)) + rt 3 12 * rt 3 (-9 * q - sqrt 3 * sqrt (27 * q^2 + 4 * p^3))) / 6 cF ((x - 1) * (x - 2) * (x - 3)) x -- (2, (- sqrt 3 * rt 3 (3 * sqrt 3) + 6) / 3, (sqrt 3 * rt 3 (3 * sqrt 3) + 6) / 3) (3)#%1 (cF (a * x ^ 3 + b * x ^ 2 + c * x + d) x) -- (rt 3 4 * rt 3 (-2 * b^3 + 9 * a * c * b - 27 * a^2 * d + 3 * a * sqrt 3 * sqrt (4 * d * b^3 - c^2 * b^2 - 18 * a * d * c * b + 27 * a^2 * d^2 + 4 * a * c^3)) + rt 3 4 * rt 3 (-2 * b^3 + 9 * a * c * b - 27 * a^2 * d - 3 * a * sqrt 3 * sqrt (4 * d * b^3 - c^2 * b^2 - 18 * a * d * c * b + 27 * a^2 * d^2 + 4 * a * c^3)) - 2 * b) / (6 * a)
Links
Back to the Table of Contents
This website in other langauge:
English
,
日本語