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

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

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

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

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original34.6
Target21.6
Herbie22.1
\[\begin{array}{l} \mathbf{if}\;b < 0:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \end{array} \]

Derivation

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

    1. Initial program 64.0

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

      \[\leadsto \frac{\color{blue}{\mathsf{hypot}\left(b, \sqrt{\left(a \cdot c\right) \cdot -4}\right) - b}}{2 \cdot a} \]
    3. Applied egg-rr39.6

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

      \[\leadsto \frac{\mathsf{hypot}\left(b, \sqrt{\color{blue}{\sqrt{16 \cdot {\left(a \cdot c\right)}^{2}}}}\right) - b}{2 \cdot a} \]
      Proof
      (sqrt.f64 (*.f64 16 (pow.f64 (*.f64 a c) 2))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unpow1/2_binary64 (pow.f64 (*.f64 16 (pow.f64 (*.f64 a c) 2)) 1/2)): 0 points increase in error, 0 points decrease in error

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

    1. Initial program 4.3

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

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

    1. Initial program 48.5

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

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

      \[\leadsto \left(b - \sqrt{\color{blue}{b \cdot b + a \cdot \left(c \cdot -4\right)}}\right) \cdot \frac{-0.5}{a} \]
    4. Applied egg-rr56.0

      \[\leadsto \left(b - \color{blue}{e^{\log \left(\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)\right) \cdot 0.5}}\right) \cdot \frac{-0.5}{a} \]
    5. Applied egg-rr56.1

      \[\leadsto \left(b - \color{blue}{{\left(e^{0.5}\right)}^{\log \left(\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)\right)}}\right) \cdot \frac{-0.5}{a} \]
    6. Applied egg-rr53.9

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

      \[\leadsto \color{blue}{\frac{-0.5}{\left(b + \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right) \cdot \frac{a}{\left(a \cdot c\right) \cdot 4}}} \]
      Proof
      (/.f64 -1/2 (*.f64 (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) (/.f64 a (*.f64 (*.f64 a c) 4)))): 0 points increase in error, 0 points decrease in error
      (/.f64 -1/2 (*.f64 (Rewrite<= /-rgt-identity_binary64 (/.f64 (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) 1)) (/.f64 a (*.f64 (*.f64 a c) 4)))): 0 points increase in error, 0 points decrease in error
      (/.f64 -1/2 (*.f64 (/.f64 (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) 1) (/.f64 a (*.f64 (*.f64 a c) (Rewrite<= metadata-eval (neg.f64 -4)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 -1/2 (*.f64 (/.f64 (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) 1) (/.f64 a (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (*.f64 a c) -4)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 -1/2 (*.f64 (/.f64 (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) 1) (/.f64 a (neg.f64 (Rewrite<= associate-*r*_binary64 (*.f64 a (*.f64 c -4))))))): 1 points increase in error, 0 points decrease in error
      (/.f64 -1/2 (*.f64 (/.f64 (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) 1) (/.f64 a (Rewrite=> neg-sub0_binary64 (-.f64 0 (*.f64 a (*.f64 c -4))))))): 0 points increase in error, 0 points decrease in error
      (/.f64 -1/2 (*.f64 (/.f64 (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) 1) (/.f64 a (-.f64 (Rewrite<= +-inverses_binary64 (-.f64 (*.f64 b b) (*.f64 b b))) (*.f64 a (*.f64 c -4)))))): 17 points increase in error, 0 points decrease in error
      (/.f64 -1/2 (*.f64 (/.f64 (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) 1) (/.f64 a (Rewrite<= associate--r+_binary64 (-.f64 (*.f64 b b) (+.f64 (*.f64 b b) (*.f64 a (*.f64 c -4)))))))): 17 points increase in error, 1 points decrease in error
      (/.f64 -1/2 (*.f64 (/.f64 (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) 1) (/.f64 a (-.f64 (*.f64 b b) (Rewrite<= fma-udef_binary64 (fma.f64 b b (*.f64 a (*.f64 c -4)))))))): 0 points increase in error, 0 points decrease in error
      (/.f64 -1/2 (Rewrite<= times-frac_binary64 (/.f64 (*.f64 (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) a) (*.f64 1 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 a (*.f64 c -4)))))))): 24 points increase in error, 9 points decrease in error
      (/.f64 -1/2 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 a (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))) (*.f64 1 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 a (*.f64 c -4))))))): 0 points increase in error, 0 points decrease in error
      (/.f64 -1/2 (/.f64 (*.f64 a (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))))) (Rewrite=> *-lft-identity_binary64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 a (*.f64 c -4))))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 -1/2 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 a (*.f64 c -4))))) (*.f64 a (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))))))): 5 points increase in error, 9 points decrease in error
      (Rewrite=> times-frac_binary64 (*.f64 (/.f64 -1/2 a) (/.f64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 a (*.f64 c -4)))) (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))))))): 22 points increase in error, 26 points decrease in error
      (*.f64 (/.f64 (Rewrite<= metadata-eval (/.f64 1 -2)) a) (/.f64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 a (*.f64 c -4)))) (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= associate-/r*_binary64 (/.f64 1 (*.f64 -2 a))) (/.f64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 a (*.f64 c -4)))) (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 1 (Rewrite<= *-commutative_binary64 (*.f64 a -2))) (/.f64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 a (*.f64 c -4)))) (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= times-frac_binary64 (/.f64 (*.f64 1 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 a (*.f64 c -4))))) (*.f64 (*.f64 a -2) (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))))))): 26 points increase in error, 22 points decrease in error
      (/.f64 (Rewrite=> *-lft-identity_binary64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 a (*.f64 c -4))))) (*.f64 (*.f64 a -2) (+.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))): 0 points increase in error, 0 points decrease in error

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

    1. Initial program 62.7

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

      \[\leadsto \frac{\color{blue}{\mathsf{hypot}\left(b, \sqrt{\left(a \cdot c\right) \cdot -4}\right) - b}}{2 \cdot a} \]
    3. Applied egg-rr35.5

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

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

