| Alternative 1 | |
|---|---|
| Error | 2.8 |
| Cost | 53568 |
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
:precision binary64
(+
(* -1.0 (/ c b))
(+
(* -1.0 (/ (* a (pow c 2.0)) (pow b 3.0)))
(+
(* -2.0 (/ (* (pow c 3.0) (pow a 2.0)) (pow b 5.0)))
(* -0.25 (/ (/ (* (pow a 3.0) (* (pow c 4.0) 20.0)) (pow b 6.0)) b))))))double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
double code(double a, double b, double c) {
return (-1.0 * (c / b)) + ((-1.0 * ((a * pow(c, 2.0)) / pow(b, 3.0))) + ((-2.0 * ((pow(c, 3.0) * pow(a, 2.0)) / pow(b, 5.0))) + (-0.25 * (((pow(a, 3.0) * (pow(c, 4.0) * 20.0)) / pow(b, 6.0)) / b))));
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = ((-1.0d0) * (c / b)) + (((-1.0d0) * ((a * (c ** 2.0d0)) / (b ** 3.0d0))) + (((-2.0d0) * (((c ** 3.0d0) * (a ** 2.0d0)) / (b ** 5.0d0))) + ((-0.25d0) * ((((a ** 3.0d0) * ((c ** 4.0d0) * 20.0d0)) / (b ** 6.0d0)) / b))))
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
public static double code(double a, double b, double c) {
return (-1.0 * (c / b)) + ((-1.0 * ((a * Math.pow(c, 2.0)) / Math.pow(b, 3.0))) + ((-2.0 * ((Math.pow(c, 3.0) * Math.pow(a, 2.0)) / Math.pow(b, 5.0))) + (-0.25 * (((Math.pow(a, 3.0) * (Math.pow(c, 4.0) * 20.0)) / Math.pow(b, 6.0)) / b))));
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
def code(a, b, c): return (-1.0 * (c / b)) + ((-1.0 * ((a * math.pow(c, 2.0)) / math.pow(b, 3.0))) + ((-2.0 * ((math.pow(c, 3.0) * math.pow(a, 2.0)) / math.pow(b, 5.0))) + (-0.25 * (((math.pow(a, 3.0) * (math.pow(c, 4.0) * 20.0)) / math.pow(b, 6.0)) / b))))
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function code(a, b, c) return Float64(Float64(-1.0 * Float64(c / b)) + Float64(Float64(-1.0 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0))) + Float64(Float64(-2.0 * Float64(Float64((c ^ 3.0) * (a ^ 2.0)) / (b ^ 5.0))) + Float64(-0.25 * Float64(Float64(Float64((a ^ 3.0) * Float64((c ^ 4.0) * 20.0)) / (b ^ 6.0)) / b))))) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
function tmp = code(a, b, c) tmp = (-1.0 * (c / b)) + ((-1.0 * ((a * (c ^ 2.0)) / (b ^ 3.0))) + ((-2.0 * (((c ^ 3.0) * (a ^ 2.0)) / (b ^ 5.0))) + (-0.25 * ((((a ^ 3.0) * ((c ^ 4.0) * 20.0)) / (b ^ 6.0)) / b)))); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_] := N[(N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-2.0 * N[(N[(N[Power[c, 3.0], $MachinePrecision] * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(N[(N[(N[Power[a, 3.0], $MachinePrecision] * N[(N[Power[c, 4.0], $MachinePrecision] * 20.0), $MachinePrecision]), $MachinePrecision] / N[Power[b, 6.0], $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \left(-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + -0.25 \cdot \frac{\frac{{a}^{3} \cdot \left({c}^{4} \cdot 20\right)}{{b}^{6}}}{b}\right)\right)
Results
Initial program 44.1
Simplified44.1
[Start]44.1 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]44.1 | \[ \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}{2 \cdot a}
\] |
rational_best_oopsla_all_46_json_45_simplify-97 [=>]44.1 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \color{blue}{\left(0 - b\right)}}{2 \cdot a}
\] |
rational_best_oopsla_all_46_json_45_simplify-108 [=>]44.1 | \[ \frac{\color{blue}{\left(0 + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) - b}}{2 \cdot a}
\] |
rational_best_oopsla_all_46_json_45_simplify-35 [=>]44.1 | \[ \frac{\color{blue}{\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + 0\right)} - b}{2 \cdot a}
\] |
rational_best_oopsla_all_46_json_45_simplify-85 [=>]44.1 | \[ \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} - b}{2 \cdot a}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]44.1 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{\color{blue}{a \cdot 2}}
\] |
metadata-eval [<=]44.1 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a \cdot \color{blue}{\left(1 + 1\right)}}
\] |
metadata-eval [<=]44.1 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a \cdot \left(\color{blue}{\frac{4}{4}} + 1\right)}
\] |
metadata-eval [<=]44.1 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a \cdot \left(\frac{4}{4} + \color{blue}{\frac{4}{4}}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-23 [<=]44.1 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{\color{blue}{\frac{4}{4} \cdot a + a \cdot \frac{4}{4}}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]44.1 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{\color{blue}{a \cdot \frac{4}{4}} + a \cdot \frac{4}{4}}
\] |
metadata-eval [=>]44.1 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a \cdot \color{blue}{1} + a \cdot \frac{4}{4}}
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]44.1 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{\color{blue}{a} + a \cdot \frac{4}{4}}
\] |
metadata-eval [=>]44.1 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a + a \cdot \color{blue}{1}}
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]44.1 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a + \color{blue}{a}}
\] |
Taylor expanded in a around 0 2.8
Simplified2.8
[Start]2.8 | \[ -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(-1 \cdot \frac{c}{b} + \left(-0.25 \cdot \frac{{a}^{3} \cdot \left(16 \cdot \frac{{c}^{4}}{{b}^{6}} + {\left(-2 \cdot \frac{{c}^{2}}{{b}^{3}}\right)}^{2}\right)}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-82 [=>]2.8 | \[ \color{blue}{-1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(-0.25 \cdot \frac{{a}^{3} \cdot \left(16 \cdot \frac{{c}^{4}}{{b}^{6}} + {\left(-2 \cdot \frac{{c}^{2}}{{b}^{3}}\right)}^{2}\right)}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]2.8 | \[ -1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{\color{blue}{a \cdot {c}^{2}}}{{b}^{3}} + \left(-0.25 \cdot \frac{{a}^{3} \cdot \left(16 \cdot \frac{{c}^{4}}{{b}^{6}} + {\left(-2 \cdot \frac{{c}^{2}}{{b}^{3}}\right)}^{2}\right)}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-35 [=>]2.8 | \[ -1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \color{blue}{\left(-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + -0.25 \cdot \frac{{a}^{3} \cdot \left(16 \cdot \frac{{c}^{4}}{{b}^{6}} + {\left(-2 \cdot \frac{{c}^{2}}{{b}^{3}}\right)}^{2}\right)}{b}\right)}\right)
\] |
Taylor expanded in b around 0 2.8
Simplified2.8
[Start]2.8 | \[ -1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \left(-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + -0.25 \cdot \frac{\frac{\left(4 \cdot {c}^{4} + 16 \cdot {c}^{4}\right) \cdot {a}^{3}}{{b}^{6}}}{b}\right)\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]2.8 | \[ -1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \left(-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + -0.25 \cdot \frac{\frac{\color{blue}{{a}^{3} \cdot \left(4 \cdot {c}^{4} + 16 \cdot {c}^{4}\right)}}{{b}^{6}}}{b}\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]2.8 | \[ -1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \left(-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + -0.25 \cdot \frac{\frac{{a}^{3} \cdot \left(4 \cdot {c}^{4} + \color{blue}{{c}^{4} \cdot 16}\right)}{{b}^{6}}}{b}\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-23 [=>]2.8 | \[ -1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \left(-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + -0.25 \cdot \frac{\frac{{a}^{3} \cdot \color{blue}{\left({c}^{4} \cdot \left(4 + 16\right)\right)}}{{b}^{6}}}{b}\right)\right)
\] |
metadata-eval [=>]2.8 | \[ -1 \cdot \frac{c}{b} + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \left(-2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + -0.25 \cdot \frac{\frac{{a}^{3} \cdot \left({c}^{4} \cdot \color{blue}{20}\right)}{{b}^{6}}}{b}\right)\right)
\] |
Final simplification2.8
| Alternative 1 | |
|---|---|
| Error | 2.8 |
| Cost | 53568 |
| Alternative 2 | |
|---|---|
| Error | 3.8 |
| Cost | 33664 |
| Alternative 3 | |
|---|---|
| Error | 3.8 |
| Cost | 33536 |
| Alternative 4 | |
|---|---|
| Error | 10.5 |
| Cost | 14852 |
| Alternative 5 | |
|---|---|
| Error | 5.7 |
| Cost | 13632 |
| Alternative 6 | |
|---|---|
| Error | 11.8 |
| Cost | 256 |
herbie shell --seed 2023090
(FPCore (a b c)
:name "Quadratic roots, medium range"
:precision binary64
:pre (and (and (and (< 1.1102230246251565e-16 a) (< a 9007199254740992.0)) (and (< 1.1102230246251565e-16 b) (< b 9007199254740992.0))) (and (< 1.1102230246251565e-16 c) (< c 9007199254740992.0)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))