Average Error: 20.1 → 6.9
Time: 16.8s
Precision: binary64
Cost: 57188
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
\[\begin{array}{l} t_0 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\\ t_1 := \frac{t_0 - b}{2 \cdot a}\\ t_2 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_0}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array}\\ t_3 := \frac{\left(-b\right) - b}{2 \cdot a}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;{\left(\sqrt[3]{\frac{c \cdot -2}{\mathsf{fma}\left(\sqrt{a \cdot -4}, \sqrt{c}, b\right)}}\right)}^{3}\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array}\\ \mathbf{elif}\;t_2 \leq -4 \cdot 10^{-223}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array}\\ \mathbf{elif}\;t_2 \leq 10^{+276}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, -\mathsf{fma}\left(\frac{a}{\frac{b}{c}}, -2, b\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (>= b 0.0)
   (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))
   (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (+ (* b b) (* c (* a -4.0)))))
        (t_1 (/ (- t_0 b) (* 2.0 a)))
        (t_2 (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) t_1))
        (t_3 (/ (- (- b) b) (* 2.0 a))))
   (if (<= t_2 (- INFINITY))
     (if (>= b 0.0)
       (pow (cbrt (/ (* c -2.0) (fma (sqrt (* a -4.0)) (sqrt c) b))) 3.0)
       t_3)
     (if (<= t_2 -4e-223)
       t_2
       (if (<= t_2 0.0)
         (if (>= b 0.0) (/ (* 2.0 c) (- (- b) (fma -2.0 (* a (/ c b)) b))) t_1)
         (if (<= t_2 1e+276)
           t_2
           (if (>= b 0.0)
             (/
              (* 2.0 c)
              (fma (sqrt b) (- (sqrt b)) (- (fma (/ a (/ b c)) -2.0 b))))
             t_3)))))))
double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - sqrt(((b * b) - ((4.0 * a) * c))));
	} else {
		tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
	}
	return tmp;
}
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) + (c * (a * -4.0))));
	double t_1 = (t_0 - b) / (2.0 * a);
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - t_0);
	} else {
		tmp = t_1;
	}
	double t_2 = tmp;
	double t_3 = (-b - b) / (2.0 * a);
	double tmp_2;
	if (t_2 <= -((double) INFINITY)) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = pow(cbrt(((c * -2.0) / fma(sqrt((a * -4.0)), sqrt(c), b))), 3.0);
		} else {
			tmp_3 = t_3;
		}
		tmp_2 = tmp_3;
	} else if (t_2 <= -4e-223) {
		tmp_2 = t_2;
	} else if (t_2 <= 0.0) {
		double tmp_4;
		if (b >= 0.0) {
			tmp_4 = (2.0 * c) / (-b - fma(-2.0, (a * (c / b)), b));
		} else {
			tmp_4 = t_1;
		}
		tmp_2 = tmp_4;
	} else if (t_2 <= 1e+276) {
		tmp_2 = t_2;
	} else if (b >= 0.0) {
		tmp_2 = (2.0 * c) / fma(sqrt(b), -sqrt(b), -fma((a / (b / c)), -2.0, b));
	} else {
		tmp_2 = t_3;
	}
	return tmp_2;
}
function code(a, b, c)
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))));
	else
		tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a));
	end
	return tmp
end
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(b * b) + Float64(c * Float64(a * -4.0))))
	t_1 = Float64(Float64(t_0 - b) / Float64(2.0 * a))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0));
	else
		tmp = t_1;
	end
	t_2 = tmp
	t_3 = Float64(Float64(Float64(-b) - b) / Float64(2.0 * a))
	tmp_2 = 0.0
	if (t_2 <= Float64(-Inf))
		tmp_3 = 0.0
		if (b >= 0.0)
			tmp_3 = cbrt(Float64(Float64(c * -2.0) / fma(sqrt(Float64(a * -4.0)), sqrt(c), b))) ^ 3.0;
		else
			tmp_3 = t_3;
		end
		tmp_2 = tmp_3;
	elseif (t_2 <= -4e-223)
		tmp_2 = t_2;
	elseif (t_2 <= 0.0)
		tmp_4 = 0.0
		if (b >= 0.0)
			tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - fma(-2.0, Float64(a * Float64(c / b)), b)));
		else
			tmp_4 = t_1;
		end
		tmp_2 = tmp_4;
	elseif (t_2 <= 1e+276)
		tmp_2 = t_2;
	elseif (b >= 0.0)
		tmp_2 = Float64(Float64(2.0 * c) / fma(sqrt(b), Float64(-sqrt(b)), Float64(-fma(Float64(a / Float64(b / c)), -2.0, b))));
	else
		tmp_2 = t_3;
	end
	return tmp_2
