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

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


\end{array}\\
\mathbf{if}\;t_4 \leq -2.5 \cdot 10^{+280}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\

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


\end{array}\\

\mathbf{elif}\;t_4 \leq -2 \cdot 10^{-197}:\\
\;\;\;\;t_4\\

\mathbf{elif}\;t_4 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_3\\

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


\end{array}\\

\mathbf{elif}\;t_4 \leq 10^{+288}:\\
\;\;\;\;t_4\\

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

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


\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)))))) < -2.5000000000000001e280

    1. Initial program 58.2

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

      \[\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. Applied egg-rr16.1

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

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

    if -2.5000000000000001e280 < (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)))))) < -2e-197 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)))))) < 1e288

    1. Initial program 2.7

      \[\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 -2e-197 < (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 33.3

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

      \[\leadsto \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}:\\ \;\;\;\;\color{blue}{\frac{2 \cdot c}{2 \cdot \frac{c \cdot a}{b} + -2 \cdot b}}\\ \end{array} \]
    3. Simplified10.6

      \[\leadsto \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}:\\ \;\;\;\;\color{blue}{\frac{2 \cdot c}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}}\\ \end{array} \]
      Proof

      [Start]12.7

      \[ \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}{2 \cdot \frac{c \cdot a}{b} + -2 \cdot b}\\ \end{array} \]

      fma-def [=>]12.7

      \[ \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}:\\ \;\;\;\;\color{blue}{\frac{2 \cdot c}{\mathsf{fma}\left(2, \frac{c \cdot a}{b}, -2 \cdot b\right)}}\\ \end{array} \]

      associate-/l* [=>]10.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}{\color{blue}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -2 \cdot b\right)}}\\ \end{array} \]

      *-commutative [=>]10.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}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}\\ \end{array} \]

    if 1e288 < (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 61.1

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

      \[\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 -inf 13.8

      \[\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}{-2 \cdot b}}\\ \end{array} \]
    4. Simplified13.8

      \[\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}{b \cdot -2}}\\ \end{array} \]
      Proof

      [Start]13.8

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

      *-commutative [=>]13.8

      \[ \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\color{blue}{\frac{2 \cdot c}{b \cdot -2}}\\ \end{array} \]
  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{\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.5 \cdot 10^{+280}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\frac{c}{b \cdot b - \mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} \cdot \left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)\right)\right)\\ \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 -2 \cdot 10^{-197}:\\ \;\;\;\;\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(-b\right) - \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}\\ \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^{+288}:\\ \;\;\;\;\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}{b \cdot -2}\\ \end{array} \]

Alternatives

Alternative 1
Error6.7
Cost38052
\[\begin{array}{l} t_0 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\\ t_1 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{t_0 - b}\\ \end{array}\\ t_2 := \frac{\left(-b\right) - b}{a \cdot 2}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\frac{b}{a} \cdot 0.5\right)\\ \end{array}\\ \mathbf{elif}\;t_1 \leq -2 \cdot 10^{-224}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \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}{\left(c \cdot -2\right) \cdot \frac{a}{b} + b \cdot 2}\\ \end{array}\\ \mathbf{elif}\;t_1 \leq 10^{+288}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{b \cdot -2}\\ \end{array} \]
Alternative 2
Error6.6
Cost38052
\[\begin{array}{l} t_0 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\\ t_1 := \frac{\left(-b\right) - t_0}{a \cdot 2}\\ t_2 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{t_0 - b}\\ \end{array}\\ t_3 := \frac{\left(-b\right) - b}{a \cdot 2}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\frac{b}{a} \cdot 0.5\right)\\ \end{array}\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{-197}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}\\ \end{array}\\ \mathbf{elif}\;t_2 \leq 10^{+288}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{b \cdot -2}\\ \end{array} \]
Alternative 3
Error14.6
Cost7756
\[\begin{array}{l} t_0 := c \cdot \left(a \cdot -4\right)\\ t_1 := \frac{\left(-b\right) - b}{a \cdot 2}\\ \mathbf{if}\;b \leq -5 \cdot 10^{+112}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{b \cdot -2}\\ \end{array}\\ \mathbf{elif}\;b \leq -1.2 \cdot 10^{-296}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(b + b\right) + \frac{0.5}{a} \cdot \left(a \cdot \left(2 \cdot \frac{c}{b}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b + t_0} - b}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{1}{\frac{b + \sqrt{t_0}}{c}}\\ \end{array} \]
Alternative 4
Error14.6
Cost7624
\[\begin{array}{l} t_0 := \frac{\left(-b\right) - b}{a \cdot 2}\\ \mathbf{if}\;b \leq -8.8 \cdot 10^{+111}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{b \cdot -2}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}\\ \end{array} \]
Alternative 5
Error17.6
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -8.2 \cdot 10^{-67}:\\ \;\;\;\;\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}{\left(c \cdot -2\right) \cdot \frac{a}{b} + b \cdot 2}\\ \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
Error22.6
Cost1092
\[\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}{\left(c \cdot -2\right) \cdot \frac{a}{b} + b \cdot 2}\\ \end{array} \]
Alternative 7
Error44.8
Cost644
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\frac{b}{a} \cdot 0.5\right)\\ \end{array} \]
Alternative 8
Error22.7
Cost644
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{b \cdot -2}\\ \end{array} \]

Error

Reproduce

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