Alternatives

Alternative 1
Error23.3
Cost49680
\[\begin{array}{l} t_0 := 4 \cdot \left(a \cdot c\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^{-179}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\frac{-0.5}{\left(b + \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right) \cdot \frac{a}{t_0}}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+290}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(b - \mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{c \cdot -4}, b\right)\right) \cdot \frac{-0.5}{a}\\ \end{array} \]
Alternative 2
Error23.3
Cost49680
\[\begin{array}{l} t_0 := 4 \cdot \left(a \cdot c\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^{-179}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\frac{-0.5}{\left(b + \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right) \cdot \frac{a}{t_0}}\\ \mathbf{elif}\;t_1 \leq 10^{+290}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{hypot}\left(b, \sqrt{a} \cdot \sqrt{c \cdot -4}\right) - b}{a \cdot 2}\\ \end{array} \]
Alternative 3
Error24.1
Cost14216
\[\begin{array}{l} t_0 := 4 \cdot \left(a \cdot c\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 - t_0} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{a} \cdot \frac{t_0}{b + \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)}\\ \end{array} \]
Alternative 4
Error23.3
Cost14216
\[\begin{array}{l} t_0 := 4 \cdot \left(a \cdot c\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 - t_0} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{\left(b + \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right) \cdot \frac{a}{t_0}}\\ \end{array} \]
Alternative 5
Error27.3
Cost13700
\[\begin{array}{l} \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.5 \cdot 10^{+136}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 6
Error30.1
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 4 \cdot 10^{+135}:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 7
Error30.0
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 4 \cdot 10^{+131}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 8
Error56.4
Cost64
\[0 \]

Error

Reproduce

herbie shell --seed 2022334 
(FPCore (a b c)
  :name "quadp (p42, positive)"
  :precision binary64

  :herbie-target
  (if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))))

  (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))