| Alternative 1 | |
|---|---|
| Accuracy | 93.7% |
| Cost | 33536 |
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c) :precision binary64 (fma -0.16666666666666666 (* (/ (pow a 3.0) b) (* (* (* c c) (* (* c c) (pow b -6.0))) 6.328125)) (fma -0.5625 (* (/ (pow c 3.0) (pow b 5.0)) (* a a)) (fma -0.5 (/ c b) (* -0.375 (* (/ c b) (/ (* a c) (* b b))))))))
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(-0.16666666666666666, ((pow(a, 3.0) / b) * (((c * c) * ((c * c) * pow(b, -6.0))) * 6.328125)), fma(-0.5625, ((pow(c, 3.0) / pow(b, 5.0)) * (a * a)), fma(-0.5, (c / b), (-0.375 * ((c / b) * ((a * c) / (b * b)))))));
}
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 fma(-0.16666666666666666, Float64(Float64((a ^ 3.0) / b) * Float64(Float64(Float64(c * c) * Float64(Float64(c * c) * (b ^ -6.0))) * 6.328125)), fma(-0.5625, Float64(Float64((c ^ 3.0) / (b ^ 5.0)) * Float64(a * a)), fma(-0.5, Float64(c / b), Float64(-0.375 * Float64(Float64(c / b) * Float64(Float64(a * c) / Float64(b * b))))))) 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[(-0.16666666666666666 * N[(N[(N[Power[a, 3.0], $MachinePrecision] / b), $MachinePrecision] * N[(N[(N[(c * c), $MachinePrecision] * N[(N[(c * c), $MachinePrecision] * N[Power[b, -6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 6.328125), $MachinePrecision]), $MachinePrecision] + N[(-0.5625 * N[(N[(N[Power[c, 3.0], $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision] + N[(-0.375 * N[(N[(c / b), $MachinePrecision] * N[(N[(a * c), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left(\left(c \cdot c\right) \cdot \left(\left(c \cdot c\right) \cdot {b}^{-6}\right)\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{c}{b} \cdot \frac{a \cdot c}{b \cdot b}\right)\right)\right)\right)
Initial program 31.7%
Simplified31.8%
[Start]31.7 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\] |
|---|---|
neg-sub0 [=>]31.7 | \[ \frac{\color{blue}{\left(0 - b\right)} + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\] |
associate-+l- [=>]31.7 | \[ \frac{\color{blue}{0 - \left(b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}
\] |
sub0-neg [=>]31.7 | \[ \frac{\color{blue}{-\left(b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}
\] |
neg-mul-1 [=>]31.7 | \[ \frac{\color{blue}{-1 \cdot \left(b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}
\] |
associate-*r/ [<=]31.7 | \[ \color{blue}{-1 \cdot \frac{b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}}
\] |
*-commutative [=>]31.7 | \[ \color{blue}{\frac{b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \cdot -1}
\] |
metadata-eval [<=]31.7 | \[ \frac{b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \cdot \color{blue}{\frac{1}{-1}}
\] |
metadata-eval [<=]31.7 | \[ \frac{b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \cdot \frac{\color{blue}{--1}}{-1}
\] |
times-frac [<=]31.7 | \[ \color{blue}{\frac{\left(b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \left(--1\right)}{\left(3 \cdot a\right) \cdot -1}}
\] |
*-commutative [<=]31.7 | \[ \frac{\left(b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \left(--1\right)}{\color{blue}{-1 \cdot \left(3 \cdot a\right)}}
\] |
times-frac [=>]31.7 | \[ \color{blue}{\frac{b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{-1} \cdot \frac{--1}{3 \cdot a}}
\] |
Applied egg-rr14.8%
[Start]31.8 | \[ \left(\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b\right) \cdot \frac{0.3333333333333333}{a}
\] |
|---|---|
add-log-exp [=>]14.8 | \[ \left(\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b\right) \cdot \color{blue}{\log \left(e^{\frac{0.3333333333333333}{a}}\right)}
\] |
Taylor expanded in a around 0 95.2%
Simplified95.2%
[Start]95.2 | \[ -0.16666666666666666 \cdot \frac{{a}^{3} \cdot \left(5.0625 \cdot \frac{{c}^{4}}{{b}^{6}} + {\left(-1.125 \cdot \frac{{c}^{2}}{{b}^{3}}\right)}^{2}\right)}{b} + \left(-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right)
\] |
|---|---|
fma-def [=>]95.2 | \[ \color{blue}{\mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3} \cdot \left(5.0625 \cdot \frac{{c}^{4}}{{b}^{6}} + {\left(-1.125 \cdot \frac{{c}^{2}}{{b}^{3}}\right)}^{2}\right)}{b}, -0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right)}
\] |
Applied egg-rr95.2%
[Start]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\frac{{c}^{4}}{{b}^{6}} \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot \left(a \cdot c\right)}{{b}^{3}}\right)\right)\right)
\] |
|---|---|
*-commutative [=>]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\frac{{c}^{4}}{{b}^{6}} \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{\color{blue}{\left(a \cdot c\right) \cdot c}}{{b}^{3}}\right)\right)\right)
\] |
unpow3 [=>]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\frac{{c}^{4}}{{b}^{6}} \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{\left(a \cdot c\right) \cdot c}{\color{blue}{\left(b \cdot b\right) \cdot b}}\right)\right)\right)
\] |
times-frac [=>]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\frac{{c}^{4}}{{b}^{6}} \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \color{blue}{\left(\frac{a \cdot c}{b \cdot b} \cdot \frac{c}{b}\right)}\right)\right)\right)
\] |
*-commutative [=>]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\frac{{c}^{4}}{{b}^{6}} \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{\color{blue}{c \cdot a}}{b \cdot b} \cdot \frac{c}{b}\right)\right)\right)\right)
\] |
Applied egg-rr95.2%
[Start]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\frac{{c}^{4}}{{b}^{6}} \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{c \cdot a}{b \cdot b} \cdot \frac{c}{b}\right)\right)\right)\right)
\] |
|---|---|
div-inv [=>]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\color{blue}{\left({c}^{4} \cdot \frac{1}{{b}^{6}}\right)} \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{c \cdot a}{b \cdot b} \cdot \frac{c}{b}\right)\right)\right)\right)
\] |
metadata-eval [<=]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left({c}^{\color{blue}{\left(2 + 2\right)}} \cdot \frac{1}{{b}^{6}}\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{c \cdot a}{b \cdot b} \cdot \frac{c}{b}\right)\right)\right)\right)
\] |
metadata-eval [<=]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left({c}^{\left(\color{blue}{\sqrt{4}} + 2\right)} \cdot \frac{1}{{b}^{6}}\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{c \cdot a}{b \cdot b} \cdot \frac{c}{b}\right)\right)\right)\right)
\] |
metadata-eval [<=]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left({c}^{\left(\sqrt{4} + \color{blue}{\sqrt{4}}\right)} \cdot \frac{1}{{b}^{6}}\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{c \cdot a}{b \cdot b} \cdot \frac{c}{b}\right)\right)\right)\right)
\] |
pow-prod-up [<=]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left(\color{blue}{\left({c}^{\left(\sqrt{4}\right)} \cdot {c}^{\left(\sqrt{4}\right)}\right)} \cdot \frac{1}{{b}^{6}}\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{c \cdot a}{b \cdot b} \cdot \frac{c}{b}\right)\right)\right)\right)
\] |
pow-prod-down [=>]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left(\color{blue}{{\left(c \cdot c\right)}^{\left(\sqrt{4}\right)}} \cdot \frac{1}{{b}^{6}}\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{c \cdot a}{b \cdot b} \cdot \frac{c}{b}\right)\right)\right)\right)
\] |
metadata-eval [=>]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left({\left(c \cdot c\right)}^{\color{blue}{2}} \cdot \frac{1}{{b}^{6}}\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{c \cdot a}{b \cdot b} \cdot \frac{c}{b}\right)\right)\right)\right)
\] |
pow2 [<=]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left(\color{blue}{\left(\left(c \cdot c\right) \cdot \left(c \cdot c\right)\right)} \cdot \frac{1}{{b}^{6}}\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{c \cdot a}{b \cdot b} \cdot \frac{c}{b}\right)\right)\right)\right)
\] |
associate-*l* [=>]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\color{blue}{\left(\left(c \cdot c\right) \cdot \left(\left(c \cdot c\right) \cdot \frac{1}{{b}^{6}}\right)\right)} \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{c \cdot a}{b \cdot b} \cdot \frac{c}{b}\right)\right)\right)\right)
\] |
pow-flip [=>]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left(\left(c \cdot c\right) \cdot \left(\left(c \cdot c\right) \cdot \color{blue}{{b}^{\left(-6\right)}}\right)\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{c \cdot a}{b \cdot b} \cdot \frac{c}{b}\right)\right)\right)\right)
\] |
metadata-eval [=>]95.2 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left(\left(c \cdot c\right) \cdot \left(\left(c \cdot c\right) \cdot {b}^{\color{blue}{-6}}\right)\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \left(\frac{c \cdot a}{b \cdot b} \cdot \frac{c}{b}\right)\right)\right)\right)
\] |
Final simplification95.2%
| Alternative 1 | |
|---|---|
| Accuracy | 93.7% |
| Cost | 33536 |
| Alternative 2 | |
|---|---|
| Accuracy | 93.7% |
| Cost | 33536 |
| Alternative 3 | |
|---|---|
| Accuracy | 93.2% |
| Cost | 27648 |
| Alternative 4 | |
|---|---|
| Accuracy | 90.3% |
| Cost | 21188 |
| Alternative 5 | |
|---|---|
| Accuracy | 90.3% |
| Cost | 21060 |
| Alternative 6 | |
|---|---|
| Accuracy | 90.3% |
| Cost | 14852 |
| Alternative 7 | |
|---|---|
| Accuracy | 90.6% |
| Cost | 7424 |
| Alternative 8 | |
|---|---|
| Accuracy | 80.8% |
| Cost | 320 |
| Alternative 9 | |
|---|---|
| Accuracy | 81.0% |
| Cost | 320 |
herbie shell --seed 2023152
(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)))