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

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


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

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


\end{array}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\frac{-b}{a}\\

\mathbf{elif}\;t_2 \leq -2 \cdot 10^{-254}:\\
\;\;\;\;t_2\\

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

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


\end{array}\\

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

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\frac{t_0 - b \cdot b}{b + \sqrt{t_0}}}\\


\end{array}

Error

Derivation

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

    1. Initial program 64.0

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

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

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

      [Start]21.8

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

      associate-/l* [=>]18.1

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

      associate-*r/ [=>]18.1

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

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

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

      [Start]17.6

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

      mul-1-neg [=>]17.6

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

      distribute-neg-frac [=>]17.6

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]
      Proof

      [Start]17.6

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

      mul-1-neg [=>]17.6

      \[ \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;-\frac{b}{a}\\ \end{array} \]

      distribute-neg-frac [=>]17.6

      \[ \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]

    if -inf.0 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < -1.9999999999999998e-254 or -0.0 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < 1.00000000000000005e248

    1. Initial program 2.6

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

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

    1. Initial program 36.8

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

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

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

      [Start]37.1

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

      associate-/l* [=>]37.1

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

      associate-*r/ [=>]37.1

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

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

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

      [Start]13.6

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

      fma-def [=>]13.6

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

      associate-/l* [=>]11.0

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

      mul-1-neg [=>]11.0

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

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

    1. Initial program 54.9

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

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

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

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

      [Start]17.5

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

      *-commutative [=>]17.5

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

      associate-*r* [<=]17.5

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

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

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

Alternatives

Alternative 1
Error7.1
Cost38052
\[\begin{array}{l} t_0 := \frac{-b}{a}\\ t_1 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\\ t_2 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t_1}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{t_1 - b}\\ \end{array}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{-254}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(\frac{c \cdot 2}{\frac{b}{a}} - b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right) - b}\\ \end{array}\\ \mathbf{elif}\;t_2 \leq 10^{+248}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error6.5
Cost7952
\[\begin{array}{l} t_0 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\\ \mathbf{if}\;b \leq -5.2 \cdot 10^{+153}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(\frac{c \cdot 2}{\frac{b}{a}} - b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right) - b}\\ \end{array}\\ \mathbf{elif}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a} \cdot -3\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{t_0 - b}\\ \end{array}\\ \mathbf{elif}\;b \leq 1.05 \cdot 10^{+111}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{a}\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]
Alternative 3
Error14.4
Cost7756
\[\begin{array}{l} \mathbf{if}\;b \leq -1.25 \cdot 10^{+154}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(\frac{c \cdot 2}{\frac{b}{a}} - b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right) - b}\\ \end{array}\\ \mathbf{elif}\;b \leq 1.6 \cdot 10^{-214}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a} \cdot -3\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]
Alternative 4
Error14.4
Cost7624
\[\begin{array}{l} \mathbf{if}\;b \leq -2 \cdot 10^{+154}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(\frac{c \cdot 2}{\frac{b}{a}} - b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right) - b}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}\\ \end{array} \]
Alternative 5
Error17.9
Cost7560
\[\begin{array}{l} \mathbf{if}\;b \leq -1.05 \cdot 10^{-28}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(\frac{c \cdot 2}{\frac{b}{a}} - b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right) - b}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{c \cdot \left(a \cdot -4\right)} - b}\\ \end{array} \]
Alternative 6
Error18.1
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -8 \cdot 10^{-22}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{-2}{b - \sqrt{c \cdot \left(a \cdot -4\right)}}\\ \end{array} \]
Alternative 7
Error18.1
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -1.92 \cdot 10^{-22}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{c \cdot \left(a \cdot -4\right)} - b}\\ \end{array} \]
Alternative 8
Error22.6
Cost388
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array} \]
Alternative 9
Error45.7
Cost256
\[-\frac{b}{a} \]

Error

Reproduce

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