Average Error: 34.3 → 10.1
Time: 6.5s
Precision: binary64
\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.102385277532225 \cdot 10^{-63}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 9.108292722462307 \cdot 10^{+85}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(b_2, b_2, \mathsf{fma}\left(a, -c, \mathsf{fma}\left(a, -c, c \cdot a\right)\right)\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\ \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -1.102385277532225e-63)
   (/ (* -0.5 c) b_2)
   (if (<= b_2 9.108292722462307e+85)
     (/ (- (- b_2) (sqrt (fma b_2 b_2 (fma a (- c) (fma a (- c) (* c a)))))) a)
     (fma 0.5 (/ c b_2) (* -2.0 (/ b_2 a))))))
double code(double a, double b_2, double c) {
	return (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
}
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -1.102385277532225e-63) {
		tmp = (-0.5 * c) / b_2;
	} else if (b_2 <= 9.108292722462307e+85) {
		tmp = (-b_2 - sqrt(fma(b_2, b_2, fma(a, -c, fma(a, -c, (c * a)))))) / a;
	} else {
		tmp = fma(0.5, (c / b_2), (-2.0 * (b_2 / a)));
	}
	return tmp;
}
function code(a, b_2, c)
	return Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a)
end
function code(a, b_2, c)
	tmp = 0.0
	if (b_2 <= -1.102385277532225e-63)
		tmp = Float64(Float64(-0.5 * c) / b_2);
	elseif (b_2 <= 9.108292722462307e+85)
		tmp = Float64(Float64(Float64(-b_2) - sqrt(fma(b_2, b_2, fma(a, Float64(-c), fma(a, Float64(-c), Float64(c * a)))))) / a);
	else
		tmp = fma(0.5, Float64(c / b_2), Float64(-2.0 * Float64(b_2 / a)));
	end
	return tmp
end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.102385277532225e-63], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 9.108292722462307e+85], N[(N[((-b$95$2) - N[Sqrt[N[(b$95$2 * b$95$2 + N[(a * (-c) + N[(a * (-c) + N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(0.5 * N[(c / b$95$2), $MachinePrecision] + N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.102385277532225 \cdot 10^{-63}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\

\mathbf{elif}\;b_2 \leq 9.108292722462307 \cdot 10^{+85}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(b_2, b_2, \mathsf{fma}\left(a, -c, \mathsf{fma}\left(a, -c, c \cdot a\right)\right)\right)}}{a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\


\end{array}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b_2 < -1.10238527753222506e-63

    1. Initial program 53.2

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Taylor expanded in b_2 around -inf 8.7

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    3. Applied egg-rr8.7

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]

    if -1.10238527753222506e-63 < b_2 < 9.10829272246230701e85

    1. Initial program 13.7

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Applied egg-rr13.7

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\mathsf{fma}\left(b_2, b_2, \mathsf{fma}\left(a, -c, \mathsf{fma}\left(a, -c, a \cdot c\right)\right)\right)}}}{a} \]

    if 9.10829272246230701e85 < b_2

    1. Initial program 45.4

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Taylor expanded in b_2 around inf 3.9

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}} \]
    3. Simplified3.9

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.102385277532225 \cdot 10^{-63}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 9.108292722462307 \cdot 10^{+85}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(b_2, b_2, \mathsf{fma}\left(a, -c, \mathsf{fma}\left(a, -c, c \cdot a\right)\right)\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022133 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))