Average Error: 28.4 → 5.7
Time: 11.4s
Precision: binary64
Cost: 34432
\[\left(\left(1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156\right) \land \left(1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156\right)\right) \land \left(1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\right)\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
\[\mathsf{fma}\left(-2, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), -5 \cdot \frac{{\left(c \cdot a\right)}^{3}}{\frac{{b}^{7}}{c}}\right) - \mathsf{fma}\left(\frac{c}{b \cdot b} \cdot \frac{c}{b}, a, \frac{c}{b}\right) \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
 :precision binary64
 (-
  (fma
   -2.0
   (* (* (* c c) (* c (pow b -5.0))) (* a a))
   (* -5.0 (/ (pow (* c a) 3.0) (/ (pow b 7.0) c))))
  (fma (* (/ c (* b b)) (/ c b)) 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(-2.0, (((c * c) * (c * pow(b, -5.0))) * (a * a)), (-5.0 * (pow((c * a), 3.0) / (pow(b, 7.0) / c)))) - fma(((c / (b * b)) * (c / b)), 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 Float64(fma(-2.0, Float64(Float64(Float64(c * c) * Float64(c * (b ^ -5.0))) * Float64(a * a)), Float64(-5.0 * Float64((Float64(c * a) ^ 3.0) / Float64((b ^ 7.0) / c)))) - fma(Float64(Float64(c / Float64(b * b)) * Float64(c / b)), 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[(-2.0 * N[(N[(N[(c * c), $MachinePrecision] * N[(c * N[Power[b, -5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(-5.0 * N[(N[Power[N[(c * a), $MachinePrecision], 3.0], $MachinePrecision] / N[(N[Power[b, 7.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * N[(c / b), $MachinePrecision]), $MachinePrecision] * a + N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\mathsf{fma}\left(-2, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), -5 \cdot \frac{{\left(c \cdot a\right)}^{3}}{\frac{{b}^{7}}{c}}\right) - \mathsf{fma}\left(\frac{c}{b \cdot b} \cdot \frac{c}{b}, a, \frac{c}{b}\right)

Error

Derivation

  1. Initial program 28.4

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Simplified28.3

    \[\leadsto \color{blue}{\left(\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b\right) \cdot \frac{0.5}{a}} \]
  3. Taylor expanded in a around 0 5.7

    \[\leadsto \color{blue}{-1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(-1 \cdot \frac{c}{b} + \left(-0.25 \cdot \frac{{a}^{3} \cdot \left(16 \cdot \frac{{c}^{4}}{{b}^{6}} + {\left(-2 \cdot \frac{{c}^{2}}{{b}^{3}}\right)}^{2}\right)}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right)} \]
  4. Simplified5.7

    \[\leadsto \color{blue}{\mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \frac{{a}^{3} \cdot -0.25}{b} \cdot \left(\frac{{c}^{4}}{{b}^{6}} \cdot 20\right)\right) - \mathsf{fma}\left(\frac{c \cdot c}{{b}^{3}}, a, \frac{c}{b}\right)} \]
  5. Taylor expanded in a around 0 5.7

    \[\leadsto \mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \color{blue}{-5 \cdot \frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}}}\right) - \mathsf{fma}\left(\frac{c \cdot c}{{b}^{3}}, a, \frac{c}{b}\right) \]
  6. Simplified5.7

    \[\leadsto \mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), \color{blue}{-5 \cdot \frac{{\left(c \cdot a\right)}^{3}}{\frac{{b}^{7}}{c}}}\right) - \mathsf{fma}\left(\frac{c \cdot c}{{b}^{3}}, a, \frac{c}{b}\right) \]
  7. Applied egg-rr5.7

    \[\leadsto \mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}} \cdot \left(a \cdot a\right), -5 \cdot \frac{{\left(c \cdot a\right)}^{3}}{\frac{{b}^{7}}{c}}\right) - \mathsf{fma}\left(\color{blue}{\frac{c}{b \cdot b} \cdot \frac{c}{b}}, a, \frac{c}{b}\right) \]
  8. Applied egg-rr5.7

    \[\leadsto \mathsf{fma}\left(-2, \color{blue}{\left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right)} \cdot \left(a \cdot a\right), -5 \cdot \frac{{\left(c \cdot a\right)}^{3}}{\frac{{b}^{7}}{c}}\right) - \mathsf{fma}\left(\frac{c}{b \cdot b} \cdot \frac{c}{b}, a, \frac{c}{b}\right) \]
  9. Final simplification5.7

    \[\leadsto \mathsf{fma}\left(-2, \left(\left(c \cdot c\right) \cdot \left(c \cdot {b}^{-5}\right)\right) \cdot \left(a \cdot a\right), -5 \cdot \frac{{\left(c \cdot a\right)}^{3}}{\frac{{b}^{7}}{c}}\right) - \mathsf{fma}\left(\frac{c}{b \cdot b} \cdot \frac{c}{b}, a, \frac{c}{b}\right) \]

Alternatives

Alternative 1
Error7.2
Cost28036
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2} \leq -0.012:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}}\right) - \frac{c \cdot c}{{b}^{3}}\right) - \frac{c}{b}\\ \end{array} \]
Alternative 2
Error9.6
Cost21060
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2} \leq -0.0025:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b} - \frac{\frac{c \cdot \left(c \cdot a\right)}{b}}{b \cdot b}\\ \end{array} \]
Alternative 3
Error9.5
Cost21060
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2} \leq -0.0025:\\ \;\;\;\;\left(\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b\right) \cdot \frac{0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b} - \frac{\frac{c \cdot \left(c \cdot a\right)}{b}}{b \cdot b}\\ \end{array} \]
Alternative 4
Error9.5
Cost21060
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2} \leq -0.0025:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b} - \frac{\frac{c \cdot \left(c \cdot a\right)}{b}}{b \cdot b}\\ \end{array} \]
Alternative 5
Error9.6
Cost14788
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2} \leq -0.0025:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)} - b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b} - \frac{\frac{c \cdot \left(c \cdot a\right)}{b}}{b \cdot b}\\ \end{array} \]
Alternative 6
Error11.8
Cost1024
\[\frac{-c}{b} - \frac{\frac{c \cdot \left(c \cdot a\right)}{b}}{b \cdot b} \]
Alternative 7
Error22.9
Cost256
\[\frac{-c}{b} \]

Error

Reproduce

herbie shell --seed 2022284 
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :precision binary64
  :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))