end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]}, Block[{t$95$3 = N[(N[((-b) - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], If[GreaterEqual[b, 0.0], N[Power[N[Power[N[(N[(c * -2.0), $MachinePrecision] / N[(N[Sqrt[N[(a * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[c], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], t$95$3], If[LessEqual[t$95$2, -4e-223], t$95$2, If[LessEqual[t$95$2, 0.0], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1], If[LessEqual[t$95$2, 1e+276], t$95$2, If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(N[Sqrt[b], $MachinePrecision] * (-N[Sqrt[b], $MachinePrecision]) + (-N[(N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision] * -2.0 + b), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]]]
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\


\end{array}
\begin{array}{l}
t_0 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\\
t_1 := \frac{t_0 - b}{2 \cdot a}\\
t_2 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_0}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}\\
t_3 := \frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;{\left(\sqrt[3]{\frac{c \cdot -2}{\mathsf{fma}\left(\sqrt{a \cdot -4}, \sqrt{c}, b\right)}}\right)}^{3}\\

\mathbf{else}:\\
\;\;\;\;t_3\\


\end{array}\\

\mathbf{elif}\;t_2 \leq -4 \cdot 10^{-223}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}\\

\mathbf{elif}\;t_2 \leq 10^{+276}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, -\mathsf{fma}\left(\frac{a}{\frac{b}{c}}, -2, b\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;t_3\\


\end{array}

Error

Derivation

  1. Split input into 4 regimes
  2. if (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < -inf.0

    1. Initial program 64.0

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Taylor expanded in b around -inf 19.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
    3. Taylor expanded in b around 0 19.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{-4 \cdot \left(c \cdot a\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
    4. Simplified19.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{c \cdot \left(a \cdot -4\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
      Proof
      (*.f64 c (*.f64 a -4)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 c a) -4)): 4 points increase in error, 0 points decrease in error
      (Rewrite<= *-commutative_binary64 (*.f64 -4 (*.f64 c a))): 0 points increase in error, 0 points decrease in error
    5. Applied egg-rr19.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{{\left(\sqrt[3]{\frac{c \cdot -2}{\mathsf{fma}\left(\sqrt{a \cdot -4}, \sqrt{c}, b\right)}}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]

    if -inf.0 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < -3.9999999999999999e-223 or -0.0 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < 1.0000000000000001e276

    1. Initial program 2.9

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]

    if -3.9999999999999999e-223 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < -0.0

    1. Initial program 34.0

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Taylor expanded in b around inf 12.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b + -2 \cdot \frac{c \cdot a}{b}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    3. Simplified11.1

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      Proof
      (fma.f64 -2 (*.f64 a (/.f64 c b)) b): 0 points increase in error, 0 points decrease in error
      (fma.f64 -2 (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 c b) a)) b): 0 points increase in error, 0 points decrease in error
      (fma.f64 -2 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 c a) b)) b): 17 points increase in error, 23 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 -2 (/.f64 (*.f64 c a) b)) b)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 b (*.f64 -2 (/.f64 (*.f64 c a) b)))): 0 points increase in error, 0 points decrease in error

    if 1.0000000000000001e276 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)))

    1. Initial program 59.8

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Taylor expanded in b around -inf 18.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
    3. Taylor expanded in b around inf 18.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b + -2 \cdot \frac{c \cdot a}{b}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
    4. Simplified12.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
      Proof
      (fma.f64 -2 (*.f64 a (/.f64 c b)) b): 0 points increase in error, 0 points decrease in error
      (fma.f64 -2 (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 c b) a)) b): 0 points increase in error, 0 points decrease in error
      (fma.f64 -2 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 c a) b)) b): 17 points increase in error, 23 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 -2 (/.f64 (*.f64 c a) b)) b)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 b (*.f64 -2 (/.f64 (*.f64 c a) b)))): 0 points increase in error, 0 points decrease in error
    5. Applied egg-rr12.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, -\mathsf{fma}\left(\frac{a}{\frac{b}{c}}, -2, b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{2 \cdot a}\\ \end{array} \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;{\left(\sqrt[3]{\frac{c \cdot -2}{\mathsf{fma}\left(\sqrt{a \cdot -4}, \sqrt{c}, b\right)}}\right)}^{3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{2 \cdot a}\\ \end{array} \leq -4 \cdot 10^{-223}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{2 \cdot a}\\ \end{array} \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{2 \cdot a}\\ \end{array} \leq 10^{+276}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, -\mathsf{fma}\left(\frac{a}{\frac{b}{c}}, -2, b\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\ \end{array} \]

Alternatives

Alternative 1
Error11.2
Cost7888
\[\begin{array}{l} t_0 := c \cdot \left(a \cdot -4\right)\\ t_1 := \left(-b\right) - b\\ t_2 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;b \leq -4 \cdot 10^{-110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq -9.2 \cdot 10^{-298}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{t_0} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 1.8 \cdot 10^{+27}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \sqrt{b \cdot b + t_0}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, -2, 2 \cdot \frac{c \cdot a}{b}\right) \cdot \frac{0.5}{a}\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error18.6
Cost7368
\[\begin{array}{l} t_0 := \left(-b\right) - b\\ \mathbf{if}\;b \leq 10^{-36}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{b - \sqrt{c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b}\\ \end{array} \]
Alternative 3
Error22.9
Cost644
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]

Error

Reproduce

herbie shell --seed 2022289 
(FPCore (a b c)
  :name "jeff quadratic root 2"
  :precision binary64
  (if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))