| Alternative 1 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 14144 |
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
:precision binary64
(/
(fma 6.0 (* c (* a (* b b))) (* -9.0 (* (* c c) (* a a))))
(*
a
(*
(+ b (sqrt (fma a (* c -3.0) (* b b))))
(fma -6.0 (* b b) (* (* c a) 9.0))))))double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
double code(double a, double b, double c) {
return fma(6.0, (c * (a * (b * b))), (-9.0 * ((c * c) * (a * a)))) / (a * ((b + sqrt(fma(a, (c * -3.0), (b * b)))) * fma(-6.0, (b * b), ((c * a) * 9.0))));
}
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function code(a, b, c) return Float64(fma(6.0, Float64(c * Float64(a * Float64(b * b))), Float64(-9.0 * Float64(Float64(c * c) * Float64(a * a)))) / Float64(a * Float64(Float64(b + sqrt(fma(a, Float64(c * -3.0), Float64(b * b)))) * fma(-6.0, Float64(b * b), Float64(Float64(c * a) * 9.0))))) end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_] := N[(N[(6.0 * N[(c * N[(a * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-9.0 * N[(N[(c * c), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * N[(N[(b + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-6.0 * N[(b * b), $MachinePrecision] + N[(N[(c * a), $MachinePrecision] * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{a \cdot \left(\left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \mathsf{fma}\left(-6, b \cdot b, \left(c \cdot a\right) \cdot 9\right)\right)}
Initial program 30.9%
Simplified30.9%
[Start]30.9 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\] |
|---|---|
remove-double-neg [<=]30.9 | \[ \frac{\left(-b\right) + \color{blue}{\left(-\left(-\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)\right)}}{3 \cdot a}
\] |
sub-neg [<=]30.9 | \[ \frac{\color{blue}{\left(-b\right) - \left(-\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}
\] |
div-sub [=>]30.5 | \[ \color{blue}{\frac{-b}{3 \cdot a} - \frac{-\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}}
\] |
neg-mul-1 [=>]30.5 | \[ \frac{\color{blue}{-1 \cdot b}}{3 \cdot a} - \frac{-\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\] |
associate-*l/ [<=]30.7 | \[ \color{blue}{\frac{-1}{3 \cdot a} \cdot b} - \frac{-\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\] |
distribute-frac-neg [=>]30.7 | \[ \frac{-1}{3 \cdot a} \cdot b - \color{blue}{\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)}
\] |
fma-neg [=>]32.3 | \[ \color{blue}{\mathsf{fma}\left(\frac{-1}{3 \cdot a}, b, -\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)\right)}
\] |
/-rgt-identity [<=]32.3 | \[ \mathsf{fma}\left(\frac{-1}{3 \cdot a}, \color{blue}{\frac{b}{1}}, -\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)\right)
\] |
metadata-eval [<=]32.3 | \[ \mathsf{fma}\left(\frac{-1}{3 \cdot a}, \frac{b}{\color{blue}{\frac{-1}{-1}}}, -\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)\right)
\] |
associate-/l* [<=]32.3 | \[ \mathsf{fma}\left(\frac{-1}{3 \cdot a}, \color{blue}{\frac{b \cdot -1}{-1}}, -\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)\right)
\] |
*-commutative [<=]32.3 | \[ \mathsf{fma}\left(\frac{-1}{3 \cdot a}, \frac{\color{blue}{-1 \cdot b}}{-1}, -\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)\right)
\] |
neg-mul-1 [<=]32.3 | \[ \mathsf{fma}\left(\frac{-1}{3 \cdot a}, \frac{\color{blue}{-b}}{-1}, -\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)\right)
\] |
fma-neg [<=]30.7 | \[ \color{blue}{\frac{-1}{3 \cdot a} \cdot \frac{-b}{-1} - \left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)}
\] |
neg-mul-1 [=>]30.7 | \[ \frac{-1}{3 \cdot a} \cdot \frac{-b}{-1} - \color{blue}{-1 \cdot \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}}
\] |
Applied egg-rr32.4%
Taylor expanded in b around 0 99.0%
Simplified99.0%
[Start]99.0 | \[ \frac{6 \cdot \left(c \cdot \left(a \cdot {b}^{2}\right)\right) + -9 \cdot \left({c}^{2} \cdot {a}^{2}\right)}{\left(\left(a \cdot -3\right) \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right) \cdot \left(b \cdot b + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}
\] |
|---|---|
fma-def [=>]99.0 | \[ \frac{\color{blue}{\mathsf{fma}\left(6, c \cdot \left(a \cdot {b}^{2}\right), -9 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}}{\left(\left(a \cdot -3\right) \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right) \cdot \left(b \cdot b + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}
\] |
unpow2 [=>]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \color{blue}{\left(b \cdot b\right)}\right), -9 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}{\left(\left(a \cdot -3\right) \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right) \cdot \left(b \cdot b + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}
\] |
unpow2 [=>]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot {a}^{2}\right)\right)}{\left(\left(a \cdot -3\right) \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right) \cdot \left(b \cdot b + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}
\] |
unpow2 [=>]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \color{blue}{\left(a \cdot a\right)}\right)\right)}{\left(\left(a \cdot -3\right) \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right) \cdot \left(b \cdot b + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}
\] |
Applied egg-rr99.0%
Simplified99.0%
[Start]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{\left(a \cdot -3\right) \cdot \left(\left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \left(b \cdot b\right)\right) + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right) \cdot \left(\left(a \cdot -3\right) \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right)}
\] |
|---|---|
associate-*r* [=>]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{\color{blue}{\left(\left(a \cdot -3\right) \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right) \cdot \left(b \cdot b\right)} + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right) \cdot \left(\left(a \cdot -3\right) \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right)}
\] |
*-commutative [=>]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{\left(\left(a \cdot -3\right) \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right) \cdot \left(b \cdot b\right) + \color{blue}{\left(\left(a \cdot -3\right) \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right) \cdot \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}
\] |
distribute-lft-in [<=]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{\color{blue}{\left(\left(a \cdot -3\right) \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right) \cdot \left(b \cdot b + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}}
\] |
fma-udef [<=]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{\left(\left(a \cdot -3\right) \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right) \cdot \color{blue}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}}
\] |
associate-*l* [=>]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{\color{blue}{\left(a \cdot \left(-3 \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right)\right)} \cdot \mathsf{fma}\left(b, b, \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}
\] |
associate-*r* [<=]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{\color{blue}{a \cdot \left(\left(-3 \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right) \cdot \mathsf{fma}\left(b, b, \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)\right)}}
\] |
*-commutative [=>]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{a \cdot \left(\color{blue}{\left(\left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot -3\right)} \cdot \mathsf{fma}\left(b, b, \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)\right)}
\] |
associate-*l* [=>]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{a \cdot \color{blue}{\left(\left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \left(-3 \cdot \mathsf{fma}\left(b, b, \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)\right)\right)}}
\] |
Taylor expanded in b around 0 99.0%
Simplified99.0%
[Start]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{a \cdot \left(\left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \left(-6 \cdot {b}^{2} + 9 \cdot \left(c \cdot a\right)\right)\right)}
\] |
|---|---|
fma-def [=>]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{a \cdot \left(\left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \color{blue}{\mathsf{fma}\left(-6, {b}^{2}, 9 \cdot \left(c \cdot a\right)\right)}\right)}
\] |
unpow2 [=>]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{a \cdot \left(\left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \mathsf{fma}\left(-6, \color{blue}{b \cdot b}, 9 \cdot \left(c \cdot a\right)\right)\right)}
\] |
*-commutative [=>]99.0 | \[ \frac{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), -9 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{a \cdot \left(\left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \mathsf{fma}\left(-6, b \cdot b, \color{blue}{\left(c \cdot a\right) \cdot 9}\right)\right)}
\] |
Final simplification99.0%
| Alternative 1 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 14144 |
| Alternative 2 | |
|---|---|
| Accuracy | 93.9% |
| Cost | 8448 |
| Alternative 3 | |
|---|---|
| Accuracy | 90.9% |
| Cost | 7232 |
| Alternative 4 | |
|---|---|
| Accuracy | 90.8% |
| Cost | 1088 |
| Alternative 5 | |
|---|---|
| Accuracy | 90.9% |
| Cost | 960 |
| Alternative 6 | |
|---|---|
| Accuracy | 81.6% |
| Cost | 320 |
| Alternative 7 | |
|---|---|
| Accuracy | 3.2% |
| Cost | 192 |
herbie shell --seed 2023125
(FPCore (a b c)
:name "Cubic critical, 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) (* (* 3.0 a) c)))) (* 3.0 a)))