?

Average Error: 20.5 → 8.8
Time: 23.8s
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 := \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\\ t_1 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{-a}\\ \end{array}\\ t_2 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\ t_3 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + t_2}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_3 \leq -5 \cdot 10^{-297}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + t_0}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;t_3 \leq 0:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_3 \leq 2 \cdot 10^{+295}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{c}{a} \cdot -4} + -0.5 \cdot \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 (sqrt (- (* b b) (* 4.0 (* c a)))))
        (t_1 (if (>= b 0.0) (/ (- c) b) (/ b (- a))))
        (t_2 (sqrt (- (* b b) (* (* 4.0 a) c))))
        (t_3
         (if (>= b 0.0)
           (/ (* 2.0 c) (- (- b) t_2))
           (/ (+ (- b) t_2) (* 2.0 a)))))
   (if (<= t_3 (- INFINITY))
     t_1
     (if (<= t_3 -5e-297)
       (if (>= b 0.0) (* 2.0 (/ c (- (- b) t_0))) (/ (+ (- b) t_0) (* 2.0 a)))
       (if (<= t_3 0.0)
         t_1
         (if (<= t_3 2e+295)
           t_3
           (if (>= b 0.0)
             (* 2.0 (/ c (- (- b) b)))
             (+ (* 0.5 (sqrt (* (/ c a) -4.0))) (* -0.5 (/ 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 = sqrt(((b * b) - (4.0 * (c * a))));
	double tmp;
	if (b >= 0.0) {
		tmp = -c / b;
	} else {
		tmp = b / -a;
	}
	double t_1 = tmp;
	double t_2 = sqrt(((b * b) - ((4.0 * a) * c)));
	double tmp_1;
	if (b >= 0.0) {
		tmp_1 = (2.0 * c) / (-b - t_2);
	} else {
		tmp_1 = (-b + t_2) / (2.0 * a);
	}
	double t_3 = tmp_1;
	double tmp_2;
	if (t_3 <= -((double) INFINITY)) {
		tmp_2 = t_1;
	} else if (t_3 <= -5e-297) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = 2.0 * (c / (-b - t_0));
		} else {
			tmp_3 = (-b + t_0) / (2.0 * a);
		}
		tmp_2 = tmp_3;
	} else if (t_3 <= 0.0) {
		tmp_2 = t_1;
	} else if (t_3 <= 2e+295) {
		tmp_2 = t_3;
	} else if (b >= 0.0) {
		tmp_2 = 2.0 * (c / (-b - b));
	} else {
		tmp_2 = (0.5 * sqrt(((c / a) * -4.0))) + (-0.5 * (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 = Math.sqrt(((b * b) - (4.0 * (c * a))));
	double tmp;
	if (b >= 0.0) {
		tmp = -c / b;
	} else {
		tmp = b / -a;
	}
	double t_1 = tmp;
	double t_2 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
	double tmp_1;
	if (b >= 0.0) {
		tmp_1 = (2.0 * c) / (-b - t_2);
	} else {
		tmp_1 = (-b + t_2) / (2.0 * a);
	}
	double t_3 = tmp_1;
	double tmp_2;
	if (t_3 <= -Double.POSITIVE_INFINITY) {
		tmp_2 = t_1;
	} else if (t_3 <= -5e-297) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = 2.0 * (c / (-b - t_0));
		} else {
			tmp_3 = (-b + t_0) / (2.0 * a);
		}
		tmp_2 = tmp_3;
	} else if (t_3 <= 0.0) {
		tmp_2 = t_1;
	} else if (t_3 <= 2e+295) {
		tmp_2 = t_3;
	} else if (b >= 0.0) {
		tmp_2 = 2.0 * (c / (-b - b));
	} else {
		tmp_2 = (0.5 * Math.sqrt(((c / a) * -4.0))) + (-0.5 * (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 = math.sqrt(((b * b) - (4.0 * (c * a))))
	tmp = 0
	if b >= 0.0:
		tmp = -c / b
	else:
		tmp = b / -a
	t_1 = tmp
	t_2 = math.sqrt(((b * b) - ((4.0 * a) * c)))
	tmp_1 = 0
	if b >= 0.0:
		tmp_1 = (2.0 * c) / (-b - t_2)
	else:
		tmp_1 = (-b + t_2) / (2.0 * a)
	t_3 = tmp_1
	tmp_2 = 0
	if t_3 <= -math.inf:
		tmp_2 = t_1
	elif t_3 <= -5e-297:
		tmp_3 = 0
		if b >= 0.0:
			tmp_3 = 2.0 * (c / (-b - t_0))
		else:
			tmp_3 = (-b + t_0) / (2.0 * a)
		tmp_2 = tmp_3
	elif t_3 <= 0.0:
		tmp_2 = t_1
	elif t_3 <= 2e+295:
		tmp_2 = t_3
	elif b >= 0.0:
		tmp_2 = 2.0 * (c / (-b - b))
	else:
		tmp_2 = (0.5 * math.sqrt(((c / a) * -4.0))) + (-0.5 * (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 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a))))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(-c) / b);
	else
		tmp = Float64(b / Float64(-a));
	end
	t_1 = tmp
	t_2 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))
	tmp_1 = 0.0
	if (b >= 0.0)
		tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_2));
	else
		tmp_1 = Float64(Float64(Float64(-b) + t_2) / Float64(2.0 * a));
	end
	t_3 = tmp_1
	tmp_2 = 0.0
	if (t_3 <= Float64(-Inf))
		tmp_2 = t_1;
	elseif (t_3 <= -5e-297)
		tmp_3 = 0.0
		if (b >= 0.0)
			tmp_3 = Float64(2.0 * Float64(c / Float64(Float64(-b) - t_0)));
		else
			tmp_3 = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a));
		end
		tmp_2 = tmp_3;
	elseif (t_3 <= 0.0)
		tmp_2 = t_1;
	elseif (t_3 <= 2e+295)
		tmp_2 = t_3;
	elseif (b >= 0.0)
		tmp_2 = Float64(2.0 * Float64(c / Float64(Float64(-b) - b)));
	else
		tmp_2 = Float64(Float64(0.5 * sqrt(Float64(Float64(c / a) * -4.0))) + Float64(-0.5 * 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_5 = code(a, b, c)
	t_0 = sqrt(((b * b) - (4.0 * (c * a))));
	tmp = 0.0;
	if (b >= 0.0)
		tmp = -c / b;
	else
		tmp = b / -a;
	end
	t_1 = tmp;
	t_2 = sqrt(((b * b) - ((4.0 * a) * c)));
	tmp_2 = 0.0;
	if (b >= 0.0)
		tmp_2 = (2.0 * c) / (-b - t_2);
	else
		tmp_2 = (-b + t_2) / (2.0 * a);
	end
	t_3 = tmp_2;
	tmp_3 = 0.0;
	if (t_3 <= -Inf)
		tmp_3 = t_1;
	elseif (t_3 <= -5e-297)
		tmp_4 = 0.0;
		if (b >= 0.0)
			tmp_4 = 2.0 * (c / (-b - t_0));
		else
			tmp_4 = (-b + t_0) / (2.0 * a);
		end
		tmp_3 = tmp_4;
	elseif (t_3 <= 0.0)
		tmp_3 = t_1;
	elseif (t_3 <= 2e+295)
		tmp_3 = t_3;
	elseif (b >= 0.0)
		tmp_3 = 2.0 * (c / (-b - b));
	else
		tmp_3 = (0.5 * sqrt(((c / a) * -4.0))) + (-0.5 * (b / a));
	end
	tmp_5 = 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[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[((-c) / b), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]}, Block[{t$95$2 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$2), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$2), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$3, (-Infinity)], t$95$1, If[LessEqual[t$95$3, -5e-297], If[GreaterEqual[b, 0.0], N[(2.0 * N[(c / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[t$95$3, 0.0], t$95$1, If[LessEqual[t$95$3, 2e+295], t$95$3, If[GreaterEqual[b, 0.0], N[(2.0 * N[(c / N[((-b) - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sqrt[N[(N[(c / a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(b / a), $MachinePrecision]), $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 := \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-c}{b}\\

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


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

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


\end{array}\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_3 \leq -5 \cdot 10^{-297}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;2 \cdot \frac{c}{\left(-b\right) - t_0}\\

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


\end{array}\\

\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_3 \leq 2 \cdot 10^{+295}:\\
\;\;\;\;t_3\\

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

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{c}{a} \cdot -4} + -0.5 \cdot \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 or -5e-297 < (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 44.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. Simplified44.1

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

      [Start]44.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} \]
    3. Taylor expanded in b around inf 22.7

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

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

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

      [Start]12.4

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

      rational.json-simplify-2 [=>]12.4

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

      rational.json-simplify-9 [=>]12.4

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

      rational.json-simplify-10 [=>]12.4

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

      rational.json-simplify-47 [=>]12.4

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

      rational.json-simplify-9 [=>]12.4

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{-c}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{-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))) < -5e-297

    1. Initial program 2.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{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Simplified2.5

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

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

    if 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))) < 2e295

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

    if 2e295 < (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 62.2

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

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

      [Start]62.2

      \[ \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} \]
    3. Taylor expanded in b around inf 56.5

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

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

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

      [Start]58.3

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

      exponential.json-simplify-20 [=>]38.8

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

      rational.json-simplify-2 [=>]38.8

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

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

Alternatives

Alternative 1
Error10.0
Cost7820
\[\begin{array}{l} t_0 := \frac{b}{-a}\\ \mathbf{if}\;b \leq -1.4 \cdot 10^{+144}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} + t_0\\ \end{array}\\ \mathbf{elif}\;b \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \left(0.5 \cdot \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 1.2 \cdot 10^{-68}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(\left(-b\right) + \frac{c}{b} \cdot \left(2 \cdot a\right)\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error10.2
Cost7820
\[\begin{array}{l} t_0 := \frac{b}{-a}\\ t_1 := 2 \cdot \frac{c}{\left(-b\right) - b}\\ \mathbf{if}\;b \leq -7.5 \cdot 10^{+87}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} + t_0\\ \end{array}\\ \mathbf{elif}\;b \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right)\\ \end{array}\\ \mathbf{elif}\;b \leq 4.2 \cdot 10^{-69}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(\left(-b\right) + \frac{c}{b} \cdot \left(2 \cdot a\right)\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error10.0
Cost7820
\[\begin{array}{l} t_0 := \frac{b}{-a}\\ t_1 := 2 \cdot \frac{c}{\left(-b\right) - b}\\ \mathbf{if}\;b \leq -2.8 \cdot 10^{+138}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} + t_0\\ \end{array}\\ \mathbf{elif}\;b \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a} \cdot 0.5\\ \end{array}\\ \mathbf{elif}\;b \leq 1.55 \cdot 10^{-69}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(\left(-b\right) + \frac{c}{b} \cdot \left(2 \cdot a\right)\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error6.9
Cost7820
\[\begin{array}{l} t_0 := \frac{b}{-a}\\ t_1 := \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\\ \mathbf{if}\;b \leq -1 \cdot 10^{+144}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} + t_0\\ \end{array}\\ \mathbf{elif}\;b \leq 8.4 \cdot 10^{+74}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + t_1}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error13.5
Cost7696
\[\begin{array}{l} t_0 := \frac{b}{-a}\\ t_1 := 2 \cdot \frac{c}{\left(-b\right) - b}\\ \mathbf{if}\;b \leq -2.15 \cdot 10^{-24}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} + t_0\\ \end{array}\\ \mathbf{elif}\;b \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{-4 \cdot \left(c \cdot a\right)}}{a} \cdot 0.5\\ \end{array}\\ \mathbf{elif}\;b \leq 6.8 \cdot 10^{-69}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(\left(-b\right) + \frac{c}{b} \cdot \left(2 \cdot a\right)\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error16.4
Cost7568
\[\begin{array}{l} t_0 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{-a}\\ \end{array}\\ \mathbf{if}\;b \leq -3.1 \cdot 10^{-159}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{c}{a} \cdot -4}\\ \end{array}\\ \mathbf{elif}\;b \leq 8 \cdot 10^{-69}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{-\sqrt{c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(\left(-b\right) + \frac{c}{b} \cdot \left(2 \cdot a\right)\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error13.8
Cost7568
\[\begin{array}{l} t_0 := \frac{b}{-a}\\ t_1 := 2 \cdot \frac{c}{\left(-b\right) - b}\\ t_2 := \sqrt{c \cdot \left(a \cdot -4\right)}\\ \mathbf{if}\;b \leq -1.3 \cdot 10^{-28}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} + t_0\\ \end{array}\\ \mathbf{elif}\;b \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(t_2 + \left(-b\right)\right)\\ \end{array}\\ \mathbf{elif}\;b \leq 5.4 \cdot 10^{-69}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{-t_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(\left(-b\right) + \frac{c}{b} \cdot \left(2 \cdot a\right)\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error14.0
Cost7568
\[\begin{array}{l} t_0 := \frac{b}{-a}\\ t_1 := 2 \cdot \frac{c}{\left(-b\right) - b}\\ \mathbf{if}\;b \leq -2 \cdot 10^{-20}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} + t_0\\ \end{array}\\ \mathbf{elif}\;b \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{-4 \cdot \left(c \cdot a\right)}}{a} \cdot 0.5\\ \end{array}\\ \mathbf{elif}\;b \leq 9.2 \cdot 10^{-69}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{-\sqrt{c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(\left(-b\right) + \frac{c}{b} \cdot \left(2 \cdot a\right)\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error21.6
Cost7112
\[\begin{array}{l} \mathbf{if}\;c \leq -9.8 \cdot 10^{+123}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{c}{a} \cdot -4}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{\frac{2}{\frac{\frac{b}{a}}{c}} + b \cdot -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
Alternative 10
Error22.0
Cost1092
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{c \cdot \left(2 \cdot \frac{a}{b}\right) + b \cdot -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
Alternative 11
Error22.0
Cost1092
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;2 \cdot \frac{c}{\frac{2}{\frac{\frac{b}{a}}{c}} + b \cdot -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
Alternative 12
Error22.2
Cost388
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{-a}\\ \end{array} \]

Error

Reproduce?

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