Average Error: 19.5 → 6.6
Time: 20.7s
Precision: binary64
Cost: 38052
\[\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 := \frac{2 \cdot c}{-\left(b + b\right)}\\ t_1 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\ t_2 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1 - b}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;t_2 \leq -1 \cdot 10^{-285}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(\frac{c}{b}, a, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot \left(a \cdot -2\right)}{b}}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;t_2 \leq 10^{+264}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \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 (/ (* 2.0 c) (- (+ b b))))
        (t_1 (sqrt (- (* b b) (* c (* 4.0 a)))))
        (t_2
         (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_1)) (/ (- t_1 b) (* 2.0 a)))))
   (if (<= t_2 (- INFINITY))
     (if (>= b 0.0) t_0 (/ (* b -2.0) (* 2.0 a)))
     (if (<= t_2 -1e-285)
       t_2
       (if (<= t_2 0.0)
         (if (>= b 0.0)
           (/ (* 2.0 c) (* 2.0 (fma (/ c b) a (- b))))
           (/ (/ (* c (* a -2.0)) b) (* 2.0 a)))
         (if (<= t_2 1e+264) t_2 (if (>= b 0.0) t_0 (- (/ c b) (/ b a)))))))))
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 = (2.0 * c) / -(b + b);
	double t_1 = sqrt(((b * b) - (c * (4.0 * a))));
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - t_1);
	} else {
		tmp = (t_1 - b) / (2.0 * a);
	}
	double t_2 = tmp;
	double tmp_2;
	if (t_2 <= -((double) INFINITY)) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = t_0;
		} else {
			tmp_3 = (b * -2.0) / (2.0 * a);
		}
		tmp_2 = tmp_3;
	} else if (t_2 <= -1e-285) {
		tmp_2 = t_2;
	} else if (t_2 <= 0.0) {
		double tmp_4;
		if (b >= 0.0) {
			tmp_4 = (2.0 * c) / (2.0 * fma((c / b), a, -b));
		} else {
			tmp_4 = ((c * (a * -2.0)) / b) / (2.0 * a);
		}
		tmp_2 = tmp_4;
	} else if (t_2 <= 1e+264) {
		tmp_2 = t_2;
	} else if (b >= 0.0) {
		tmp_2 = t_0;
	} else {
		tmp_2 = (c / b) - (b / a);
	}
	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 = Float64(Float64(2.0 * c) / Float64(-Float64(b + b)))
	t_1 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a))))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_1));
	else
		tmp = Float64(Float64(t_1 - b) / Float64(2.0 * a));
	end
	t_2 = tmp
	tmp_2 = 0.0
	if (t_2 <= Float64(-Inf))
		tmp_3 = 0.0
		if (b >= 0.0)
			tmp_3 = t_0;
		else
			tmp_3 = Float64(Float64(b * -2.0) / Float64(2.0 * a));
		end
		tmp_2 = tmp_3;
	elseif (t_2 <= -1e-285)
		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(2.0 * fma(Float64(c / b), a, Float64(-b))));
		else
			tmp_4 = Float64(Float64(Float64(c * Float64(a * -2.0)) / b) / Float64(2.0 * a));
		end
		tmp_2 = tmp_4;
	elseif (t_2 <= 1e+264)
		tmp_2 = t_2;
	elseif (b >= 0.0)
		tmp_2 = t_0;
	else
		tmp_2 = Float64(Float64(c / b) - Float64(b / a));
	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[(N[(2.0 * c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$2, (-Infinity)], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[t$95$2, -1e-285], t$95$2, If[LessEqual[t$95$2, 0.0], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(c / b), $MachinePrecision] * a + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(a * -2.0), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[t$95$2, 1e+264], t$95$2, If[GreaterEqual[b, 0.0], t$95$0, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\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 := \frac{2 \cdot c}{-\left(b + b\right)}\\
t_1 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_2 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_1}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_1 - b}{2 \cdot a}\\


\end{array}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\


\end{array}\\

\mathbf{elif}\;t_2 \leq -1 \cdot 10^{-285}:\\
\;\;\;\;t_2\\

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

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


\end{array}\\

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

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\


\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 64.0

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

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

      \[\leadsto \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} \]
      Proof
      (*.f64 b -2): 0 points increase in error, 0 points decrease in error
      (Rewrite<= *-commutative_binary64 (*.f64 -2 b)): 0 points increase in error, 0 points decrease in error

    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))) < -1.00000000000000007e-285 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.00000000000000004e264

    1. Initial program 2.7

      \[\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 -1.00000000000000007e-285 < (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 38.2

      \[\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. Applied egg-rr38.2

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{2 \cdot \mathsf{fma}\left(\frac{c}{b}, 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} \]
      Proof
      (*.f64 2 (fma.f64 (/.f64 c b) a (neg.f64 b))): 0 points increase in error, 0 points decrease in error
      (*.f64 2 (Rewrite<= fma-neg_binary64 (-.f64 (*.f64 (/.f64 c b) a) b))): 2 points increase in error, 0 points decrease in error
      (*.f64 2 (-.f64 (Rewrite<= associate-/r/_binary64 (/.f64 c (/.f64 b a))) b)): 18 points increase in error, 15 points decrease in error
      (*.f64 2 (-.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 c a) b)) b)): 19 points increase in error, 16 points decrease in error
      (*.f64 2 (Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 (*.f64 c a) b) (neg.f64 b)))): 0 points increase in error, 0 points decrease in error
      (*.f64 2 (+.f64 (/.f64 (*.f64 c a) b) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 b)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= distribute-lft-out_binary64 (+.f64 (*.f64 2 (/.f64 (*.f64 c a) b)) (*.f64 2 (*.f64 -1 b)))): 0 points increase in error, 0 points decrease in error
    5. Taylor expanded in b around inf 10.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(\frac{c}{b}, a, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \frac{c \cdot a}{b}}{2 \cdot a}\\ \end{array} \]
    6. Simplified10.7

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

    if 1.00000000000000004e264 < (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 57.7

      \[\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 52.2

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
      Proof
      (-.f64 (/.f64 c b) (/.f64 b a)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 c b) (neg.f64 (/.f64 b a)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 c b) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 b a)))): 0 points increase in error, 0 points decrease in error
  3. Recombined 4 regimes into one program.
  4. Final simplification6.6

    \[\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(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array} \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{-\left(b + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{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(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array} \leq -1 \cdot 10^{-285}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\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(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array} \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(\frac{c}{b}, a, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot \left(a \cdot -2\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(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array} \leq 10^{+264}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{-\left(b + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]

Alternatives

Alternative 1
Error7.3
Cost7952
\[\begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\ t_1 := \frac{t_0 - b}{2 \cdot a}\\ \mathbf{if}\;b \leq -9.4 \cdot 10^{+151}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{-\left(b + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{elif}\;b \leq -2 \cdot 10^{-295}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array}\\ \mathbf{elif}\;b \leq 4.6 \cdot 10^{+42}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -2, \left(2 \cdot a\right) \cdot \frac{c}{b}\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(\frac{c}{b}, a, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error7.2
Cost7952
\[\begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\ t_1 := \frac{t_0 - b}{2 \cdot a}\\ t_2 := -\left(b + b\right)\\ \mathbf{if}\;b \leq -9.4 \cdot 10^{+151}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{t_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{elif}\;b \leq -2 \cdot 10^{-295}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array}\\ \mathbf{elif}\;b \leq 4.6 \cdot 10^{+42}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_2}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(\frac{c}{b}, a, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error14.7
Cost7756
\[\begin{array}{l} \mathbf{if}\;b \leq -9.4 \cdot 10^{+151}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{-\left(b + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{elif}\;b \leq 7.8 \cdot 10^{-300}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(\frac{c}{b}, a, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot \left(a \cdot -2\right)}{b}}{2 \cdot a}\\ \end{array} \]
Alternative 4
Error14.7
Cost7624
\[\begin{array}{l} \mathbf{if}\;b \leq -9.4 \cdot 10^{+151}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{-\left(b + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(\frac{c}{b}, a, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array} \]
Alternative 5
Error18.6
Cost7368
\[\begin{array}{l} t_0 := \frac{2 \cdot c}{-\left(b + b\right)}\\ \mathbf{if}\;b \leq -8.5 \cdot 10^{-128}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{2 \cdot a}\\ \end{array} \]
Alternative 6
Error22.9
Cost644
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{-\left(b + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 7
Error22.9
Cost644
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{-\left(b + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]

Error

Reproduce

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