Average Error: 34.6 → 21.0
Time: 21.5s
Precision: binary64
Cost: 49680
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
\[\begin{array}{l} t_0 := c \cdot \left(a \cdot -4\right)\\ t_1 := \frac{\sqrt{b \cdot b + t_0} - b}{a \cdot 2}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(\mathsf{hypot}\left(\sqrt{c} \cdot \sqrt{a \cdot -4}, b\right) - b\right)\\ \mathbf{elif}\;t_1 \leq -2 \cdot 10^{-251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\frac{\frac{t_0}{b + \mathsf{hypot}\left(b, \sqrt{t_0}\right)}}{a \cdot 2}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+290}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{hypot}\left(\sqrt{c \cdot -4} \cdot \sqrt{a}, b\right) - b\right) \cdot \frac{0.5}{a}\\ \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (* c (* a -4.0)))
        (t_1 (/ (- (sqrt (+ (* b b) t_0)) b) (* a 2.0))))
   (if (<= t_1 (- INFINITY))
     (* (/ 0.5 a) (- (hypot (* (sqrt c) (sqrt (* a -4.0))) b) b))
     (if (<= t_1 -2e-251)
       t_1
       (if (<= t_1 0.0)
         (/ (/ t_0 (+ b (hypot b (sqrt t_0)))) (* a 2.0))
         (if (<= t_1 5e+290)
           t_1
           (* (- (hypot (* (sqrt (* c -4.0)) (sqrt a)) b) b) (/ 0.5 a))))))))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
