| Alternative 1 | |
|---|---|
| Error | 1.9 |
| Cost | 33536 |
(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) (/ (* 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) + ((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) + ((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) + ((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) + ((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(Float64(c / b) + 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) + ((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[(N[(c / b), $MachinePrecision] + N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $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]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
-1 \cdot \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right) + \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)
Results
Initial program 52.6
Simplified52.6
[Start]52.6 | \[ \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 [=>]52.6 | \[ \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 [=>]52.6 | \[ \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 [=>]52.6 | \[ \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 [=>]52.6 | \[ \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 [=>]52.6 | \[ \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 [=>]52.6 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{\color{blue}{a \cdot 2}}
\] |
metadata-eval [<=]52.6 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a \cdot \color{blue}{\left(1 + 1\right)}}
\] |
metadata-eval [<=]52.6 | \[ \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 [<=]52.6 | \[ \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 [<=]52.6 | \[ \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 [<=]52.6 | \[ \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 [=>]52.6 | \[ \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 [=>]52.6 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{\color{blue}{a} + a \cdot \frac{4}{4}}
\] |
metadata-eval [=>]52.6 | \[ \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 [=>]52.6 | \[ \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a + \color{blue}{a}}
\] |
Taylor expanded in a around 0 1.4
Simplified1.4
[Start]1.4 | \[ -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-35 [=>]1.4 | \[ -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \color{blue}{\left(\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) + -1 \cdot \frac{c}{b}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-82 [=>]1.4 | \[ \color{blue}{\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) + \left(-1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + -1 \cdot \frac{c}{b}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-35 [=>]1.4 | \[ \color{blue}{\left(-1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + -1 \cdot \frac{c}{b}\right) + \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)}
\] |
Taylor expanded in b around 0 1.4
Simplified1.4
[Start]1.4 | \[ -1 \cdot \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right) + \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)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]1.4 | \[ -1 \cdot \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right) + \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)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]1.4 | \[ -1 \cdot \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right) + \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)
\] |
rational_best_oopsla_all_46_json_45_simplify-23 [=>]1.4 | \[ -1 \cdot \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right) + \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)
\] |
metadata-eval [=>]1.4 | \[ -1 \cdot \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right) + \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)
\] |
Final simplification1.4
| Alternative 1 | |
|---|---|
| Error | 1.9 |
| Cost | 33536 |
| Alternative 2 | |
|---|---|
| Error | 5.7 |
| Cost | 14852 |
| Alternative 3 | |
|---|---|
| Error | 2.9 |
| Cost | 13632 |
| Alternative 4 | |
|---|---|
| Error | 6.1 |
| Cost | 256 |
herbie shell --seed 2023090
(FPCore (a b c)
:name "Quadratic roots, wide range"
:precision binary64
:pre (and (and (and (< 4.930380657631324e-32 a) (< a 2.028240960365167e+31)) (and (< 4.930380657631324e-32 b) (< b 2.028240960365167e+31))) (and (< 4.930380657631324e-32 c) (< c 2.028240960365167e+31)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))