?

Average Error: 19.6 → 6.9
Time: 25.3s
Precision: binary64
Cost: 38052

?

\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
\[\begin{array}{l} t_0 := \frac{2 \cdot c}{\left(-b\right) - b}\\ t_1 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\\ t_2 := \frac{t_1 - b}{2 \cdot a}\\ t_3 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_1}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array}\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;t_3 \leq -4 \cdot 10^{-187}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_3 \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array}\\ \mathbf{elif}\;t_3 \leq 10^{+279}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (>= b 0.0)
   (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))
   (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (/ (* 2.0 c) (- (- b) b)))
        (t_1 (sqrt (+ (* b b) (* c (* a -4.0)))))
        (t_2 (/ (- t_1 b) (* 2.0 a)))
        (t_3 (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_1)) t_2)))
   (if (<= t_3 (- INFINITY))
     (if (>= b 0.0) t_0 (/ (* b -2.0) (* 2.0 a)))
     (if (<= t_3 -4e-187)
       t_3
       (if (<= t_3 0.0)
         (if (>= b 0.0) t_0 t_2)
         (if (<= t_3 1e+279) t_3 (if (>= b 0.0) t_0 (- (/ c b) (/ b a)))))))))
double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - sqrt(((b * b) - ((4.0 * a) * c))));
	} else {
		tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
	}
	return tmp;
}
double code(double a, double b, double c) {
	double t_0 = (2.0 * c) / (-b - b);
	double t_1 = sqrt(((b * b) + (c * (a * -4.0))));
	double t_2 = (t_1 - b) / (2.0 * a);
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - t_1);
	} else {
		tmp = t_2;
	}
	double t_3 = tmp;
	double tmp_2;
	if (t_3 <= -((double) INFINITY)) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = t_0;
		} else {
			tmp_3 = (b * -2.0) / (2.0 * a);
		}
		tmp_2 = tmp_3;
	} else if (t_3 <= -4e-187) {
		tmp_2 = t_3;
	} else if (t_3 <= 0.0) {
		double tmp_4;
		if (b >= 0.0) {
			tmp_4 = t_0;
		} else {
			tmp_4 = t_2;
		}
		tmp_2 = tmp_4;
	} else if (t_3 <= 1e+279) {
		tmp_2 = t_3;
	} else if (b >= 0.0) {
		tmp_2 = t_0;
	} else {
		tmp_2 = (c / b) - (b / a);
	}
	return tmp_2;
}
public static double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - Math.sqrt(((b * b) - ((4.0 * a) * c))));
	} else {
		tmp = (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
	}
	return tmp;
}
public static double code(double a, double b, double c) {
	double t_0 = (2.0 * c) / (-b - b);
	double t_1 = Math.sqrt(((b * b) + (c * (a * -4.0))));
	double t_2 = (t_1 - b) / (2.0 * a);
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - t_1);
	} else {
		tmp = t_2;
	}
	double t_3 = tmp;
	double tmp_2;
	if (t_3 <= -Double.POSITIVE_INFINITY) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = t_0;
		} else {
			tmp_3 = (b * -2.0) / (2.0 * a);
		}
		tmp_2 = tmp_3;
	} else if (t_3 <= -4e-187) {
		tmp_2 = t_3;
	} else if (t_3 <= 0.0) {
		double tmp_4;
		if (b >= 0.0) {
			tmp_4 = t_0;
		} else {
			tmp_4 = t_2;
		}
		tmp_2 = tmp_4;
	} else if (t_3 <= 1e+279) {
		tmp_2 = t_3;
	} else if (b >= 0.0) {
		tmp_2 = t_0;
	} else {
		tmp_2 = (c / b) - (b / a);
	}
	return tmp_2;
}
def code(a, b, c):
	tmp = 0
	if b >= 0.0:
		tmp = (2.0 * c) / (-b - math.sqrt(((b * b) - ((4.0 * a) * c))))
	else:
		tmp = (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
	return tmp
def code(a, b, c):
	t_0 = (2.0 * c) / (-b - b)
	t_1 = math.sqrt(((b * b) + (c * (a * -4.0))))
	t_2 = (t_1 - b) / (2.0 * a)
	tmp = 0
	if b >= 0.0:
		tmp = (2.0 * c) / (-b - t_1)
	else:
		tmp = t_2
	t_3 = tmp
	tmp_2 = 0
	if t_3 <= -math.inf:
		tmp_3 = 0
		if b >= 0.0:
			tmp_3 = t_0
		else:
			tmp_3 = (b * -2.0) / (2.0 * a)
		tmp_2 = tmp_3
	elif t_3 <= -4e-187:
		tmp_2 = t_3
	elif t_3 <= 0.0:
		tmp_4 = 0
		if b >= 0.0:
			tmp_4 = t_0
		else:
			tmp_4 = t_2
		tmp_2 = tmp_4
	elif t_3 <= 1e+279:
		tmp_2 = t_3
	elif b >= 0.0:
		tmp_2 = t_0
	else:
		tmp_2 = (c / b) - (b / a)
	return tmp_2
function code(a, b, c)
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))));
	else
		tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a));
	end
	return tmp