double code(double a, double b, double c) {
	double t_0 = c * (a * -4.0);
	double t_1 = (sqrt(((b * b) + t_0)) - b) / (a * 2.0);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = (0.5 / a) * (hypot((sqrt(c) * sqrt((a * -4.0))), b) - b);
	} else if (t_1 <= -2e-251) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = (t_0 / (b + hypot(b, sqrt(t_0)))) / (a * 2.0);
	} else if (t_1 <= 5e+290) {
		tmp = t_1;
	} else {
		tmp = (hypot((sqrt((c * -4.0)) * sqrt(a)), b) - b) * (0.5 / a);
	}
	return tmp;
}
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
public static double code(double a, double b, double c) {
	double t_0 = c * (a * -4.0);
	double t_1 = (Math.sqrt(((b * b) + t_0)) - b) / (a * 2.0);
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = (0.5 / a) * (Math.hypot((Math.sqrt(c) * Math.sqrt((a * -4.0))), b) - b);
	} else if (t_1 <= -2e-251) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = (t_0 / (b + Math.hypot(b, Math.sqrt(t_0)))) / (a * 2.0);
	} else if (t_1 <= 5e+290) {
		tmp = t_1;
	} else {
		tmp = (Math.hypot((Math.sqrt((c * -4.0)) * Math.sqrt(a)), b) - b) * (0.5 / a);
	}
	return tmp;
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
def code(a, b, c):
	t_0 = c * (a * -4.0)
	t_1 = (math.sqrt(((b * b) + t_0)) - b) / (a * 2.0)
	tmp = 0
	if t_1 <= -math.inf:
		tmp = (0.5 / a) * (math.hypot((math.sqrt(c) * math.sqrt((a * -4.0))), b) - b)
	elif t_1 <= -2e-251:
		tmp = t_1
	elif t_1 <= 0.0:
		tmp = (t_0 / (b + math.hypot(b, math.sqrt(t_0)))) / (a * 2.0)
	elif t_1 <= 5e+290:
		tmp = t_1
	else:
		tmp = (math.hypot((math.sqrt((c * -4.0)) * math.sqrt(a)), b) - b) * (0.5 / a)
	return tmp
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a))
end
function code(a, b, c)
	t_0 = Float64(c * Float64(a * -4.0))
	t_1 = Float64(Float64(sqrt(Float64(Float64(b * b) + t_0)) - b) / Float64(a * 2.0))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(Float64(0.5 / a) * Float64(hypot(Float64(sqrt(c) * sqrt(Float64(a * -4.0))), b) - b));
	elseif (t_1 <= -2e-251)
		tmp = t_1;
	elseif (t_1 <= 0.0)
		tmp = Float64(Float64(t_0 / Float64(b + hypot(b, sqrt(t_0)))) / Float64(a * 2.0));
	elseif (t_1 <= 5e+290)
		tmp = t_1;
	else
		tmp = Float64(Float64(hypot(Float64(sqrt(Float64(c * -4.0)) * sqrt(a)), b) - b) * Float64(0.5 / a));
	end
	return tmp
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
end
function tmp_2 = code(a, b, c)
	t_0 = c * (a * -4.0);
	t_1 = (sqrt(((b * b) + t_0)) - b) / (a * 2.0);
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = (0.5 / a) * (hypot((sqrt(c) * sqrt((a * -4.0))), b) - b);
	elseif (t_1 <= -2e-251)
		tmp = t_1;
	elseif (t_1 <= 0.0)
		tmp = (t_0 / (b + hypot(b, sqrt(t_0)))) / (a * 2.0);
	elseif (t_1 <= 5e+290)
		tmp = t_1;
	else
		tmp = (hypot((sqrt((c * -4.0)) * sqrt(a)), b) - b) * (0.5 / a);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := 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[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(N[Sqrt[c], $MachinePrecision] * N[Sqrt[N[(a * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + b ^ 2], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -2e-251], t$95$1, If[LessEqual[t$95$1, 0.0], N[(N[(t$95$0 / N[(b + N[Sqrt[b ^ 2 + N[Sqrt[t$95$0], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+290], t$95$1, N[(N[(N[Sqrt[N[(N[Sqrt[N[(c * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[a], $MachinePrecision]), $MachinePrecision] ^ 2 + b ^ 2], $MachinePrecision] - b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision]]]]]]]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
t_0 := c \cdot \left(a \cdot -4\right)\\
t_1 := \frac{\sqrt{b \cdot b + t_0} - b}{a \cdot 2}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\mathsf{hypot}\left(\sqrt{c} \cdot \sqrt{a \cdot -4}, b\right) - b\right)\\

\mathbf{elif}\;t_1 \leq -2 \cdot 10^{-251}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\frac{\frac{t_0}{b + \mathsf{hypot}\left(b, \sqrt{t_0}\right)}}{a \cdot 2}\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+290}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\left(\mathsf{hypot}\left(\sqrt{c \cdot -4} \cdot \sqrt{a}, b\right) - b\right) \cdot \frac{0.5}{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 (/.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

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Simplified64.0

      \[\leadsto \color{blue}{\left(\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b\right) \cdot \frac{0.5}{a}} \]
      Proof
      (*.f64 (-.f64 (sqrt.f64 (fma.f64 a (*.f64 c -4) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (fma.f64 a (*.f64 c (Rewrite<= metadata-eval (neg.f64 4))) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (fma.f64 a (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 c 4))) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (fma.f64 a (neg.f64 (Rewrite=> *-commutative_binary64 (*.f64 4 c))) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (fma.f64 a (Rewrite=> distribute-lft-neg-in_binary64 (*.f64 (neg.f64 4) c)) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a (*.f64 (neg.f64 4) c)) (*.f64 b b)))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (+.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 a (neg.f64 4)) c)) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 1 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (+.f64 (*.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 a 4))) c) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (+.f64 (*.f64 (neg.f64 (Rewrite<= *-commutative_binary64 (*.f64 4 a))) c) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 b b) (*.f64 (neg.f64 (*.f64 4 a)) c)))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= unsub-neg_binary64 (+.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))) (neg.f64 b))) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (/.f64 (Rewrite<= metadata-eval (/.f64 1 2)) a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (/.f64 (/.f64 (Rewrite<= metadata-eval (neg.f64 -1)) 2) a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (Rewrite<= associate-/r*_binary64 (/.f64 (neg.f64 -1) (*.f64 2 a)))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (neg.f64 -1)) (*.f64 2 a))): 6 points increase in error, 32 points decrease in error
      (Rewrite=> associate-/l*_binary64 (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (/.f64 (*.f64 2 a) (neg.f64 -1)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (/.f64 (*.f64 2 a) (Rewrite=> metadata-eval 1))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (Rewrite=> /-rgt-identity_binary64 (*.f64 2 a))): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr64.0

      \[\leadsto \left(\sqrt{\color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -4\right)}\right)}^{3}}} - b\right) \cdot \frac{0.5}{a} \]
    4. Applied egg-rr64.0

      \[\leadsto \left(\color{blue}{\sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} \cdot {\left(\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)\right)}^{0.16666666666666666}} - b\right) \cdot \frac{0.5}{a} \]
    5. Simplified64.0

      \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\right)}^{1.5}} - b\right) \cdot \frac{0.5}{a} \]
      Proof
      (pow.f64 (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b))) 3/2): 0 points increase in error, 0 points decrease in error
      (pow.f64 (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b))) (Rewrite<= metadata-eval (+.f64 1/2 1))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= pow-plus_binary64 (*.f64 (pow.f64 (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b))) 1/2) (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b))))): 21 points increase in error, 22 points decrease in error
      (*.f64 (Rewrite=> unpow1/2_binary64 (sqrt.f64 (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b))))) (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (sqrt.f64 (Rewrite<= unpow1/3_binary64 (pow.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)) 1/3))) (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)))): 63 points increase in error, 115 points decrease in error
      (*.f64 (sqrt.f64 (pow.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)) (Rewrite<= metadata-eval (*.f64 2 1/6)))) (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (sqrt.f64 (Rewrite<= pow-sqr_binary64 (*.f64 (pow.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)) 1/6) (pow.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)) 1/6)))) (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)))): 11 points increase in error, 7 points decrease in error
      (*.f64 (Rewrite=> rem-sqrt-square_binary64 (fabs.f64 (pow.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)) 1/6))) (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (fabs.f64 (Rewrite=> sqr-pow_binary64 (*.f64 (pow.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)) (/.f64 1/6 2)) (pow.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)) (/.f64 1/6 2))))) (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)))): 37 points increase in error, 45 points decrease in error
      (*.f64 (Rewrite=> fabs-sqr_binary64 (*.f64 (pow.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)) (/.f64 1/6 2)) (pow.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)) (/.f64 1/6 2)))) (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= sqr-pow_binary64 (pow.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)) 1/6)) (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)))): 45 points increase in error, 37 points decrease in error
      (Rewrite<= *-commutative_binary64 (*.f64 (cbrt.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b))) (pow.f64 (fma.f64 c (*.f64 a -4) (*.f64 b b)) 1/6))): 0 points increase in error, 0 points decrease in error
    6. Applied egg-rr32.8

      \[\leadsto \left(\color{blue}{\mathsf{hypot}\left(\sqrt{c} \cdot \sqrt{a \cdot -4}, b\right)} - b\right) \cdot \frac{0.5}{a} \]

    if -inf.0 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) < -2.00000000000000003e-251 or 0.0 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) < 4.9999999999999998e290

    1. Initial program 4.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]

    if -2.00000000000000003e-251 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) < 0.0

    1. Initial program 52.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Applied egg-rr55.8

      \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right) - b \cdot b}{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}}}{2 \cdot a} \]
    3. Simplified36.9

      \[\leadsto \frac{\color{blue}{\frac{c \cdot \left(a \cdot -4\right)}{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}}}{2 \cdot a} \]
      Proof
      (/.f64 (*.f64 c (*.f64 a -4)) (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 c (*.f64 a -4)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= +-rgt-identity_binary64 (+.f64 (*.f64 c (*.f64 a -4)) 0)) (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 c (*.f64 a -4)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (*.f64 c (*.f64 a -4)) (Rewrite<= +-inverses_binary64 (-.f64 (*.f64 b b) (*.f64 b b)))) (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 c (*.f64 a -4)))))): 17 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (*.f64 c (*.f64 a -4)) (*.f64 b b)) (*.f64 b b))) (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 c (*.f64 a -4)))))): 10 points increase in error, 9 points decrease in error
      (/.f64 (-.f64 (Rewrite<= fma-udef_binary64 (fma.f64 c (*.f64 a -4) (*.f64 b b))) (*.f64 b b)) (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 c (*.f64 a -4)))))): 0 points increase in error, 0 points decrease in error

    if 4.9999999999999998e290 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))

    1. Initial program 62.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Simplified62.6

      \[\leadsto \color{blue}{\left(\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b\right) \cdot \frac{0.5}{a}} \]
      Proof
      (*.f64 (-.f64 (sqrt.f64 (fma.f64 a (*.f64 c -4) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (fma.f64 a (*.f64 c (Rewrite<= metadata-eval (neg.f64 4))) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (fma.f64 a (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 c 4))) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (fma.f64 a (neg.f64 (Rewrite=> *-commutative_binary64 (*.f64 4 c))) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (fma.f64 a (Rewrite=> distribute-lft-neg-in_binary64 (*.f64 (neg.f64 4) c)) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a (*.f64 (neg.f64 4) c)) (*.f64 b b)))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (+.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 a (neg.f64 4)) c)) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 1 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (+.f64 (*.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 a 4))) c) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (+.f64 (*.f64 (neg.f64 (Rewrite<= *-commutative_binary64 (*.f64 4 a))) c) (*.f64 b b))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 b b) (*.f64 (neg.f64 (*.f64 4 a)) c)))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (-.f64 (sqrt.f64 (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) b) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= unsub-neg_binary64 (+.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))) (neg.f64 b))) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 1/2 a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (/.f64 (Rewrite<= metadata-eval (/.f64 1 2)) a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (/.f64 (/.f64 (Rewrite<= metadata-eval (neg.f64 -1)) 2) a)): 0 points increase in error, 0 points decrease in error
      (*.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (Rewrite<= associate-/r*_binary64 (/.f64 (neg.f64 -1) (*.f64 2 a)))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (neg.f64 -1)) (*.f64 2 a))): 6 points increase in error, 32 points decrease in error
      (Rewrite=> associate-/l*_binary64 (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (/.f64 (*.f64 2 a) (neg.f64 -1)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (/.f64 (*.f64 2 a) (Rewrite=> metadata-eval 1))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (Rewrite=> /-rgt-identity_binary64 (*.f64 2 a))): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr35.5

      \[\leadsto \left(\color{blue}{\mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{c \cdot -4}, b\right)} - b\right) \cdot \frac{0.5}{a} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification21.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2} \leq -\infty:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(\mathsf{hypot}\left(\sqrt{c} \cdot \sqrt{a \cdot -4}, b\right) - b\right)\\ \mathbf{elif}\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2} \leq -2 \cdot 10^{-251}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{elif}\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2} \leq 0:\\ \;\;\;\;\frac{\frac{c \cdot \left(a \cdot -4\right)}{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}}{a \cdot 2}\\ \mathbf{elif}\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2} \leq 5 \cdot 10^{+290}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{hypot}\left(\sqrt{c \cdot -4} \cdot \sqrt{a}, b\right) - b\right) \cdot \frac{0.5}{a}\\ \end{array} \]

