| Alternative 1 | |
|---|---|
| Accuracy | 93.9% |
| Cost | 20736 |
\[\left(\frac{-2 \cdot {c}^{3}}{\frac{{b}^{5}}{a \cdot a}} - \frac{c}{b}\right) - a \cdot \frac{c}{\frac{{b}^{3}}{c}}
\]
(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 a) (/ (* (pow (* a c) 4.0) 20.0) (pow b 7.0)) (- (* -2.0 (* (* (* c c) (* c (pow b -5.0))) (* a a))) (fma (/ c (/ (pow b 3.0) c)) a (/ c 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 / a), ((pow((a * c), 4.0) * 20.0) / pow(b, 7.0)), ((-2.0 * (((c * c) * (c * pow(b, -5.0))) * (a * a))) - fma((c / (pow(b, 3.0) / c)), a, (c / 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 fma(Float64(-0.25 / a), Float64(Float64((Float64(a * c) ^ 4.0) * 20.0) / (b ^ 7.0)), Float64(Float64(-2.0 * Float64(Float64(Float64(c * c) * Float64(c * (b ^ -5.0))) * Float64(a * a))) - fma(Float64(c / Float64((b ^ 3.0) / c)), a, Float64(c / 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 / a), $MachinePrecision] * N[(N[(N[Power[N[(a * c), $MachinePrecision], 4.0], $MachinePrecision] * 20.0), $MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-2.0 * N[(N[(N[(c * c), $MachinePrecision] * N[(c * N[Power[b, -5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(c / N[(N[Power[b, 3.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] * a + N[(c / b), $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(\frac{-0.25}{a}, \frac{{\left(a \cdot c\right)}^{4} \cdot 20}{{b}^{7}}, -2 \cdot \left(\left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
Initial program 31.6%
Simplified31.7%
[Start]31.6 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\] |
|---|---|
*-commutative [=>]31.6 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}}
\] |
+-commutative [=>]31.6 | \[ \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}}{a \cdot 2}
\] |
unsub-neg [=>]31.6 | \[ \frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}{a \cdot 2}
\] |
fma-neg [=>]31.7 | \[ \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b}{a \cdot 2}
\] |
associate-*l* [=>]31.7 | \[ \frac{\sqrt{\mathsf{fma}\left(b, b, -\color{blue}{4 \cdot \left(a \cdot c\right)}\right)} - b}{a \cdot 2}
\] |
*-commutative [=>]31.7 | \[ \frac{\sqrt{\mathsf{fma}\left(b, b, -\color{blue}{\left(a \cdot c\right) \cdot 4}\right)} - b}{a \cdot 2}
\] |
distribute-rgt-neg-in [=>]31.7 | \[ \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(a \cdot c\right) \cdot \left(-4\right)}\right)} - b}{a \cdot 2}
\] |
metadata-eval [=>]31.7 | \[ \frac{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot \color{blue}{-4}\right)} - b}{a \cdot 2}
\] |
Taylor expanded in b around inf 95.1%
Simplified95.1%
[Start]95.1 | \[ -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.1 | \[ \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}}}
\] |
associate-+l+ [=>]95.1 | \[ \color{blue}{-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(\left(-1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right) + -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)}
\] |
associate-*r/ [=>]95.1 | \[ \color{blue}{\frac{-0.25 \cdot \left({\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)\right)}{a \cdot {b}^{7}}} + \left(\left(-1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right) + -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)
\] |
times-frac [=>]95.1 | \[ \color{blue}{\frac{-0.25}{a} \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{{b}^{7}}} + \left(\left(-1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right) + -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)
\] |
+-commutative [<=]95.1 | \[ \frac{-0.25}{a} \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{{b}^{7}} + \color{blue}{\left(-1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(-1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right)}
\] |
fma-def [=>]95.1 | \[ \color{blue}{\mathsf{fma}\left(\frac{-0.25}{a}, \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{{b}^{7}}, -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(-1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right)}
\] |
Applied egg-rr94.5%
[Start]95.1 | \[ \mathsf{fma}\left(\frac{-0.25}{a}, \frac{\left({c}^{4} \cdot {a}^{4}\right) \cdot 20}{{b}^{7}}, -2 \cdot \left(\frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
\] |
|---|---|
expm1-log1p-u [=>]95.1 | \[ \mathsf{fma}\left(\frac{-0.25}{a}, \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({c}^{4} \cdot {a}^{4}\right)\right)} \cdot 20}{{b}^{7}}, -2 \cdot \left(\frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
\] |
expm1-udef [=>]94.5 | \[ \mathsf{fma}\left(\frac{-0.25}{a}, \frac{\color{blue}{\left(e^{\mathsf{log1p}\left({c}^{4} \cdot {a}^{4}\right)} - 1\right)} \cdot 20}{{b}^{7}}, -2 \cdot \left(\frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
\] |
pow-prod-down [=>]94.5 | \[ \mathsf{fma}\left(\frac{-0.25}{a}, \frac{\left(e^{\mathsf{log1p}\left(\color{blue}{{\left(c \cdot a\right)}^{4}}\right)} - 1\right) \cdot 20}{{b}^{7}}, -2 \cdot \left(\frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
\] |
Simplified95.1%
[Start]94.5 | \[ \mathsf{fma}\left(\frac{-0.25}{a}, \frac{\left(e^{\mathsf{log1p}\left({\left(c \cdot a\right)}^{4}\right)} - 1\right) \cdot 20}{{b}^{7}}, -2 \cdot \left(\frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
\] |
|---|---|
expm1-def [=>]95.1 | \[ \mathsf{fma}\left(\frac{-0.25}{a}, \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(c \cdot a\right)}^{4}\right)\right)} \cdot 20}{{b}^{7}}, -2 \cdot \left(\frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
\] |
expm1-log1p [=>]95.1 | \[ \mathsf{fma}\left(\frac{-0.25}{a}, \frac{\color{blue}{{\left(c \cdot a\right)}^{4}} \cdot 20}{{b}^{7}}, -2 \cdot \left(\frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
\] |
Applied egg-rr95.1%
[Start]95.1 | \[ \mathsf{fma}\left(\frac{-0.25}{a}, \frac{{\left(c \cdot a\right)}^{4} \cdot 20}{{b}^{7}}, -2 \cdot \left(\frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
\] |
|---|---|
div-inv [=>]95.1 | \[ \mathsf{fma}\left(\frac{-0.25}{a}, \frac{{\left(c \cdot a\right)}^{4} \cdot 20}{{b}^{7}}, -2 \cdot \left(\color{blue}{\left({c}^{3} \cdot \frac{1}{{b}^{5}}\right)} \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
\] |
unpow3 [=>]95.1 | \[ \mathsf{fma}\left(\frac{-0.25}{a}, \frac{{\left(c \cdot a\right)}^{4} \cdot 20}{{b}^{7}}, -2 \cdot \left(\left(\color{blue}{\left(\left(c \cdot c\right) \cdot c\right)} \cdot \frac{1}{{b}^{5}}\right) \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
\] |
associate-*l* [=>]95.1 | \[ \mathsf{fma}\left(\frac{-0.25}{a}, \frac{{\left(c \cdot a\right)}^{4} \cdot 20}{{b}^{7}}, -2 \cdot \left(\color{blue}{\left(\left(c \cdot c\right) \cdot \left(c \cdot \frac{1}{{b}^{5}}\right)\right)} \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
\] |
pow-flip [=>]95.1 | \[ \mathsf{fma}\left(\frac{-0.25}{a}, \frac{{\left(c \cdot a\right)}^{4} \cdot 20}{{b}^{7}}, -2 \cdot \left(\left(\left(c \cdot c\right) \cdot \left(c \cdot \color{blue}{{b}^{\left(-5\right)}}\right)\right) \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
\] |
metadata-eval [=>]95.1 | \[ \mathsf{fma}\left(\frac{-0.25}{a}, \frac{{\left(c \cdot a\right)}^{4} \cdot 20}{{b}^{7}}, -2 \cdot \left(\left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{\color{blue}{-5}}\right)\right) \cdot \left(a \cdot a\right)\right) - \mathsf{fma}\left(\frac{c}{\frac{{b}^{3}}{c}}, a, \frac{c}{b}\right)\right)
\] |
Final simplification95.1%
| Alternative 1 | |
|---|---|
| Accuracy | 93.9% |
| Cost | 20736 |
| Alternative 2 | |
|---|---|
| Accuracy | 93.9% |
| Cost | 20736 |
| Alternative 3 | |
|---|---|
| Accuracy | 90.7% |
| Cost | 1024 |
| Alternative 4 | |
|---|---|
| Accuracy | 81.0% |
| Cost | 256 |
| Alternative 5 | |
|---|---|
| Accuracy | 3.2% |
| Cost | 64 |
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)))