| Alternative 1 | |
|---|---|
| Accuracy | 99.0% |
| Cost | 34624 |
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma a (* c -3.0) (* b b))))
(/
(+ (* 6.0 (* c (* a (pow b 2.0)))) (* -9.0 (pow (* c a) 2.0)))
(* (+ (* a (* b -3.0)) (* a (* -3.0 (sqrt t_0)))) (+ (* b b) t_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) {
double t_0 = fma(a, (c * -3.0), (b * b));
return ((6.0 * (c * (a * pow(b, 2.0)))) + (-9.0 * pow((c * a), 2.0))) / (((a * (b * -3.0)) + (a * (-3.0 * sqrt(t_0)))) * ((b * b) + t_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) t_0 = fma(a, Float64(c * -3.0), Float64(b * b)) return Float64(Float64(Float64(6.0 * Float64(c * Float64(a * (b ^ 2.0)))) + Float64(-9.0 * (Float64(c * a) ^ 2.0))) / Float64(Float64(Float64(a * Float64(b * -3.0)) + Float64(a * Float64(-3.0 * sqrt(t_0)))) * Float64(Float64(b * b) + t_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_] := Block[{t$95$0 = N[(a * N[(c * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(6.0 * N[(c * N[(a * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-9.0 * N[Power[N[(c * a), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(a * N[(b * -3.0), $MachinePrecision]), $MachinePrecision] + N[(a * N[(-3.0 * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\\
\frac{6 \cdot \left(c \cdot \left(a \cdot {b}^{2}\right)\right) + -9 \cdot {\left(c \cdot a\right)}^{2}}{\left(a \cdot \left(b \cdot -3\right) + a \cdot \left(-3 \cdot \sqrt{t_0}\right)\right) \cdot \left(b \cdot b + t_0\right)}
\end{array}
Initial program 31.5%
Simplified31.5%
[Start]31.5 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\] |
|---|---|
remove-double-neg [<=]31.5 | \[ \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 [<=]31.5 | \[ \frac{\color{blue}{\left(-b\right) - \left(-\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}
\] |
div-sub [=>]31.1 | \[ \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 [=>]31.1 | \[ \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/ [<=]31.3 | \[ \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 [=>]31.3 | \[ \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.8 | \[ \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.8 | \[ \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.8 | \[ \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.8 | \[ \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.8 | \[ \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.8 | \[ \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 [<=]31.3 | \[ \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 [=>]31.3 | \[ \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.9%
[Start]31.5 | \[ \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \frac{-0.3333333333333333}{a}
\] |
|---|---|
associate-*r/ [=>]31.5 | \[ \color{blue}{\frac{\left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot -0.3333333333333333}{a}}
\] |
associate-/l* [=>]31.5 | \[ \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}{\frac{a}{-0.3333333333333333}}}
\] |
flip-- [=>]31.5 | \[ \frac{\color{blue}{\frac{b \cdot b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}}}{\frac{a}{-0.3333333333333333}}
\] |
associate-/l/ [=>]31.5 | \[ \color{blue}{\frac{b \cdot b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}{\frac{a}{-0.3333333333333333} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)}}
\] |
add-sqr-sqrt [<=]32.5 | \[ \frac{b \cdot b - \color{blue}{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}{\frac{a}{-0.3333333333333333} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)}
\] |
flip-- [=>]32.4 | \[ \frac{\color{blue}{\frac{\left(b \cdot b\right) \cdot \left(b \cdot b\right) - \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right) \cdot \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}{b \cdot b + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}}{\frac{a}{-0.3333333333333333} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)}
\] |
associate-/l/ [=>]32.4 | \[ \color{blue}{\frac{\left(b \cdot b\right) \cdot \left(b \cdot b\right) - \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right) \cdot \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}{\left(\frac{a}{-0.3333333333333333} \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)}}
\] |
Taylor expanded in b around 0 99.0%
Applied egg-rr99.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)}
\] |
|---|---|
distribute-rgt-in [=>]99.0 | \[ \frac{6 \cdot \left(c \cdot \left(a \cdot {b}^{2}\right)\right) + -9 \cdot \left({c}^{2} \cdot {a}^{2}\right)}{\color{blue}{\left(b \cdot \left(a \cdot -3\right) + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} \cdot \left(a \cdot -3\right)\right)} \cdot \left(b \cdot b + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}
\] |
*-commutative [=>]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(b \cdot \color{blue}{\left(-3 \cdot a\right)} + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} \cdot \left(a \cdot -3\right)\right) \cdot \left(b \cdot b + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}
\] |
associate-*r* [=>]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(\color{blue}{\left(b \cdot -3\right) \cdot a} + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} \cdot \left(a \cdot -3\right)\right) \cdot \left(b \cdot b + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}
\] |
*-commutative [=>]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(b \cdot -3\right) \cdot a + \color{blue}{\left(a \cdot -3\right) \cdot \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}\right) \cdot \left(b \cdot b + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}
\] |
associate-*l* [=>]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(b \cdot -3\right) \cdot a + \color{blue}{a \cdot \left(-3 \cdot \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-rr92.4%
[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(b \cdot -3\right) \cdot a + a \cdot \left(-3 \cdot \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)}
\] |
|---|---|
expm1-log1p-u [=>]99.0 | \[ \frac{6 \cdot \left(c \cdot \left(a \cdot {b}^{2}\right)\right) + -9 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({c}^{2} \cdot {a}^{2}\right)\right)}}{\left(\left(b \cdot -3\right) \cdot a + a \cdot \left(-3 \cdot \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)}
\] |
expm1-udef [=>]92.4 | \[ \frac{6 \cdot \left(c \cdot \left(a \cdot {b}^{2}\right)\right) + -9 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({c}^{2} \cdot {a}^{2}\right)} - 1\right)}}{\left(\left(b \cdot -3\right) \cdot a + a \cdot \left(-3 \cdot \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)}
\] |
sub-neg [=>]92.4 | \[ \frac{6 \cdot \left(c \cdot \left(a \cdot {b}^{2}\right)\right) + -9 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({c}^{2} \cdot {a}^{2}\right)} + \left(-1\right)\right)}}{\left(\left(b \cdot -3\right) \cdot a + a \cdot \left(-3 \cdot \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)}
\] |
pow-prod-down [=>]92.4 | \[ \frac{6 \cdot \left(c \cdot \left(a \cdot {b}^{2}\right)\right) + -9 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(c \cdot a\right)}^{2}}\right)} + \left(-1\right)\right)}{\left(\left(b \cdot -3\right) \cdot a + a \cdot \left(-3 \cdot \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)}
\] |
metadata-eval [=>]92.4 | \[ \frac{6 \cdot \left(c \cdot \left(a \cdot {b}^{2}\right)\right) + -9 \cdot \left(e^{\mathsf{log1p}\left({\left(c \cdot a\right)}^{2}\right)} + \color{blue}{-1}\right)}{\left(\left(b \cdot -3\right) \cdot a + a \cdot \left(-3 \cdot \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)}
\] |
Simplified99.0%
[Start]92.4 | \[ \frac{6 \cdot \left(c \cdot \left(a \cdot {b}^{2}\right)\right) + -9 \cdot \left(e^{\mathsf{log1p}\left({\left(c \cdot a\right)}^{2}\right)} + -1\right)}{\left(\left(b \cdot -3\right) \cdot a + a \cdot \left(-3 \cdot \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)}
\] |
|---|---|
metadata-eval [<=]92.4 | \[ \frac{6 \cdot \left(c \cdot \left(a \cdot {b}^{2}\right)\right) + -9 \cdot \left(e^{\mathsf{log1p}\left({\left(c \cdot a\right)}^{2}\right)} + \color{blue}{\left(-1\right)}\right)}{\left(\left(b \cdot -3\right) \cdot a + a \cdot \left(-3 \cdot \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)}
\] |
sub-neg [<=]92.4 | \[ \frac{6 \cdot \left(c \cdot \left(a \cdot {b}^{2}\right)\right) + -9 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(c \cdot a\right)}^{2}\right)} - 1\right)}}{\left(\left(b \cdot -3\right) \cdot a + a \cdot \left(-3 \cdot \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)}
\] |
expm1-def [=>]99.0 | \[ \frac{6 \cdot \left(c \cdot \left(a \cdot {b}^{2}\right)\right) + -9 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(c \cdot a\right)}^{2}\right)\right)}}{\left(\left(b \cdot -3\right) \cdot a + a \cdot \left(-3 \cdot \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)}
\] |
expm1-log1p [=>]99.0 | \[ \frac{6 \cdot \left(c \cdot \left(a \cdot {b}^{2}\right)\right) + -9 \cdot \color{blue}{{\left(c \cdot a\right)}^{2}}}{\left(\left(b \cdot -3\right) \cdot a + a \cdot \left(-3 \cdot \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)}
\] |
Final simplification99.0%
| Alternative 1 | |
|---|---|
| Accuracy | 99.0% |
| Cost | 34624 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.0% |
| Cost | 28352 |
| Alternative 3 | |
|---|---|
| Accuracy | 99.0% |
| Cost | 28352 |
| Alternative 4 | |
|---|---|
| Accuracy | 90.9% |
| Cost | 28228 |
| Alternative 5 | |
|---|---|
| Accuracy | 90.9% |
| Cost | 28228 |
| Alternative 6 | |
|---|---|
| Accuracy | 90.7% |
| Cost | 21124 |
| Alternative 7 | |
|---|---|
| Accuracy | 90.7% |
| Cost | 21124 |
| Alternative 8 | |
|---|---|
| Accuracy | 84.3% |
| Cost | 21060 |
| Alternative 9 | |
|---|---|
| Accuracy | 84.3% |
| Cost | 21060 |
| Alternative 10 | |
|---|---|
| Accuracy | 84.2% |
| Cost | 14916 |
| Alternative 11 | |
|---|---|
| Accuracy | 84.2% |
| Cost | 14788 |
| Alternative 12 | |
|---|---|
| Accuracy | 81.1% |
| Cost | 320 |
| Alternative 13 | |
|---|---|
| Accuracy | 81.3% |
| Cost | 320 |
| Alternative 14 | |
|---|---|
| Accuracy | 3.2% |
| Cost | 64 |
herbie shell --seed 2023137
(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)))