end
function code(a, b, c)
	t_0 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b))
	t_1 = sqrt(Float64(Float64(b * b) + Float64(c * Float64(a * -4.0))))
	t_2 = Float64(Float64(t_1 - b) / Float64(2.0 * a))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_1));
	else
		tmp = t_2;
	end
	t_3 = tmp
	tmp_2 = 0.0
	if (t_3 <= Float64(-Inf))
		tmp_3 = 0.0
		if (b >= 0.0)
			tmp_3 = t_0;
		else
			tmp_3 = Float64(Float64(b * -2.0) / Float64(2.0 * a));
		end
		tmp_2 = tmp_3;
	elseif (t_3 <= -4e-187)
		tmp_2 = t_3;
	elseif (t_3 <= 0.0)
		tmp_4 = 0.0
		if (b >= 0.0)
			tmp_4 = t_0;
		else
			tmp_4 = t_2;
		end
		tmp_2 = tmp_4;
	elseif (t_3 <= 1e+279)
		tmp_2 = t_3;
	elseif (b >= 0.0)
		tmp_2 = t_0;
	else
		tmp_2 = Float64(Float64(c / b) - Float64(b / a));
	end
	return tmp_2
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	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);
	end
	tmp_2 = tmp;
end
function tmp_6 = code(a, b, c)
	t_0 = (2.0 * c) / (-b - b);
	t_1 = sqrt(((b * b) + (c * (a * -4.0))));
	t_2 = (t_1 - b) / (2.0 * a);
	tmp = 0.0;
	if (b >= 0.0)
		tmp = (2.0 * c) / (-b - t_1);
	else
		tmp = t_2;
	end
	t_3 = tmp;
	tmp_3 = 0.0;
	if (t_3 <= -Inf)
		tmp_4 = 0.0;
		if (b >= 0.0)
			tmp_4 = t_0;
		else
			tmp_4 = (b * -2.0) / (2.0 * a);
		end
		tmp_3 = tmp_4;
	elseif (t_3 <= -4e-187)
		tmp_3 = t_3;
	elseif (t_3 <= 0.0)
		tmp_5 = 0.0;
		if (b >= 0.0)
			tmp_5 = t_0;
		else
			tmp_5 = t_2;
		end
		tmp_3 = tmp_5;
	elseif (t_3 <= 1e+279)
		tmp_3 = t_3;
	elseif (b >= 0.0)
		tmp_3 = t_0;
	else
		tmp_3 = (c / b) - (b / a);
	end
	tmp_6 = 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[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$1), $MachinePrecision]), $MachinePrecision], t$95$2]}, If[LessEqual[t$95$3, (-Infinity)], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[t$95$3, -4e-187], t$95$3, If[LessEqual[t$95$3, 0.0], If[GreaterEqual[b, 0.0], t$95$0, t$95$2], If[LessEqual[t$95$3, 1e+279], t$95$3, If[GreaterEqual[b, 0.0], t$95$0, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

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


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

\mathbf{else}:\\
\;\;\;\;t_2\\


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

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


\end{array}\\

\mathbf{elif}\;t_3 \leq -4 \cdot 10^{-187}:\\
\;\;\;\;t_3\\

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

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}\\

\mathbf{elif}\;t_3 \leq 10^{+279}:\\
\;\;\;\;t_3\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

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

    1. Initial program 64.0

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

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

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

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

      [Start]18.7

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

      *-commutative [=>]18.7

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

    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))) < -4.0000000000000001e-187 or 0.0 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < 1.00000000000000006e279

    1. Initial program 2.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. Applied egg-rr16.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{\frac{{b}^{4} - \left(c \cdot \left(a \cdot -4\right)\right) \cdot \left(c \cdot \left(a \cdot -4\right)\right)}{b \cdot b - c \cdot \left(a \cdot -4\right)}}}{2 \cdot a}\\ \end{array} \]
    3. Simplified21.5

      \[\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{\frac{{b}^{4} - \left(c \cdot c\right) \cdot \left(\left(a \cdot -4\right) \cdot \left(a \cdot -4\right)\right)}{b \cdot b - c \cdot \left(a \cdot -4\right)}}}{2 \cdot a}\\ \end{array} \]
      Proof

      [Start]16.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{\frac{{b}^{4} - \left(c \cdot \left(a \cdot -4\right)\right) \cdot \left(c \cdot \left(a \cdot -4\right)\right)}{b \cdot b - c \cdot \left(a \cdot -4\right)}}}{2 \cdot a}\\ \end{array} \]

      swap-sqr [=>]21.5

      \[ \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{\frac{{b}^{4} - \left(c \cdot c\right) \cdot \left(\left(a \cdot -4\right) \cdot \left(a \cdot -4\right)\right)}{b \cdot b - c \cdot \left(a \cdot -4\right)}}}{2 \cdot a}\\ \end{array} \]
    4. Applied egg-rr2.9

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

    if -4.0000000000000001e-187 < (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 31.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} \]

    if 1.00000000000000006e279 < (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 60.1

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

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

      \[\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. Simplified14.1

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

      \[ \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 [=>]14.1

      \[ \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 [=>]14.1

      \[ \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} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.9

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

Alternatives

Alternative 1
Error9.6
Cost7888
\[\begin{array}{l} t_0 := \frac{2 \cdot c}{\left(-b\right) - b}\\ t_1 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ t_2 := c \cdot \left(a \cdot -4\right)\\ \mathbf{if}\;b \leq -8.5 \cdot 10^{-75}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{t_2} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 1.8 \cdot 10^{+131}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \sqrt{b \cdot b + t_2}}\\ \mathbf{else}:\\ \;\;\;\;\left(b + b\right) \cdot \frac{-0.5}{a}\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error6.5
Cost7888
\[\begin{array}{l} t_0 := \frac{2 \cdot c}{\left(-b\right) - b}\\ t_1 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ t_2 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\\ \mathbf{if}\;b \leq -6 \cdot 10^{+133}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{t_2 - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 2 \cdot 10^{+131}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + t_2}\\ \mathbf{else}:\\ \;\;\;\;\left(b + b\right) \cdot \frac{-0.5}{a}\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error13.5
Cost7632
\[\begin{array}{l} t_0 := \left(b + b\right) \cdot \frac{-0.5}{a}\\ t_1 := \frac{2 \cdot c}{\left(-b\right) - b}\\ t_2 := \sqrt{c \cdot \left(a \cdot -4\right)}\\ \mathbf{if}\;b \leq -1.22 \cdot 10^{-106}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{elif}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{t_2 - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 7.8 \cdot 10^{-24}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + t_2}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \left(b + \frac{c \cdot -2}{\frac{b}{a}}\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error18.1
Cost7368
\[\begin{array}{l} t_0 := \left(b + b\right) \cdot \frac{-0.5}{a}\\ \mathbf{if}\;b \leq 2.25 \cdot 10^{-23}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \sqrt{c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \left(b + \frac{c \cdot -2}{\frac{b}{a}}\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error22.8
Cost1092
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \left(b + \frac{c \cdot -2}{\frac{b}{a}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(b + b\right) \cdot \frac{-0.5}{a}\\ \end{array} \]
Alternative 6
Error22.8
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} \]

Error

Reproduce?

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