# ?

Average Error: 60.1 → 0.6
Time: 13.1s
Precision: binary64
Cost: 53504

# ?

$\left(\left(-173.99999999999932 \leq b \land b \leq -173.99999999999932\right) \land \left(-1 \leq a \land a \leq 1\right)\right) \land \left(22706.999999999647 \leq c \land c \leq 22706.999999999647\right)$
$\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}$
$\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{{\left(c \cdot a\right)}^{4}}{{b}^{7}} \cdot \frac{20}{a}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$
(FPCore (b a c)
:precision binary64
(/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (b a c)
:precision binary64
(fma
-1.0
(/ (* c c) (/ (pow b 3.0) a))
(fma
-0.25
(* (/ (pow (* c a) 4.0) (pow b 7.0)) (/ 20.0 a))
(fma -1.0 (/ c b) (* -2.0 (/ (* (pow c 3.0) (* a a)) (pow b 5.0)))))))
double code(double b, double a, double c) {
return (-b - sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}

double code(double b, double a, double c) {
return fma(-1.0, ((c * c) / (pow(b, 3.0) / a)), fma(-0.25, ((pow((c * a), 4.0) / pow(b, 7.0)) * (20.0 / a)), fma(-1.0, (c / b), (-2.0 * ((pow(c, 3.0) * (a * a)) / pow(b, 5.0))))));
}

function code(b, a, c)
return Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a))
end

function code(b, a, c)
return fma(-1.0, Float64(Float64(c * c) / Float64((b ^ 3.0) / a)), fma(-0.25, Float64(Float64((Float64(c * a) ^ 4.0) / (b ^ 7.0)) * Float64(20.0 / a)), fma(-1.0, Float64(c / b), Float64(-2.0 * Float64(Float64((c ^ 3.0) * Float64(a * a)) / (b ^ 5.0))))))
end

code[b_, a_, 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[b_, a_, c_] := N[(-1.0 * N[(N[(c * c), $MachinePrecision] / N[(N[Power[b, 3.0],$MachinePrecision] / a), $MachinePrecision]),$MachinePrecision] + N[(-0.25 * N[(N[(N[Power[N[(c * a), $MachinePrecision], 4.0],$MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]),$MachinePrecision] * N[(20.0 / a), $MachinePrecision]),$MachinePrecision] + N[(-1.0 * N[(c / b), $MachinePrecision] + N[(-2.0 * N[(N[(N[Power[c, 3.0],$MachinePrecision] * N[(a * a), $MachinePrecision]),$MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]),$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(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{{\left(c \cdot a\right)}^{4}}{{b}^{7}} \cdot \frac{20}{a}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)


# Derivation?

1. Initial program 60.1

$\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}$
2. Taylor expanded in b around -inf 0.4

$\leadsto \color{blue}{-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)}$
3. Simplified0.4

$\leadsto \color{blue}{\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{{\left(-2 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)}$
Proof
[Start]0.4 $-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)$ $\color{blue}{\mathsf{fma}\left(-1, \frac{{c}^{2} \cdot a}{{b}^{3}}, -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)}$ $\mathsf{fma}\left(-1, \color{blue}{\frac{{c}^{2}}{\frac{{b}^{3}}{a}}}, -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)$ $\mathsf{fma}\left(-1, \frac{\color{blue}{c \cdot c}}{\frac{{b}^{3}}{a}}, -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)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \color{blue}{\mathsf{fma}\left(-0.25, \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}}, -1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)}\right)$
4. Taylor expanded in c around 0 0.4

$\leadsto \mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \color{blue}{\frac{{c}^{4} \cdot \left(16 \cdot {a}^{4} + 4 \cdot {a}^{4}\right)}{a \cdot {b}^{7}}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$
5. Simplified0.6

$\leadsto \mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \color{blue}{\frac{{\left(c \cdot a\right)}^{4}}{{b}^{7}} \cdot \frac{20}{a}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$
Proof
[Start]0.4 $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{{c}^{4} \cdot \left(16 \cdot {a}^{4} + 4 \cdot {a}^{4}\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{{c}^{4} \cdot \color{blue}{\left(4 \cdot {a}^{4} + 16 \cdot {a}^{4}\right)}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{{c}^{4} \cdot \color{blue}{\left({a}^{4} \cdot \left(4 + 16\right)\right)}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\color{blue}{\left({c}^{4} \cdot {a}^{4}\right) \cdot \left(4 + 16\right)}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\left({c}^{4} \cdot {a}^{\color{blue}{\left(2 \cdot 2\right)}}\right) \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\left({c}^{4} \cdot \color{blue}{\left({a}^{2} \cdot {a}^{2}\right)}\right) \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\left({c}^{4} \cdot \left(\color{blue}{\left(a \cdot a\right)} \cdot {a}^{2}\right)\right) \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\left({c}^{4} \cdot \left(\left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)}\right)\right) \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\left({c}^{\color{blue}{\left(2 \cdot 2\right)}} \cdot \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right)\right)\right) \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\left(\color{blue}{\left({c}^{2} \cdot {c}^{2}\right)} \cdot \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right)\right)\right) \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\left(\left(\color{blue}{\left(c \cdot c\right)} \cdot {c}^{2}\right) \cdot \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right)\right)\right) \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\left(\left(\left(c \cdot c\right) \cdot \color{blue}{\left(c \cdot c\right)}\right) \cdot \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right)\right)\right) \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\color{blue}{\left(\left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right) \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)} \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\left(\color{blue}{\left(\left(c \cdot a\right) \cdot \left(c \cdot a\right)\right)} \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right) \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\left(\color{blue}{{\left(c \cdot a\right)}^{2}} \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right) \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\left({\left(c \cdot a\right)}^{2} \cdot \color{blue}{\left(\left(c \cdot a\right) \cdot \left(c \cdot a\right)\right)}\right) \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\left({\left(c \cdot a\right)}^{2} \cdot \color{blue}{{\left(c \cdot a\right)}^{2}}\right) \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{\color{blue}{{\left(c \cdot a\right)}^{\left(2 \cdot 2\right)}} \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$ $\mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{{\left(c \cdot a\right)}^{\color{blue}{4}} \cdot \left(4 + 16\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$
6. Final simplification0.6

$\leadsto \mathsf{fma}\left(-1, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \mathsf{fma}\left(-0.25, \frac{{\left(c \cdot a\right)}^{4}}{{b}^{7}} \cdot \frac{20}{a}, \mathsf{fma}\left(-1, \frac{c}{b}, -2 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right)\right)\right)$

# Alternatives

Alternative 1
Error0.4
Cost20736
$\left(-2 \cdot \left(\left(a \cdot a\right) \cdot \frac{{c}^{3}}{{b}^{5}}\right) - \frac{c}{b}\right) - \frac{a}{\frac{{b}^{3}}{c \cdot c}}$
Alternative 2
Error0.6
Cost7232
$\frac{-c}{b} - \frac{a}{\frac{{b}^{3}}{c \cdot c}}$
Alternative 3
Error1.2
Cost256
$\frac{-c}{b}$

# Reproduce?

herbie shell --seed 1
(FPCore (b a c)
:name "((-b) - sqrt((b*b) - (4 * a * c))) / (2 * a)"
:precision binary64
:pre (and (and (and (<= -173.99999999999932 b) (<= b -173.99999999999932)) (and (<= -1.0 a) (<= a 1.0))) (and (<= 22706.999999999647 c) (<= c 22706.999999999647)))
(/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))