Average Error: 19.6 → 6.4
Time: 21.7s
Precision: binary64
Cost: 7820
\[\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} \mathbf{if}\;b \leq -4 \cdot 10^{+130}:\\ \;\;\;\;\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 5 \cdot 10^{+94}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b + \left(c \cdot a\right) \cdot -4}}\\ \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}{\left(-b\right) - \mathsf{fma}\left(-2, \frac{c}{b} \cdot a, b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -2, \frac{2 \cdot \left(c \cdot a\right)}{b}\right)}{2 \cdot 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
 (if (<= b -4e+130)
   (if (>= b 0.0) (/ (* 2.0 c) (- (+ b b))) (- (/ c b) (/ b a)))
   (if (<= b 5e+94)
     (if (>= b 0.0)
       (/ (* 2.0 c) (- (- b) (sqrt (+ (* b b) (* (* c a) -4.0)))))
       (/ (- (sqrt (+ (* b b) (* c (* a -4.0)))) b) (* 2.0 a)))
     (if (>= b 0.0)
       (/ (* 2.0 c) (- (- b) (fma -2.0 (* (/ c b) a) b)))
       (/ (fma b -2.0 (/ (* 2.0 (* c a)) b)) (* 2.0 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 tmp_1;
	if (b <= -4e+130) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (2.0 * c) / -(b + b);
		} else {
			tmp_2 = (c / b) - (b / a);
		}
		tmp_1 = tmp_2;
	} else if (b <= 5e+94) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = (2.0 * c) / (-b - sqrt(((b * b) + ((c * a) * -4.0))));
		} else {
			tmp_3 = (sqrt(((b * b) + (c * (a * -4.0)))) - b) / (2.0 * a);
		}
		tmp_1 = tmp_3;
	} else if (b >= 0.0) {
		tmp_1 = (2.0 * c) / (-b - fma(-2.0, ((c / b) * a), b));
	} else {
		tmp_1 = fma(b, -2.0, ((2.0 * (c * a)) / b)) / (2.0 * a);
	}
	return tmp_1;
}
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)
	tmp_1 = 0.0
	if (b <= -4e+130)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(Float64(2.0 * c) / Float64(-Float64(b + b)));
		else
			tmp_2 = Float64(Float64(c / b) - Float64(b / a));
		end
		tmp_1 = tmp_2;
	elseif (b <= 5e+94)
		tmp_3 = 0.0
		if (b >= 0.0)
			tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(Float64(b * b) + Float64(Float64(c * a) * -4.0)))));
		else
			tmp_3 = Float64(Float64(sqrt(Float64(Float64(b * b) + Float64(c * Float64(a * -4.0)))) - b) / Float64(2.0 * a));
		end
		tmp_1 = tmp_3;
	elseif (b >= 0.0)
		tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - fma(-2.0, Float64(Float64(c / b) * a), b)));
	else
		tmp_1 = Float64(fma(b, -2.0, Float64(Float64(2.0 * Float64(c * a)) / b)) / Float64(2.0 * a));
	end
	return tmp_1
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_] := If[LessEqual[b, -4e+130], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 5e+94], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[(-2.0 * N[(N[(c / b), $MachinePrecision] * a), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0 + N[(N[(2.0 * N[(c * a), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] / N[(2.0 * 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}
\mathbf{if}\;b \leq -4 \cdot 10^{+130}:\\
\;\;\;\;\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 5 \cdot 10^{+94}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b + \left(c \cdot a\right) \cdot -4}}\\

\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}{\left(-b\right) - \mathsf{fma}\left(-2, \frac{c}{b} \cdot a, b\right)}\\

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


\end{array}

Error

Derivation

  1. Split input into 3 regimes
  2. if b < -4.0000000000000002e130

    1. Initial program 54.3

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

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

      \[\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. Simplified3.2

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

      [Start]3.2

      \[ \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} \]

      mul-1-neg [=>]3.2

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

      unsub-neg [=>]3.2

      \[ \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} \]

    if -4.0000000000000002e130 < b < 5.0000000000000001e94

    1. Initial program 8.6

      \[\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 a around 0 8.6

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

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

      [Start]8.6

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

      *-commutative [=>]8.6

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

    if 5.0000000000000001e94 < b

    1. Initial program 29.9

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

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

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

      [Start]6.1

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

      +-commutative [=>]6.1

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

      fma-def [=>]6.1

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

      associate-/l* [=>]2.2

      \[ \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{fma}\left(-2, \color{blue}{\frac{c}{\frac{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} \]

      associate-/r/ [=>]2.2

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

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

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

      [Start]2.2

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

      +-commutative [=>]2.2

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

      *-commutative [=>]2.2

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

      fma-def [=>]2.2

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

      associate-*r/ [=>]2.2

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

      *-commutative [=>]2.2

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

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

Alternatives

Alternative 1
Error6.6
Cost38052
\[\begin{array}{l} t_0 := \frac{2 \cdot c}{-\left(b + b\right)}\\ t_1 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\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{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{elif}\;t_2 \leq -5 \cdot 10^{-276}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{fma}\left(-2, \frac{c}{b} \cdot a, b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -2, \frac{2 \cdot \left(c \cdot a\right)}{b}\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+244}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]
Alternative 2
Error7.1
Cost38052
\[\begin{array}{l} t_0 := -\left(b + b\right)\\ t_1 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\\ t_2 := \frac{2 \cdot c}{\left(-b\right) - t_1}\\ t_3 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1 - b}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{elif}\;t_3 \leq -5 \cdot 10^{-276}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_3 \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{fma}\left(-2, \frac{c}{b} \cdot a, b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -2, \frac{2 \cdot \left(c \cdot a\right)}{b}\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;t_3 \leq 5 \cdot 10^{+203}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{2 \cdot a}\\ \end{array} \]
Alternative 3
Error14.4
Cost7756
\[\begin{array}{l} t_0 := \mathsf{fma}\left(-2, \frac{c}{b} \cdot a, b\right)\\ \mathbf{if}\;b \leq -9.2 \cdot 10^{+131}:\\ \;\;\;\;\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 -1 \cdot 10^{-308}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{2}{b - t_0}\\ \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}{\left(-b\right) - t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -2, \frac{2 \cdot \left(c \cdot a\right)}{b}\right)}{2 \cdot a}\\ \end{array} \]
Alternative 4
Error14.5
Cost7756
\[\begin{array}{l} \mathbf{if}\;b \leq -3.9 \cdot 10^{+129}:\\ \;\;\;\;\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 1.2 \cdot 10^{-216}:\\ \;\;\;\;\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}{\left(-b\right) - \mathsf{fma}\left(-2, \frac{c}{b} \cdot a, b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -2, \frac{2 \cdot \left(c \cdot a\right)}{b}\right)}{2 \cdot a}\\ \end{array} \]
Alternative 5
Error14.7
Cost7624
\[\begin{array}{l} t_0 := \frac{2 \cdot c}{-\left(b + b\right)}\\ \mathbf{if}\;b \leq -1.2 \cdot 10^{+130}:\\ \;\;\;\;\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{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{2 \cdot a}\\ \end{array} \]
Alternative 6
Error23.0
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} \]

Error

Reproduce

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