Alternatives

Alternative 1
Error23.5
Cost49680
\[\begin{array}{l} t_0 := c \cdot \left(a \cdot -4\right)\\ t_1 := \frac{\sqrt{b \cdot b + t_0} - b}{a \cdot 2}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\frac{\mathsf{hypot}\left(b, \sqrt{\left(a \cdot c\right) \cdot -4}\right) - b}{a \cdot 2}\\ \mathbf{elif}\;t_1 \leq -2 \cdot 10^{-251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\frac{\frac{t_0}{b + \mathsf{hypot}\left(b, \sqrt{t_0}\right)}}{a \cdot 2}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+290}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{hypot}\left(\sqrt{c \cdot -4} \cdot \sqrt{a}, b\right) - b\right) \cdot \frac{0.5}{a}\\ \end{array} \]
Alternative 2
Error21.0
Cost42252
\[\begin{array}{l} t_0 := \frac{\mathsf{hypot}\left(\sqrt{4 \cdot \left|a \cdot c\right|}, b\right) - b}{a \cdot 2}\\ t_1 := c \cdot \left(a \cdot -4\right)\\ t_2 := \frac{\sqrt{b \cdot b + t_1} - b}{a \cdot 2}\\ \mathbf{if}\;t_2 \leq -2 \cdot 10^{-251}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\frac{\frac{t_1}{b + \mathsf{hypot}\left(b, \sqrt{t_1}\right)}}{a \cdot 2}\\ \mathbf{elif}\;t_2 \leq 10^{+290}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{hypot}\left(\sqrt{c \cdot -4} \cdot \sqrt{a}, b\right) - b}{a \cdot 2}\\ \end{array} \]
Alternative 3
Error21.0
Cost42252
\[\begin{array}{l} t_0 := \frac{\mathsf{hypot}\left(\sqrt{4 \cdot \left|a \cdot c\right|}, b\right) - b}{a \cdot 2}\\ t_1 := c \cdot \left(a \cdot -4\right)\\ t_2 := \frac{\sqrt{b \cdot b + t_1} - b}{a \cdot 2}\\ \mathbf{if}\;t_2 \leq -2 \cdot 10^{-251}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\frac{\frac{t_1}{b + \mathsf{hypot}\left(b, \sqrt{t_1}\right)}}{a \cdot 2}\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+290}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{hypot}\left(\sqrt{c \cdot -4} \cdot \sqrt{a}, b\right) - b\right) \cdot \frac{0.5}{a}\\ \end{array} \]
Alternative 4
Error28.9
Cost28424
\[\begin{array}{l} t_0 := \frac{\mathsf{hypot}\left(b, \sqrt{\left(a \cdot c\right) \cdot -4}\right) - b}{a \cdot 2}\\ t_1 := \frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+246}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error24.1
Cost14216
\[\begin{array}{l} t_0 := a \cdot \left(c \cdot -4\right)\\ \mathbf{if}\;b \leq -2.8 \cdot 10^{+163}:\\ \;\;\;\;\frac{\mathsf{hypot}\left(b, \sqrt{\left(a \cdot c\right) \cdot -4}\right) - b}{a \cdot 2}\\ \mathbf{elif}\;b \leq 8 \cdot 10^{-66}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{a} \cdot \frac{t_0}{b + \mathsf{hypot}\left(\sqrt{t_0}, b\right)}\\ \end{array} \]
Alternative 6
Error23.9
Cost14216
\[\begin{array}{l} t_0 := c \cdot \left(a \cdot -4\right)\\ \mathbf{if}\;b \leq -2.8 \cdot 10^{+163}:\\ \;\;\;\;\frac{\mathsf{hypot}\left(b, \sqrt{\left(a \cdot c\right) \cdot -4}\right) - b}{a \cdot 2}\\ \mathbf{elif}\;b \leq 4 \cdot 10^{-152}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + t_0} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t_0}{b + \mathsf{hypot}\left(b, \sqrt{t_0}\right)}}{a \cdot 2}\\ \end{array} \]
Alternative 7
Error23.2
Cost14216
\[\begin{array}{l} t_0 := a \cdot \left(c \cdot -4\right)\\ \mathbf{if}\;b \leq -2.8 \cdot 10^{+163}:\\ \;\;\;\;\frac{\mathsf{hypot}\left(b, \sqrt{\left(a \cdot c\right) \cdot -4}\right) - b}{a \cdot 2}\\ \mathbf{elif}\;b \leq 8 \cdot 10^{-66}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{a} \cdot \frac{0.5}{b + \mathsf{hypot}\left(b, \sqrt{t_0}\right)}\\ \end{array} \]
Alternative 8
Error34.7
Cost7360
\[\frac{0.5}{a} \cdot \left(\sqrt{b \cdot b + \left(a \cdot c\right) \cdot -4} - b\right) \]
Alternative 9
Error34.6
Cost7360
\[\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2} \]

Error

Reproduce

herbie shell --seed 2022334 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))