| Alternative 1 | |
|---|---|
| Accuracy | 93.9% |
| Cost | 14528 |
\[\left(\frac{\left(a \cdot \left(a \cdot -2\right)\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{\frac{a \cdot \left(c \cdot c\right)}{b \cdot b}}{b}
\]
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c) :precision binary64 (- (fma -0.25 (* (pow (* c a) 4.0) (/ 20.0 (* a (pow b 7.0)))) (- (/ (* (* a (* a -2.0)) (pow c 3.0)) (pow b 5.0)) (/ c b))) (* a (* (/ c b) (/ c (* b b))))))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
double code(double a, double b, double c) {
return fma(-0.25, (pow((c * a), 4.0) * (20.0 / (a * pow(b, 7.0)))), ((((a * (a * -2.0)) * pow(c, 3.0)) / pow(b, 5.0)) - (c / b))) - (a * ((c / b) * (c / (b * b))));
}
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function code(a, b, c) return Float64(fma(-0.25, Float64((Float64(c * a) ^ 4.0) * Float64(20.0 / Float64(a * (b ^ 7.0)))), Float64(Float64(Float64(Float64(a * Float64(a * -2.0)) * (c ^ 3.0)) / (b ^ 5.0)) - Float64(c / b))) - Float64(a * Float64(Float64(c / b) * Float64(c / Float64(b * b))))) end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_] := N[(N[(-0.25 * N[(N[Power[N[(c * a), $MachinePrecision], 4.0], $MachinePrecision] * N[(20.0 / N[(a * N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(a * N[(a * -2.0), $MachinePrecision]), $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a * N[(N[(c / b), $MachinePrecision] * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\mathsf{fma}\left(-0.25, {\left(c \cdot a\right)}^{4} \cdot \frac{20}{a \cdot {b}^{7}}, \frac{\left(a \cdot \left(a \cdot -2\right)\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - a \cdot \left(\frac{c}{b} \cdot \frac{c}{b \cdot b}\right)
Initial program 31.8%
Simplified31.8%
[Start]31.8 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\] |
|---|---|
*-commutative [=>]31.8 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}}
\] |
Taylor expanded in b around inf 95.5%
Simplified95.5%
[Start]95.5 | \[ -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(-0.25 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right)
\] |
|---|---|
+-commutative [=>]95.5 | \[ \color{blue}{\left(-0.25 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right) + -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}}
\] |
Taylor expanded in c around 0 95.5%
Simplified95.5%
[Start]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{{c}^{4} \cdot \left(16 \cdot {a}^{4} + 4 \cdot {a}^{4}\right)}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
|---|---|
distribute-rgt-out [=>]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{{c}^{4} \cdot \color{blue}{\left({a}^{4} \cdot \left(16 + 4\right)\right)}}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
metadata-eval [=>]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{{c}^{4} \cdot \left({a}^{4} \cdot \color{blue}{20}\right)}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
associate-*r* [=>]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{\color{blue}{\left({c}^{4} \cdot {a}^{4}\right) \cdot 20}}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
exp-to-pow [<=]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{\left(\color{blue}{e^{\log c \cdot 4}} \cdot {a}^{4}\right) \cdot 20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
*-commutative [<=]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{\left(e^{\color{blue}{4 \cdot \log c}} \cdot {a}^{4}\right) \cdot 20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
exp-to-pow [<=]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{\left(e^{4 \cdot \log c} \cdot \color{blue}{e^{\log a \cdot 4}}\right) \cdot 20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
*-commutative [<=]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{\left(e^{4 \cdot \log c} \cdot e^{\color{blue}{4 \cdot \log a}}\right) \cdot 20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
exp-sum [<=]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{\color{blue}{e^{4 \cdot \log c + 4 \cdot \log a}} \cdot 20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
distribute-lft-out [=>]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{e^{\color{blue}{4 \cdot \left(\log c + \log a\right)}} \cdot 20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
*-commutative [=>]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{e^{\color{blue}{\left(\log c + \log a\right) \cdot 4}} \cdot 20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
log-prod [<=]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{e^{\color{blue}{\log \left(c \cdot a\right)} \cdot 4} \cdot 20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
exp-to-pow [=>]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{\color{blue}{{\left(c \cdot a\right)}^{4}} \cdot 20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
/-rgt-identity [<=]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{\color{blue}{\frac{{\left(c \cdot a\right)}^{4}}{1}} \cdot 20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
/-rgt-identity [=>]95.5 | \[ \mathsf{fma}\left(-0.25, \frac{\color{blue}{{\left(c \cdot a\right)}^{4}} \cdot 20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
associate-*r/ [<=]95.5 | \[ \mathsf{fma}\left(-0.25, \color{blue}{{\left(c \cdot a\right)}^{4} \cdot \frac{20}{a \cdot {b}^{7}}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
Applied egg-rr95.5%
[Start]95.5 | \[ \mathsf{fma}\left(-0.25, {\left(c \cdot a\right)}^{4} \cdot \frac{20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a
\] |
|---|---|
unpow3 [=>]95.5 | \[ \mathsf{fma}\left(-0.25, {\left(c \cdot a\right)}^{4} \cdot \frac{20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{\color{blue}{\left(b \cdot b\right) \cdot b}} \cdot a
\] |
times-frac [=>]95.5 | \[ \mathsf{fma}\left(-0.25, {\left(c \cdot a\right)}^{4} \cdot \frac{20}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \color{blue}{\left(\frac{c}{b \cdot b} \cdot \frac{c}{b}\right)} \cdot a
\] |
Final simplification95.5%
| Alternative 1 | |
|---|---|
| Accuracy | 93.9% |
| Cost | 14528 |
| Alternative 2 | |
|---|---|
| Accuracy | 90.7% |
| Cost | 7232 |
| Alternative 3 | |
|---|---|
| Accuracy | 90.4% |
| Cost | 7168 |
| Alternative 4 | |
|---|---|
| Accuracy | 90.2% |
| Cost | 1600 |
| Alternative 5 | |
|---|---|
| Accuracy | 81.0% |
| Cost | 256 |
herbie shell --seed 2023153
(FPCore (a b c)
:name "Quadratic roots, 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) (* (* 4.0 a) c)))) (* 2.0 a)))