Average Error: 28.6 → 0.3
Time: 5.7s
Precision: binary64
\[\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} \]
\[\frac{c \cdot -2}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot 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
 (/ (* c -2.0) (+ b (sqrt (fma a (* c -4.0) (* 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 (c * -2.0) / (b + sqrt(fma(a, (c * -4.0), (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(Float64(c * -2.0) / Float64(b + sqrt(fma(a, Float64(c * -4.0), 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[(c * -2.0), $MachinePrecision] / N[(b + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + 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}
\frac{c \cdot -2}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 28.6

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

    \[\leadsto \color{blue}{\left(\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b\right) \cdot \frac{0.5}{a}} \]
  3. Applied flip--_binary6428.6

    \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b \cdot b}{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} + b}} \cdot \frac{0.5}{a} \]
  4. Applied associate-*l/_binary6428.6

    \[\leadsto \color{blue}{\frac{\left(\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b \cdot b\right) \cdot \frac{0.5}{a}}{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} + b}} \]
  5. Simplified0.4

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

    \[\leadsto \frac{\color{blue}{-2 \cdot c}}{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} + b} \]
  7. Applied *-un-lft-identity_binary640.3

    \[\leadsto \frac{-2 \cdot c}{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} + b\right)}} \]
  8. Applied associate-/r*_binary640.3

    \[\leadsto \color{blue}{\frac{\frac{-2 \cdot c}{1}}{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} + b}} \]
  9. Simplified0.3

    \[\leadsto \frac{\color{blue}{c \cdot -2}}{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} + b} \]
  10. Final simplification0.3

    \[\leadsto \frac{c \cdot -2}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}} \]

Reproduce

herbie shell --seed 2022131 
(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)))