?

Average Accuracy: 68.7% → 89.4%
Time: 27.2s
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 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t_2}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{t_2 - b}\\ \end{array}\\ \mathbf{if}\;t_3 \leq -5 \cdot 10^{+256}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{-2}{b - \sqrt{t_1}}\\ \end{array}\\ \mathbf{elif}\;t_3 \leq -1 \cdot 10^{-245}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_3 \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\mathsf{fma}\left(2, a \cdot \frac{c}{b}, -b\right) - b}\\ \end{array}\\ \mathbf{elif}\;t_3 \leq 5 \cdot 10^{+272}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \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
         (if (>= b 0.0) (/ (- (- b) t_2) (* a 2.0)) (/ (* c 2.0) (- t_2 b)))))
   (if (<= t_3 -5e+256)
     (if (>= b 0.0) t_0 (* c (/ -2.0 (- b (sqrt t_1)))))
     (if (<= t_3 -1e-245)
       t_3
       (if (<= t_3 0.0)
         (if (>= b 0.0) t_0 (/ (* c 2.0) (- (fma 2.0 (* a (/ c b)) (- b)) b)))
         (if (<= t_3 5e+272) t_3 (if (>= b 0.0) t_0 (/ (- c) b))))))))
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 tmp;
	if (b >= 0.0) {
		tmp = (-b - t_2) / (a * 2.0);
	} else {
		tmp = (c * 2.0) / (t_2 - b);
	}
	double t_3 = tmp;
	double tmp_2;
	if (t_3 <= -5e+256) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = t_0;
		} else {
			tmp_3 = c * (-2.0 / (b - sqrt(t_1)));
		}
		tmp_2 = tmp_3;
	} else if (t_3 <= -1e-245) {
		tmp_2 = t_3;
	} else if (t_3 <= 0.0) {
		double tmp_4;
		if (b >= 0.0) {
			tmp_4 = t_0;
		} else {
			tmp_4 = (c * 2.0) / (fma(2.0, (a * (c / b)), -b) - b);
		}
		tmp_2 = tmp_4;
	} else if (t_3 <= 5e+272) {
		tmp_2 = t_3;
	} else if (b >= 0.0) {
		tmp_2 = t_0;
	} else {
		tmp_2 = -c / b;
	}
	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))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(Float64(-b) - t_2) / Float64(a * 2.0));
	else
		tmp = Float64(Float64(c * 2.0) / Float64(t_2 - b));
	end
	t_3 = tmp
	tmp_2 = 0.0
	if (t_3 <= -5e+256)
		tmp_3 = 0.0
		if (b >= 0.0)
			tmp_3 = t_0;
		else
			tmp_3 = Float64(c * Float64(-2.0 / Float64(b - sqrt(t_1))));
		end
		tmp_2 = tmp_3;
	elseif (t_3 <= -1e-245)
		tmp_2 = t_3;
	elseif (t_3 <= 0.0)
		tmp_4 = 0.0
		if (b >= 0.0)
			tmp_4 = t_0;
		else
			tmp_4 = Float64(Float64(c * 2.0) / Float64(fma(2.0, Float64(a * Float64(c / b)), Float64(-b)) - b));
		end
		tmp_2 = tmp_4;
	elseif (t_3 <= 5e+272)
		tmp_2 = t_3;
	elseif (b >= 0.0)
		tmp_2 = t_0;
	else
		tmp_2 = Float64(Float64(-c) / b);
	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 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$2), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * 2.0), $MachinePrecision] / N[(t$95$2 - b), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$3, -5e+256], If[GreaterEqual[b, 0.0], t$95$0, N[(c * N[(-2.0 / N[(b - N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[t$95$3, -1e-245], t$95$3, If[LessEqual[t$95$3, 0.0], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(c * 2.0), $MachinePrecision] / N[(N[(2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] + (-b)), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[t$95$3, 5e+272], t$95$3, If[GreaterEqual[b, 0.0], t$95$0, N[((-c) / b), $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 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_2}{a \cdot 2}\\

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


\end{array}\\
\mathbf{if}\;t_3 \leq -5 \cdot 10^{+256}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\

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


\end{array}\\

\mathbf{elif}\;t_3 \leq -1 \cdot 10^{-245}:\\
\;\;\;\;t_3\\

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

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


\end{array}\\

\mathbf{elif}\;t_3 \leq 5 \cdot 10^{+272}:\\
\;\;\;\;t_3\\

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

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


\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)))))) < -5.00000000000000015e256

    1. Initial program 15.4%

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

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

      \[\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. Simplified73.6%

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

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

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

      \[ \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-rr73.7%

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

      [Start]73.6

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

      associate-*l/ [<=]73.7

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

    if -5.00000000000000015e256 < (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)))))) < -9.9999999999999993e-246 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)))))) < 4.99999999999999973e272

    1. Initial program 95.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} \]

    if -9.9999999999999993e-246 < (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 44.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 44.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 80.0%

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

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

      [Start]80.0

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

      fma-def [=>]80.0

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

      associate-/l* [=>]82.8

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

      associate-/r/ [=>]82.8

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

      mul-1-neg [=>]82.8

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

    if 4.99999999999999973e272 < (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 8.4%

      \[\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 72.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 79.6%

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

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

      [Start]79.6

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

      mul-1-neg [=>]79.6

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

      distribute-neg-frac [=>]79.6

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

    \[\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 -5 \cdot 10^{+256}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;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}\\ \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 -1 \cdot 10^{-245}:\\ \;\;\;\;\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) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\mathsf{fma}\left(2, a \cdot \frac{c}{b}, -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 5 \cdot 10^{+272}:\\ \;\;\;\;\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}{b}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy84.1%
Cost7888
\[\begin{array}{l} t_0 := \left(-b\right) - b\\ t_1 := \frac{t_0}{a \cdot 2}\\ \mathbf{if}\;b \leq -1.22 \cdot 10^{-99}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array}\\ \mathbf{elif}\;b \leq 3.1 \cdot 10^{-307}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{-2}{b - \sqrt{c \cdot \left(a \cdot -4\right)}}\\ \end{array}\\ \mathbf{elif}\;b \leq 5 \cdot 10^{+113}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{2}{t_0}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(0.5 \cdot \frac{b}{a}\right)\\ \end{array} \]
Alternative 2
Accuracy84.1%
Cost7888
\[\begin{array}{l} t_0 := \left(-b\right) - b\\ t_1 := \frac{t_0}{a \cdot 2}\\ \mathbf{if}\;b \leq -1.22 \cdot 10^{-99}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\mathsf{fma}\left(2, a \cdot \frac{c}{b}, -b\right) - b}\\ \end{array}\\ \mathbf{elif}\;b \leq 3.1 \cdot 10^{-307}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{-2}{b - \sqrt{c \cdot \left(a \cdot -4\right)}}\\ \end{array}\\ \mathbf{elif}\;b \leq 5.2 \cdot 10^{+110}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{2}{t_0}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(0.5 \cdot \frac{b}{a}\right)\\ \end{array} \]
Alternative 3
Accuracy89.6%
Cost7888
\[\begin{array}{l} t_0 := \left(-b\right) - b\\ t_1 := \frac{t_0}{a \cdot 2}\\ \mathbf{if}\;b \leq -6 \cdot 10^{+151}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\mathsf{fma}\left(2, a \cdot \frac{c}{b}, -b\right) - b}\\ \end{array}\\ \mathbf{elif}\;b \leq 3.1 \cdot 10^{-307}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}\\ \end{array}\\ \mathbf{elif}\;b \leq 1.9 \cdot 10^{+118}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{2}{t_0}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(0.5 \cdot \frac{b}{a}\right)\\ \end{array} \]
Alternative 4
Accuracy79.0%
Cost7760
\[\begin{array}{l} t_0 := \left(-b\right) - b\\ t_1 := \frac{t_0}{a \cdot 2}\\ t_2 := \sqrt{c \cdot \left(a \cdot -4\right)}\\ t_3 := b + t_2\\ \mathbf{if}\;b \leq -1.22 \cdot 10^{-99}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array}\\ \mathbf{elif}\;b \leq 3.1 \cdot 10^{-307}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{-2}{b - t_2}\\ \end{array}\\ \mathbf{elif}\;b \leq 5.8 \cdot 10^{-51}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-0.5}{a} \cdot t_3\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{2}{t_0}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{1}{\frac{t_3}{c}}\\ \end{array} \]
Alternative 5
Accuracy79.0%
Cost7632
\[\begin{array}{l} t_0 := \left(-b\right) - b\\ t_1 := \frac{t_0}{a \cdot 2}\\ t_2 := \sqrt{c \cdot \left(a \cdot -4\right)}\\ \mathbf{if}\;b \leq -1.22 \cdot 10^{-99}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array}\\ \mathbf{elif}\;b \leq 3.1 \cdot 10^{-307}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{-2}{b - t_2}\\ \end{array}\\ \mathbf{elif}\;b \leq 1.9 \cdot 10^{-50}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b + t_2\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{2}{t_0}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(0.5 \cdot \frac{b}{a}\right)\\ \end{array} \]
Alternative 6
Accuracy71.6%
Cost7368
\[\begin{array}{l} t_0 := \left(-b\right) - b\\ \mathbf{if}\;b \leq 3.5 \cdot 10^{-50}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{c \cdot \left(a \cdot -4\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{2}{t_0}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{t_0}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(0.5 \cdot \frac{b}{a}\right)\\ \end{array} \]
Alternative 7
Accuracy29.9%
Cost644
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(0.5 \cdot \frac{b}{a}\right)\\ \end{array} \]
Alternative 8
Accuracy64.6%
Cost644
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

Error

Reproduce?

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