| Alternative 1 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 7872 |
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c) :precision binary64 (/ -0.3333333333333333 (/ (+ (/ b a) (/ (sqrt (fma c (* a -3.0) (* b b))) a)) (/ 3.0 (/ a c)))))
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 -0.3333333333333333 / (((b / a) + (sqrt(fma(c, (a * -3.0), (b * b))) / a)) / (3.0 / (a / c)));
}
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(-0.3333333333333333 / Float64(Float64(Float64(b / a) + Float64(sqrt(fma(c, Float64(a * -3.0), Float64(b * b))) / a)) / Float64(3.0 / Float64(a / c)))) 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.3333333333333333 / N[(N[(N[(b / a), $MachinePrecision] + N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(3.0 / N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\frac{-0.3333333333333333}{\frac{\frac{b}{a} + \frac{\sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}{a}}{\frac{3}{\frac{a}{c}}}}
Initial program 17.2%
Simplified17.3%
[Start]17.2 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\] |
|---|---|
/-rgt-identity [<=]17.2 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\color{blue}{\frac{3 \cdot a}{1}}}
\] |
metadata-eval [<=]17.2 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\frac{3 \cdot a}{\color{blue}{--1}}}
\] |
associate-/l* [<=]17.2 | \[ \color{blue}{\frac{\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \left(--1\right)}{3 \cdot a}}
\] |
associate-*r/ [<=]17.2 | \[ \color{blue}{\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{--1}{3 \cdot a}}
\] |
*-commutative [=>]17.2 | \[ \color{blue}{\frac{--1}{3 \cdot a} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}
\] |
associate-*l/ [=>]17.2 | \[ \color{blue}{\frac{\left(--1\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}}
\] |
associate-*r/ [<=]17.2 | \[ \color{blue}{\left(--1\right) \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}}
\] |
metadata-eval [=>]17.2 | \[ \color{blue}{1} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\] |
metadata-eval [<=]17.2 | \[ \color{blue}{\frac{-1}{-1}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\] |
times-frac [<=]17.2 | \[ \color{blue}{\frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{-1 \cdot \left(3 \cdot a\right)}}
\] |
neg-mul-1 [<=]17.2 | \[ \frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{\color{blue}{-3 \cdot a}}
\] |
distribute-rgt-neg-in [=>]17.2 | \[ \frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{\color{blue}{3 \cdot \left(-a\right)}}
\] |
times-frac [=>]17.2 | \[ \color{blue}{\frac{-1}{3} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{-a}}
\] |
metadata-eval [=>]17.2 | \[ \color{blue}{-0.3333333333333333} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{-a}
\] |
neg-mul-1 [=>]17.2 | \[ -0.3333333333333333 \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\color{blue}{-1 \cdot a}}
\] |
Applied egg-rr18.6%
[Start]17.3 | \[ -0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}{a}
\] |
|---|---|
div-sub [=>]17.0 | \[ -0.3333333333333333 \cdot \color{blue}{\left(\frac{b}{a} - \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}{a}\right)}
\] |
*-un-lft-identity [=>]17.0 | \[ -0.3333333333333333 \cdot \left(\frac{\color{blue}{1 \cdot b}}{a} - \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}{a}\right)
\] |
add-sqr-sqrt [=>]17.4 | \[ -0.3333333333333333 \cdot \left(\frac{1 \cdot b}{\color{blue}{\sqrt{a} \cdot \sqrt{a}}} - \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}{a}\right)
\] |
times-frac [=>]17.7 | \[ -0.3333333333333333 \cdot \left(\color{blue}{\frac{1}{\sqrt{a}} \cdot \frac{b}{\sqrt{a}}} - \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}{a}\right)
\] |
add-sqr-sqrt [=>]17.7 | \[ -0.3333333333333333 \cdot \left(\frac{1}{\sqrt{a}} \cdot \frac{b}{\sqrt{a}} - \frac{\color{blue}{\sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}}{a}\right)
\] |
*-un-lft-identity [=>]17.7 | \[ -0.3333333333333333 \cdot \left(\frac{1}{\sqrt{a}} \cdot \frac{b}{\sqrt{a}} - \frac{\sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{\color{blue}{1 \cdot a}}\right)
\] |
times-frac [=>]17.7 | \[ -0.3333333333333333 \cdot \left(\frac{1}{\sqrt{a}} \cdot \frac{b}{\sqrt{a}} - \color{blue}{\frac{\sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{1} \cdot \frac{\sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{a}}\right)
\] |
prod-diff [=>]18.6 | \[ -0.3333333333333333 \cdot \color{blue}{\left(\mathsf{fma}\left(\frac{1}{\sqrt{a}}, \frac{b}{\sqrt{a}}, -\frac{\sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{a} \cdot \frac{\sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{1}\right) + \mathsf{fma}\left(-\frac{\sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{a}, \frac{\sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{1}, \frac{\sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{a} \cdot \frac{\sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{1}\right)\right)}
\] |
Simplified17.8%
[Start]18.6 | \[ -0.3333333333333333 \cdot \left(\mathsf{fma}\left(\frac{1}{\sqrt{a}}, \frac{b}{\sqrt{a}}, -\frac{{\left(\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)\right)}^{0.25}}{a} \cdot \frac{{\left(\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)\right)}^{0.25}}{1}\right) + \mathsf{fma}\left(-\frac{{\left(\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)\right)}^{0.25}}{a}, \frac{{\left(\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)\right)}^{0.25}}{1}, \frac{{\left(\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)\right)}^{0.25}}{a} \cdot \frac{{\left(\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)\right)}^{0.25}}{1}\right)\right)
\] |
|---|---|
+-commutative [=>]18.6 | \[ -0.3333333333333333 \cdot \color{blue}{\left(\mathsf{fma}\left(-\frac{{\left(\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)\right)}^{0.25}}{a}, \frac{{\left(\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)\right)}^{0.25}}{1}, \frac{{\left(\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)\right)}^{0.25}}{a} \cdot \frac{{\left(\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)\right)}^{0.25}}{1}\right) + \mathsf{fma}\left(\frac{1}{\sqrt{a}}, \frac{b}{\sqrt{a}}, -\frac{{\left(\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)\right)}^{0.25}}{a} \cdot \frac{{\left(\mathsf{fma}\left(c, -3 \cdot a, b \cdot b\right)\right)}^{0.25}}{1}\right)\right)}
\] |
Applied egg-rr18.2%
[Start]17.8 | \[ -0.3333333333333333 \cdot \left(0 \cdot \frac{{\left(\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)\right)}^{0.5}}{a} + \left(\frac{1}{\sqrt{a}} \cdot \frac{b}{\sqrt{a}} - \frac{{\left(\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)\right)}^{0.5}}{a}\right)\right)
\] |
|---|---|
mul0-lft [=>]17.8 | \[ -0.3333333333333333 \cdot \left(\color{blue}{0} + \left(\frac{1}{\sqrt{a}} \cdot \frac{b}{\sqrt{a}} - \frac{{\left(\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)\right)}^{0.5}}{a}\right)\right)
\] |
+-lft-identity [=>]17.8 | \[ -0.3333333333333333 \cdot \color{blue}{\left(\frac{1}{\sqrt{a}} \cdot \frac{b}{\sqrt{a}} - \frac{{\left(\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)\right)}^{0.5}}{a}\right)}
\] |
flip-- [=>]17.8 | \[ -0.3333333333333333 \cdot \color{blue}{\frac{\left(\frac{1}{\sqrt{a}} \cdot \frac{b}{\sqrt{a}}\right) \cdot \left(\frac{1}{\sqrt{a}} \cdot \frac{b}{\sqrt{a}}\right) - \frac{{\left(\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)\right)}^{0.5}}{a} \cdot \frac{{\left(\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)\right)}^{0.5}}{a}}{\frac{1}{\sqrt{a}} \cdot \frac{b}{\sqrt{a}} + \frac{{\left(\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)\right)}^{0.5}}{a}}}
\] |
associate-*r/ [=>]17.8 | \[ \color{blue}{\frac{-0.3333333333333333 \cdot \left(\left(\frac{1}{\sqrt{a}} \cdot \frac{b}{\sqrt{a}}\right) \cdot \left(\frac{1}{\sqrt{a}} \cdot \frac{b}{\sqrt{a}}\right) - \frac{{\left(\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)\right)}^{0.5}}{a} \cdot \frac{{\left(\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)\right)}^{0.5}}{a}\right)}{\frac{1}{\sqrt{a}} \cdot \frac{b}{\sqrt{a}} + \frac{{\left(\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)\right)}^{0.5}}{a}}}
\] |
Simplified18.2%
[Start]18.2 | \[ \frac{-0.3333333333333333 \cdot \left({\left(\frac{b}{a}\right)}^{2} - \frac{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}{a \cdot a}\right)}{\frac{b}{a} + \frac{\sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}{a}}
\] |
|---|---|
associate-/l* [=>]18.2 | \[ \color{blue}{\frac{-0.3333333333333333}{\frac{\frac{b}{a} + \frac{\sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}{a}}{{\left(\frac{b}{a}\right)}^{2} - \frac{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}{a \cdot a}}}}
\] |
Taylor expanded in b around 0 99.1%
Applied egg-rr99.1%
[Start]99.1 | \[ \frac{-0.3333333333333333}{\frac{\frac{b}{a} + \frac{\sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}{a}}{3 \cdot \frac{c}{a}}}
\] |
|---|---|
clear-num [=>]99.1 | \[ \frac{-0.3333333333333333}{\frac{\frac{b}{a} + \frac{\sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}{a}}{3 \cdot \color{blue}{\frac{1}{\frac{a}{c}}}}}
\] |
un-div-inv [=>]99.1 | \[ \frac{-0.3333333333333333}{\frac{\frac{b}{a} + \frac{\sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}{a}}{\color{blue}{\frac{3}{\frac{a}{c}}}}}
\] |
Final simplification99.1%
| Alternative 1 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 7872 |
| Alternative 2 | |
|---|---|
| Accuracy | 95.0% |
| Cost | 7104 |
| Alternative 3 | |
|---|---|
| Accuracy | 95.0% |
| Cost | 832 |
| Alternative 4 | |
|---|---|
| Accuracy | 90.0% |
| Cost | 320 |
| Alternative 5 | |
|---|---|
| Accuracy | 90.0% |
| Cost | 320 |
| Alternative 6 | |
|---|---|
| Accuracy | 90.3% |
| Cost | 320 |
| Alternative 7 | |
|---|---|
| Accuracy | 3.3% |
| Cost | 64 |
herbie shell --seed 2023159
(FPCore (a b c)
:name "Cubic critical, 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) (* (* 3.0 a) c)))) (* 3.0 a)))