| Alternative 1 | |
|---|---|
| Accuracy | 93.3% |
| 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 (* (* (* c c) (* c (pow b -5.0))) (* a a)) (fma -0.5 (/ c b) (* (/ (* c c) (* b b)) (/ (* a -0.375) 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, (((c * c) * (c * pow(b, -5.0))) * (a * a)), fma(-0.5, (c / b), (((c * c) / (b * b)) * ((a * -0.375) / 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(Float64(c * c) * Float64(c * (b ^ -5.0))) * Float64(a * a)), fma(-0.5, Float64(c / b), Float64(Float64(Float64(c * c) / Float64(b * b)) * Float64(Float64(a * -0.375) / 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[(c * c), $MachinePrecision] * N[(c * N[Power[b, -5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision] + N[(N[(N[(c * c), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] * N[(N[(a * -0.375), $MachinePrecision] / b), $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, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{a \cdot -0.375}{b}\right)\right)\right)
Initial program 29.0%
Simplified29.2%
[Start]29.0 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\] |
|---|---|
neg-sub0 [=>]29.0 | \[ \frac{\color{blue}{\left(0 - b\right)} + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\] |
associate-+l- [=>]29.0 | \[ \frac{\color{blue}{0 - \left(b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}
\] |
sub0-neg [=>]29.0 | \[ \frac{\color{blue}{-\left(b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}
\] |
neg-mul-1 [=>]29.0 | \[ \frac{\color{blue}{-1 \cdot \left(b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}
\] |
associate-*r/ [<=]29.0 | \[ \color{blue}{-1 \cdot \frac{b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}}
\] |
*-commutative [=>]29.0 | \[ \color{blue}{\frac{b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \cdot -1}
\] |
metadata-eval [<=]29.0 | \[ \frac{b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \cdot \color{blue}{\frac{1}{-1}}
\] |
metadata-eval [<=]29.0 | \[ \frac{b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \cdot \frac{\color{blue}{--1}}{-1}
\] |
times-frac [<=]29.0 | \[ \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 [<=]29.0 | \[ \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 [=>]29.0 | \[ \color{blue}{\frac{b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{-1} \cdot \frac{--1}{3 \cdot a}}
\] |
Taylor expanded in a around 0 95.7%
Simplified95.7%
[Start]95.7 | \[ -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.7 | \[ \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.7%
[Start]95.7 | \[ \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}, \frac{\left(-0.375 \cdot a\right) \cdot \left(c \cdot c\right)}{{b}^{3}}\right)\right)\right)
\] |
|---|---|
*-commutative [=>]95.7 | \[ \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}, \frac{\color{blue}{\left(c \cdot c\right) \cdot \left(-0.375 \cdot a\right)}}{{b}^{3}}\right)\right)\right)
\] |
unpow3 [=>]95.7 | \[ \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}, \frac{\left(c \cdot c\right) \cdot \left(-0.375 \cdot a\right)}{\color{blue}{\left(b \cdot b\right) \cdot b}}\right)\right)\right)
\] |
times-frac [=>]95.7 | \[ \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}, \color{blue}{\frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}}\right)\right)\right)
\] |
Applied egg-rr95.7%
[Start]95.7 | \[ \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}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
|---|---|
div-inv [=>]95.7 | \[ \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, \color{blue}{\left({c}^{3} \cdot \frac{1}{{b}^{5}}\right)} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
unpow3 [=>]95.7 | \[ \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, \left(\color{blue}{\left(\left(c \cdot c\right) \cdot c\right)} \cdot \frac{1}{{b}^{5}}\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
associate-*l* [=>]95.7 | \[ \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, \color{blue}{\left(\left(c \cdot c\right) \cdot \left(c \cdot \frac{1}{{b}^{5}}\right)\right)} \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
pow-flip [=>]95.7 | \[ \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, \left(\left(c \cdot c\right) \cdot \left(c \cdot \color{blue}{{b}^{\left(-5\right)}}\right)\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
metadata-eval [=>]95.7 | \[ \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, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{\color{blue}{-5}}\right)\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
Applied egg-rr95.7%
[Start]95.7 | \[ \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, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
|---|---|
div-inv [=>]95.7 | \[ \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, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
sqr-pow [=>]95.7 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left(\color{blue}{\left({c}^{\left(\frac{4}{2}\right)} \cdot {c}^{\left(\frac{4}{2}\right)}\right)} \cdot \frac{1}{{b}^{6}}\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
metadata-eval [=>]95.7 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left(\left({c}^{\color{blue}{2}} \cdot {c}^{\left(\frac{4}{2}\right)}\right) \cdot \frac{1}{{b}^{6}}\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
pow2 [<=]95.7 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left(\left(\color{blue}{\left(c \cdot c\right)} \cdot {c}^{\left(\frac{4}{2}\right)}\right) \cdot \frac{1}{{b}^{6}}\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
metadata-eval [=>]95.7 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left(\left(\left(c \cdot c\right) \cdot {c}^{\color{blue}{2}}\right) \cdot \frac{1}{{b}^{6}}\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
pow2 [<=]95.7 | \[ \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{3}}{b} \cdot \left(\left(\left(\left(c \cdot c\right) \cdot \color{blue}{\left(c \cdot c\right)}\right) \cdot \frac{1}{{b}^{6}}\right) \cdot 6.328125\right), \mathsf{fma}\left(-0.5625, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
associate-*l* [=>]95.7 | \[ \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, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
pow-flip [=>]95.7 | \[ \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, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
metadata-eval [=>]95.7 | \[ \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, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c \cdot c}{b \cdot b} \cdot \frac{-0.375 \cdot a}{b}\right)\right)\right)
\] |
Final simplification95.7%
| Alternative 1 | |
|---|---|
| Accuracy | 93.3% |
| Cost | 33536 |
| Alternative 2 | |
|---|---|
| Accuracy | 93.6% |
| Cost | 33536 |
| Alternative 3 | |
|---|---|
| Accuracy | 93.6% |
| Cost | 33536 |
| Alternative 4 | |
|---|---|
| Accuracy | 93.0% |
| Cost | 27712 |
| Alternative 5 | |
|---|---|
| Accuracy | 90.4% |
| Cost | 7488 |
| Alternative 6 | |
|---|---|
| Accuracy | 90.2% |
| Cost | 7296 |
| Alternative 7 | |
|---|---|
| Accuracy | 90.1% |
| Cost | 1088 |
| Alternative 8 | |
|---|---|
| Accuracy | 80.9% |
| Cost | 320 |
herbie shell --seed 2023157
(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)))