| Alternative 1 | |
|---|---|
| Accuracy | 92.1% |
| Cost | 42052 |
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* c (* a -4.0))) (t_1 (sqrt (+ b (sqrt (fma b b t_0))))))
(if (<= (/ (- (sqrt (+ (* b b) t_0)) b) (* a 2.0)) -100.0)
(/ (/ (/ (- (* b b) (fma b b (* 4.0 (* a c)))) t_1) t_1) (* a 2.0))
(-
(-
(fma
-0.25
(* (/ (* a a) (pow b 7.0)) (* (/ a 0.05) (pow c 4.0)))
(/ (* (* a (* a -2.0)) (pow c 3.0)) (pow b 5.0)))
(/ c b))
(* a (* (/ c b) (/ c (* b 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) {
double t_0 = c * (a * -4.0);
double t_1 = sqrt((b + sqrt(fma(b, b, t_0))));
double tmp;
if (((sqrt(((b * b) + t_0)) - b) / (a * 2.0)) <= -100.0) {
tmp = ((((b * b) - fma(b, b, (4.0 * (a * c)))) / t_1) / t_1) / (a * 2.0);
} else {
tmp = (fma(-0.25, (((a * a) / pow(b, 7.0)) * ((a / 0.05) * pow(c, 4.0))), (((a * (a * -2.0)) * pow(c, 3.0)) / pow(b, 5.0))) - (c / b)) - (a * ((c / b) * (c / (b * b))));
}
return tmp;
}
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) t_0 = Float64(c * Float64(a * -4.0)) t_1 = sqrt(Float64(b + sqrt(fma(b, b, t_0)))) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) + t_0)) - b) / Float64(a * 2.0)) <= -100.0) tmp = Float64(Float64(Float64(Float64(Float64(b * b) - fma(b, b, Float64(4.0 * Float64(a * c)))) / t_1) / t_1) / Float64(a * 2.0)); else tmp = Float64(Float64(fma(-0.25, Float64(Float64(Float64(a * a) / (b ^ 7.0)) * Float64(Float64(a / 0.05) * (c ^ 4.0))), Float64(Float64(Float64(a * Float64(a * -2.0)) * (c ^ 3.0)) / (b ^ 5.0))) - Float64(c / b)) - Float64(a * Float64(Float64(c / b) * Float64(c / Float64(b * b))))); end return tmp 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_] := Block[{t$95$0 = N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(b + N[Sqrt[N[(b * b + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], -100.0], N[(N[(N[(N[(N[(b * b), $MachinePrecision] - N[(b * b + N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.25 * N[(N[(N[(a * a), $MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision] * N[(N[(a / 0.05), $MachinePrecision] * N[Power[c, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(a * N[(a * -2.0), $MachinePrecision]), $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision] - N[(a * N[(N[(c / b), $MachinePrecision] * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
t_0 := c \cdot \left(a \cdot -4\right)\\
t_1 := \sqrt{b + \sqrt{\mathsf{fma}\left(b, b, t_0\right)}}\\
\mathbf{if}\;\frac{\sqrt{b \cdot b + t_0} - b}{a \cdot 2} \leq -100:\\
\;\;\;\;\frac{\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 4 \cdot \left(a \cdot c\right)\right)}{t_1}}{t_1}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.25, \frac{a \cdot a}{{b}^{7}} \cdot \left(\frac{a}{0.05} \cdot {c}^{4}\right), \frac{\left(a \cdot \left(a \cdot -2\right)\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - a \cdot \left(\frac{c}{b} \cdot \frac{c}{b \cdot b}\right)\\
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) < -100Initial program 86.7%
Simplified86.7%
[Start]86.7 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\] |
|---|---|
*-commutative [=>]86.7 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}}
\] |
Applied egg-rr87.6%
[Start]86.7 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}
\] |
|---|---|
+-commutative [=>]86.7 | \[ \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}{a \cdot 2}
\] |
flip-+ [=>]86.7 | \[ \frac{\color{blue}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right) \cdot \left(-b\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right)}}}{a \cdot 2}
\] |
add-sqr-sqrt [=>]0.0 | \[ \frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right) \cdot \left(-b\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \color{blue}{\sqrt{-b} \cdot \sqrt{-b}}}}{a \cdot 2}
\] |
sqrt-unprod [=>]1.5 | \[ \frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right) \cdot \left(-b\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}}}}{a \cdot 2}
\] |
sqr-neg [=>]1.5 | \[ \frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right) \cdot \left(-b\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \sqrt{\color{blue}{b \cdot b}}}}{a \cdot 2}
\] |
sqrt-prod [=>]1.5 | \[ \frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right) \cdot \left(-b\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \color{blue}{\sqrt{b} \cdot \sqrt{b}}}}{a \cdot 2}
\] |
add-sqr-sqrt [<=]1.5 | \[ \frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right) \cdot \left(-b\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \color{blue}{b}}}{a \cdot 2}
\] |
unsub-neg [<=]1.5 | \[ \frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right) \cdot \left(-b\right)}{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}}{a \cdot 2}
\] |
+-commutative [<=]1.5 | \[ \frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right) \cdot \left(-b\right)}{\color{blue}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{a \cdot 2}
\] |
add-sqr-sqrt [=>]0.0 | \[ \frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right) \cdot \left(-b\right)}{\color{blue}{\sqrt{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}}{a \cdot 2}
\] |
associate-/r* [=>]0.0 | \[ \frac{\color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right) \cdot \left(-b\right)}{\sqrt{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{\sqrt{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}}{a \cdot 2}
\] |
if -100 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) Initial program 53.4%
Simplified53.4%
[Start]53.4 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\] |
|---|---|
*-commutative [=>]53.4 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}}
\] |
Taylor expanded in a around 0 92.3%
Simplified92.3%
[Start]92.3 | \[ -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)
\] |
|---|---|
+-commutative [=>]92.3 | \[ \color{blue}{\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) + -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}}
\] |
mul-1-neg [=>]92.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) + \color{blue}{\left(-\frac{{c}^{2} \cdot a}{{b}^{3}}\right)}
\] |
unsub-neg [=>]92.3 | \[ \color{blue}{\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) - \frac{{c}^{2} \cdot a}{{b}^{3}}}
\] |
Taylor expanded in b around 0 92.3%
Simplified92.3%
[Start]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \frac{{a}^{3} \cdot \left(4 \cdot {c}^{4} + 16 \cdot {c}^{4}\right)}{{b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
|---|---|
associate-/l* [=>]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \color{blue}{\frac{{a}^{3}}{\frac{{b}^{7}}{4 \cdot {c}^{4} + 16 \cdot {c}^{4}}}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
distribute-rgt-out [=>]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \frac{{a}^{3}}{\frac{{b}^{7}}{\color{blue}{{c}^{4} \cdot \left(4 + 16\right)}}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
metadata-eval [=>]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \frac{{a}^{3}}{\frac{{b}^{7}}{{c}^{4} \cdot \color{blue}{20}}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
Applied egg-rr92.3%
[Start]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \frac{{a}^{3}}{\frac{{b}^{7}}{{c}^{4} \cdot 20}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
|---|---|
unpow3 [=>]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \frac{{a}^{3}}{\frac{{b}^{7}}{{c}^{4} \cdot 20}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \frac{c \cdot c}{\color{blue}{\left(b \cdot b\right) \cdot b}} \cdot a
\] |
times-frac [=>]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \frac{{a}^{3}}{\frac{{b}^{7}}{{c}^{4} \cdot 20}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \color{blue}{\left(\frac{c}{b \cdot b} \cdot \frac{c}{b}\right)} \cdot a
\] |
Applied egg-rr92.3%
[Start]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \frac{{a}^{3}}{\frac{{b}^{7}}{{c}^{4} \cdot 20}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \left(\frac{c}{b \cdot b} \cdot \frac{c}{b}\right) \cdot a
\] |
|---|---|
unpow3 [=>]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \frac{\color{blue}{\left(a \cdot a\right) \cdot a}}{\frac{{b}^{7}}{{c}^{4} \cdot 20}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \left(\frac{c}{b \cdot b} \cdot \frac{c}{b}\right) \cdot a
\] |
div-inv [=>]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \frac{\left(a \cdot a\right) \cdot a}{\color{blue}{{b}^{7} \cdot \frac{1}{{c}^{4} \cdot 20}}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \left(\frac{c}{b \cdot b} \cdot \frac{c}{b}\right) \cdot a
\] |
times-frac [=>]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \color{blue}{\frac{a \cdot a}{{b}^{7}} \cdot \frac{a}{\frac{1}{{c}^{4} \cdot 20}}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \left(\frac{c}{b \cdot b} \cdot \frac{c}{b}\right) \cdot a
\] |
*-commutative [=>]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \frac{a \cdot a}{{b}^{7}} \cdot \frac{a}{\frac{1}{\color{blue}{20 \cdot {c}^{4}}}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \left(\frac{c}{b \cdot b} \cdot \frac{c}{b}\right) \cdot a
\] |
associate-/r* [=>]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \frac{a \cdot a}{{b}^{7}} \cdot \frac{a}{\color{blue}{\frac{\frac{1}{20}}{{c}^{4}}}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \left(\frac{c}{b \cdot b} \cdot \frac{c}{b}\right) \cdot a
\] |
associate-/r/ [=>]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \frac{a \cdot a}{{b}^{7}} \cdot \color{blue}{\left(\frac{a}{\frac{1}{20}} \cdot {c}^{4}\right)}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \left(\frac{c}{b \cdot b} \cdot \frac{c}{b}\right) \cdot a
\] |
metadata-eval [=>]92.3 | \[ \left(\mathsf{fma}\left(-0.25, \frac{a \cdot a}{{b}^{7}} \cdot \left(\frac{a}{\color{blue}{0.05}} \cdot {c}^{4}\right), \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \left(\frac{c}{b \cdot b} \cdot \frac{c}{b}\right) \cdot a
\] |
Final simplification92.0%
| Alternative 1 | |
|---|---|
| Accuracy | 92.1% |
| Cost | 42052 |
| Alternative 2 | |
|---|---|
| Accuracy | 89.2% |
| Cost | 28292 |
| Alternative 3 | |
|---|---|
| Accuracy | 89.0% |
| Cost | 28228 |
| Alternative 4 | |
|---|---|
| Accuracy | 88.8% |
| Cost | 21956 |
| Alternative 5 | |
|---|---|
| Accuracy | 85.1% |
| Cost | 21060 |
| Alternative 6 | |
|---|---|
| Accuracy | 85.1% |
| Cost | 21060 |
| Alternative 7 | |
|---|---|
| Accuracy | 85.1% |
| Cost | 14788 |
| Alternative 8 | |
|---|---|
| Accuracy | 84.0% |
| Cost | 7492 |
| Alternative 9 | |
|---|---|
| Accuracy | 81.5% |
| Cost | 7232 |
| Alternative 10 | |
|---|---|
| Accuracy | 81.4% |
| Cost | 1600 |
| Alternative 11 | |
|---|---|
| Accuracy | 64.3% |
| Cost | 256 |
| Alternative 12 | |
|---|---|
| Accuracy | 1.6% |
| Cost | 192 |
herbie shell --seed 2023135
(FPCore (a b c)
:name "Quadratic roots, narrow range"
:precision binary64
:pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))