| Alternative 1 | |
|---|---|
| Accuracy | 96.8% |
| Cost | 14528 |
\[\left(\frac{\left(a \cdot \left(a \cdot -2\right)\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{\frac{\frac{a}{b}}{b}}{\frac{\frac{b}{c}}{c}}
\]
(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 (sqrt (+ b (sqrt (fma b b (* c (* -4.0 a)))))))) (/ (/ (/ (* -4.0 (* c a)) t_0) t_0) (* a 2.0))))
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 = sqrt((b + sqrt(fma(b, b, (c * (-4.0 * a))))));
return (((-4.0 * (c * a)) / t_0) / t_0) / (a * 2.0);
}
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 = sqrt(Float64(b + sqrt(fma(b, b, Float64(c * Float64(-4.0 * a)))))) return Float64(Float64(Float64(Float64(-4.0 * Float64(c * a)) / t_0) / t_0) / Float64(a * 2.0)) 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[Sqrt[N[(b + N[Sqrt[N[(b * b + N[(c * N[(-4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(a * 2.0), $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 := \sqrt{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)}}\\
\frac{\frac{\frac{-4 \cdot \left(c \cdot a\right)}{t_0}}{t_0}}{a \cdot 2}
\end{array}
Initial program 18.2%
Simplified18.2%
[Start]18.2 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\] |
|---|---|
*-commutative [=>]18.2 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}}
\] |
Applied egg-rr18.6%
[Start]18.2 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}
\] |
|---|---|
+-commutative [=>]18.2 | \[ \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}{a \cdot 2}
\] |
flip-+ [=>]18.2 | \[ \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 [=>]0.4 | \[ \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 [=>]0.4 | \[ \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.7 | \[ \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 [<=]0.4 | \[ \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 [<=]0.4 | \[ \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 [<=]0.4 | \[ \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}
\] |
Taylor expanded in b around 0 99.0%
Final simplification99.0%
| Alternative 1 | |
|---|---|
| Accuracy | 96.8% |
| Cost | 14528 |
| Alternative 2 | |
|---|---|
| Accuracy | 95.2% |
| Cost | 7232 |
| Alternative 3 | |
|---|---|
| Accuracy | 94.7% |
| Cost | 1728 |
| Alternative 4 | |
|---|---|
| Accuracy | 94.6% |
| Cost | 1600 |
| Alternative 5 | |
|---|---|
| Accuracy | 90.1% |
| Cost | 256 |
herbie shell --seed 2023133
(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)))