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

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


\end{array}\\
t_5 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_3\\

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


\end{array}\\
\mathbf{if}\;t_5 \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}\\

\mathbf{elif}\;t_5 \leq -1 \cdot 10^{-195}:\\
\;\;\;\;t_4\\

\mathbf{elif}\;t_5 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot -4} \cdot \sqrt{c}\right)\right) \cdot \frac{-0.5}{a}\\


\end{array}\\

\mathbf{elif}\;t_5 \leq 5 \cdot 10^{+259}:\\
\;\;\;\;t_4\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\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}{\color{blue}{2 \cdot \frac{c \cdot a}{b} + -2 \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    3. Simplified64.0

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\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 c (/.f64 b a)) (*.f64 b -2)): 0 points increase in error, 0 points decrease in error
      (fma.f64 2 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 c a) b)) (*.f64 b -2)): 14 points increase in error, 19 points decrease in error
      (fma.f64 2 (/.f64 (*.f64 c a) b) (Rewrite<= *-commutative_binary64 (*.f64 -2 b))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 2 (/.f64 (*.f64 c a) b)) (*.f64 -2 b))): 0 points increase in error, 0 points decrease in error
    4. Taylor expanded in c around inf 64.0

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{b}{a}\\ \end{array} \]
    6. Simplified19.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]
      Proof
      (/.f64 (neg.f64 b) a): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 b)) a): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*r/_binary64 (*.f64 -1 (/.f64 b a))): 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.0000000000000001e-195 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))) < 5.00000000000000033e259

    1. Initial program 2.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. Applied egg-rr2.8

      \[\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) + \sqrt{b \cdot b + \mathsf{fma}\left(c, a \cdot -4, \mathsf{fma}\left(c, a \cdot -4, a \cdot \left(4 \cdot c\right)\right)\right)}}{2 \cdot a}\\ \end{array} \]

    if -1.0000000000000001e-195 < (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 32.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 10.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. Applied egg-rr10.3

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)\right) \cdot \frac{-0.5}{a}\\ \end{array} \]
      Proof
      (*.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 c (*.f64 a -4))))) (/.f64 -1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 c a) -4))))) (/.f64 -1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 (Rewrite<= *-commutative_binary64 (*.f64 a c)) -4)))) (/.f64 -1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (Rewrite<= *-commutative_binary64 (*.f64 -4 (*.f64 a c)))))) (/.f64 -1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 -4 (*.f64 a c))))) (/.f64 (Rewrite<= metadata-eval (/.f64 1 -2)) a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 -4 (*.f64 a c))))) (Rewrite<= associate-/r*_binary64 (/.f64 1 (*.f64 -2 a)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 -4 (*.f64 a c))))) (/.f64 1 (Rewrite<= *-commutative_binary64 (*.f64 a -2)))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 -4 (*.f64 a c))))) 1) (*.f64 a -2))): 7 points increase in error, 25 points decrease in error
      (/.f64 (Rewrite=> *-rgt-identity_binary64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 -4 (*.f64 a c)))))) (*.f64 a -2)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-lft-identity_binary64 (+.f64 0 (/.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 -4 (*.f64 a c))))) (*.f64 a -2)))): 0 points increase in error, 0 points decrease in error
    5. Applied egg-rr10.2

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

    if 5.00000000000000033e259 < (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 56.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 53.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 15.8

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]
      Proof
      (/.f64 (neg.f64 b) a): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 b)) a): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*r/_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 simplification7.0

    \[\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:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{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 -1 \cdot 10^{-195}:\\ \;\;\;\;\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 + \mathsf{fma}\left(c, a \cdot -4, \mathsf{fma}\left(c, a \cdot -4, a \cdot \left(c \cdot 4\right)\right)\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) - b}\\ \mathbf{else}:\\ \;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot -4} \cdot \sqrt{c}\right)\right) \cdot \frac{-0.5}{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 5 \cdot 10^{+259}:\\ \;\;\;\;\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 + \mathsf{fma}\left(c, a \cdot -4, \mathsf{fma}\left(c, a \cdot -4, a \cdot \left(c \cdot 4\right)\right)\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]

Alternatives

Alternative 1
Error7.0
Cost42972
\[\begin{array}{l} t_0 := \frac{2 \cdot c}{\left(-b\right) - b}\\ t_1 := \frac{-b}{a}\\ t_2 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\\ t_3 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_2 - b}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array}\\ \mathbf{elif}\;t_3 \leq -1 \cdot 10^{-195}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_3 \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot -4} \cdot \sqrt{c}\right)\right) \cdot \frac{-0.5}{a}\\ \end{array}\\ \mathbf{elif}\;t_3 \leq 5 \cdot 10^{+259}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error7.1
Cost38052
\[\begin{array}{l} t_0 := c \cdot \left(a \cdot -4\right)\\ t_1 := \frac{2 \cdot c}{\left(-b\right) - b}\\ t_2 := \frac{-b}{a}\\ t_3 := \sqrt{b \cdot b + t_0}\\ t_4 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_3}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_3 - b}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;t_4 \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array}\\ \mathbf{elif}\;t_4 \leq -1 \cdot 10^{-195}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t_4 \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{t_0} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;t_4 \leq 5 \cdot 10^{+259}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error6.8
Cost38052
\[\begin{array}{l} t_0 := c \cdot \left(a \cdot -4\right)\\ t_1 := \frac{2 \cdot c}{\left(-b\right) - b}\\ t_2 := \frac{-b}{a}\\ t_3 := \sqrt{b \cdot b + t_0}\\ t_4 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_3}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_3 - b}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;t_4 \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array}\\ \mathbf{elif}\;t_4 \leq -2 \cdot 10^{-216}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t_4 \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b - \mathsf{hypot}\left(b, \sqrt{t_0}\right)\right)\\ \end{array}\\ \mathbf{elif}\;t_4 \leq 5 \cdot 10^{+259}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error14.5
Cost7756
\[\begin{array}{l} t_0 := \frac{c}{\frac{b}{a}}\\ \mathbf{if}\;b \leq -1.4 \cdot 10^{+135}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\\ \mathbf{elif}\;b \leq 2.45 \cdot 10^{-250}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \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(2, t_0, b \cdot -2\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(2, t_0, -b\right) - b}{2 \cdot a}\\ \end{array} \]
Alternative 5
Error14.8
Cost7624
\[\begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{+156}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{2 \cdot a}\\ \end{array} \]
Alternative 6
Error17.8
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -7 \cdot 10^{-91}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{2 \cdot a}\\ \end{array} \]
Alternative 7
Error22.3
Cost644
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b \cdot 2\right)\\ \end{array} \]
Alternative 8
Error22.2
Cost644
\[\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} \]
Alternative 9
Error22.2
Cost644
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]
Alternative 10
Error45.4
Cost388
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]

Error

Reproduce

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