Average Error: 34.7 → 12.1
Time: 22.1s
Precision: binary64
Cost: 20232
\[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]
\[\begin{array}{l} \mathbf{if}\;b \leq 8.5 \cdot 10^{-269}:\\ \;\;\;\;\frac{c \cdot -2}{b - \mathsf{hypot}\left(b, \sqrt{\left|a \cdot \left(c \cdot -4\right)\right|}\right)}\\ \mathbf{elif}\;b \leq 2.3 \cdot 10^{+152}:\\ \;\;\;\;-\frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{c \cdot -4}, b\right)\right)\\ \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
 (if (<= b 8.5e-269)
   (/ (* c -2.0) (- b (hypot b (sqrt (fabs (* a (* c -4.0)))))))
   (if (<= b 2.3e+152)
     (- (/ (+ b (sqrt (- (* b b) (* 4.0 (* c a))))) (* a 2.0)))
     (* (/ -0.5 a) (+ b (hypot (* (sqrt a) (sqrt (* c -4.0))) b))))))
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 tmp;
	if (b <= 8.5e-269) {
		tmp = (c * -2.0) / (b - hypot(b, sqrt(fabs((a * (c * -4.0))))));
	} else if (b <= 2.3e+152) {
		tmp = -((b + sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0));
	} else {
		tmp = (-0.5 / a) * (b + hypot((sqrt(a) * sqrt((c * -4.0))), b));
	}
	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 tmp;
	if (b <= 8.5e-269) {
		tmp = (c * -2.0) / (b - Math.hypot(b, Math.sqrt(Math.abs((a * (c * -4.0))))));
	} else if (b <= 2.3e+152) {
		tmp = -((b + Math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0));
	} else {
		tmp = (-0.5 / a) * (b + Math.hypot((Math.sqrt(a) * Math.sqrt((c * -4.0))), b));
	}
	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):
	tmp = 0
	if b <= 8.5e-269:
		tmp = (c * -2.0) / (b - math.hypot(b, math.sqrt(math.fabs((a * (c * -4.0))))))
	elif b <= 2.3e+152:
		tmp = -((b + math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0))
	else:
		tmp = (-0.5 / a) * (b + math.hypot((math.sqrt(a) * math.sqrt((c * -4.0))), b))
	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)
	tmp = 0.0
	if (b <= 8.5e-269)
		tmp = Float64(Float64(c * -2.0) / Float64(b - hypot(b, sqrt(abs(Float64(a * Float64(c * -4.0)))))));
	elseif (b <= 2.3e+152)
		tmp = Float64(-Float64(Float64(b + sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a))))) / Float64(a * 2.0)));
	else
		tmp = Float64(Float64(-0.5 / a) * Float64(b + hypot(Float64(sqrt(a) * sqrt(Float64(c * -4.0))), b)));
	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)
	tmp = 0.0;
	if (b <= 8.5e-269)
		tmp = (c * -2.0) / (b - hypot(b, sqrt(abs((a * (c * -4.0))))));
	elseif (b <= 2.3e+152)
		tmp = -((b + sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0));
	else
		tmp = (-0.5 / a) * (b + hypot((sqrt(a) * sqrt((c * -4.0))), b));
	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_] := If[LessEqual[b, 8.5e-269], N[(N[(c * -2.0), $MachinePrecision] / N[(b - N[Sqrt[b ^ 2 + N[Sqrt[N[Abs[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.3e+152], (-N[(N[(b + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), N[(N[(-0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(N[Sqrt[a], $MachinePrecision] * N[Sqrt[N[(c * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + b ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \leq 8.5 \cdot 10^{-269}:\\
\;\;\;\;\frac{c \cdot -2}{b - \mathsf{hypot}\left(b, \sqrt{\left|a \cdot \left(c \cdot -4\right)\right|}\right)}\\

\mathbf{elif}\;b \leq 2.3 \cdot 10^{+152}:\\
\;\;\;\;-\frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original34.7
Target21.2
Herbie12.1
\[\begin{array}{l} \mathbf{if}\;b < 0:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\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 3 regimes
  2. if b < 8.5e-269

    1. Initial program 43.5

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

      \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a \cdot c, -4, b \cdot b\right)}\right)} \]
      Proof
      (*.f64 (/.f64 -1/2 a) (+.f64 b (sqrt.f64 (fma.f64 (*.f64 a c) -4 (*.f64 b b))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (Rewrite<= metadata-eval (/.f64 -1 2)) a) (+.f64 b (sqrt.f64 (fma.f64 (*.f64 a c) -4 (*.f64 b b))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= associate-/r*_binary64 (/.f64 -1 (*.f64 2 a))) (+.f64 b (sqrt.f64 (fma.f64 (*.f64 a c) -4 (*.f64 b b))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (sqrt.f64 (fma.f64 (*.f64 a c) (Rewrite<= metadata-eval (neg.f64 4)) (*.f64 b b))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (sqrt.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (*.f64 a c) (neg.f64 4)) (*.f64 b b)))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (sqrt.f64 (+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (*.f64 a c) 4))) (*.f64 b b))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (sqrt.f64 (+.f64 (neg.f64 (Rewrite<= *-commutative_binary64 (*.f64 4 (*.f64 a c)))) (*.f64 b b))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (sqrt.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 b b) (neg.f64 (*.f64 4 (*.f64 a c)))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (sqrt.f64 (Rewrite<= sub-neg_binary64 (-.f64 (*.f64 b b) (*.f64 4 (*.f64 a c))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 4 (*.f64 a c))))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (Rewrite<= sub-neg_binary64 (-.f64 b (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 4 (*.f64 a c)))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (Rewrite=> sub-neg_binary64 (+.f64 b (neg.f64 (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 4 (*.f64 a c))))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (Rewrite=> remove-double-neg_binary64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 4 (*.f64 a c))))))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 -1 (+.f64 b (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 4 (*.f64 a c)))))) (*.f64 2 a))): 7 points increase in error, 17 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<= distribute-neg-out_binary64 (+.f64 (neg.f64 b) (neg.f64 (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<= sub-neg_binary64 (-.f64 (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-rr45.3

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

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

      \[\leadsto \frac{-0.5}{a} \cdot \color{blue}{\frac{\left(a \cdot c\right) \cdot -4}{\mathsf{hypot}\left(b, \sqrt{\left(a \cdot c\right) \cdot -4}\right) - b}} \]
      Proof
      (/.f64 (*.f64 (*.f64 a c) -4) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))) b)): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= +-rgt-identity_binary64 (+.f64 (*.f64 (*.f64 a c) -4) 0)) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))) b)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (*.f64 (*.f64 a c) -4) (Rewrite<= +-inverses_binary64 (-.f64 (*.f64 b b) (*.f64 b b)))) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))) b)): 29 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (*.f64 (*.f64 a c) -4) (*.f64 b b)) (*.f64 b b))) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))) b)): 9 points increase in error, 20 points decrease in error
      (/.f64 (-.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 b b) (*.f64 (*.f64 a c) -4))) (*.f64 b b)) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))) b)): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (Rewrite<= fma-udef_binary64 (fma.f64 b b (*.f64 (*.f64 a c) -4))) (*.f64 b b)) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))) b)): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite=> sub-neg_binary64 (+.f64 (fma.f64 b b (*.f64 (*.f64 a c) -4)) (neg.f64 (*.f64 b b)))) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))) b)): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite=> +-commutative_binary64 (+.f64 (neg.f64 (*.f64 b b)) (fma.f64 b b (*.f64 (*.f64 a c) -4)))) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))) b)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 (*.f64 b b))) (fma.f64 b b (*.f64 (*.f64 a c) -4))) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))) b)): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= associate--r-_binary64 (-.f64 0 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 (*.f64 a c) -4))))) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))) b)): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 (*.f64 a c) -4))))) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))) b)): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 (*.f64 a c) -4)))) (Rewrite=> sub-neg_binary64 (+.f64 (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))) (neg.f64 b)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 (*.f64 a c) -4)))) (Rewrite=> +-commutative_binary64 (+.f64 (neg.f64 b) (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 (*.f64 a c) -4)))) (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 b)) (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 (*.f64 a c) -4)))) (Rewrite<= associate--r-_binary64 (-.f64 0 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 (*.f64 a c) -4)))) (Rewrite<= neg-sub0_binary64 (neg.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite=> neg-mul-1_binary64 (*.f64 -1 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 (*.f64 a c) -4))))) (neg.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (*.f64 -1 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 (*.f64 a c) -4)))) (Rewrite=> neg-mul-1_binary64 (*.f64 -1 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))))))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> times-frac_binary64 (*.f64 (/.f64 -1 -1) (/.f64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 (*.f64 a c) -4))) (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite=> metadata-eval 1) (/.f64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 (*.f64 a c) -4))) (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4)))))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> *-lft-identity_binary64 (/.f64 (-.f64 (*.f64 b b) (fma.f64 b b (*.f64 (*.f64 a c) -4))) (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4)))))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> div-sub_binary64 (-.f64 (/.f64 (*.f64 b b) (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))))) (/.f64 (fma.f64 b b (*.f64 (*.f64 a c) -4)) (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 (*.f64 a c) -4))))))): 0 points increase in error, 1 points decrease in error
    6. Applied egg-rr28.3

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

      \[\leadsto \color{blue}{1 \cdot \frac{c \cdot -2}{b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)}} \]
      Proof
      (*.f64 1 (/.f64 (*.f64 c -2) (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= *-inverses_binary64 (/.f64 a a)) (/.f64 (*.f64 c -2) (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 a a) (/.f64 (*.f64 c (Rewrite<= metadata-eval (*.f64 -4 1/2))) (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 a a) (/.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 c -4) 1/2)) (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))): 1 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 a a) (/.f64 (*.f64 (*.f64 c -4) 1/2) (-.f64 (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 b))) (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 a a) (/.f64 (*.f64 (*.f64 c -4) 1/2) (-.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 (neg.f64 b))) (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 a a) (/.f64 (*.f64 (*.f64 c -4) 1/2) (Rewrite<= associate--r+_binary64 (-.f64 0 (+.f64 (neg.f64 b) (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 a a) (/.f64 (*.f64 (*.f64 c -4) 1/2) (-.f64 0 (Rewrite<= +-commutative_binary64 (+.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) (neg.f64 b)))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 a a) (/.f64 (*.f64 (*.f64 c -4) 1/2) (-.f64 0 (Rewrite=> unsub-neg_binary64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 a a) (/.f64 (*.f64 (*.f64 c -4) 1/2) (Rewrite<= neg-sub0_binary64 (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= times-frac_binary64 (/.f64 (*.f64 a (*.f64 (*.f64 c -4) 1/2)) (*.f64 a (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))))): 69 points increase in error, 4 points decrease in error
      (/.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 a (*.f64 c -4)) 1/2)) (*.f64 a (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (*.f64 (Rewrite=> associate-*r*_binary64 (*.f64 (*.f64 a c) -4)) 1/2) (*.f64 a (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b)))): 0 points increase in error, 1 points decrease in error
      (/.f64 (Rewrite=> associate-*l*_binary64 (*.f64 (*.f64 a c) (*.f64 -4 1/2))) (*.f64 a (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (*.f64 (*.f64 a c) (Rewrite=> metadata-eval -2)) (*.f64 a (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (*.f64 (*.f64 a c) (Rewrite<= metadata-eval (*.f64 4 -1/2))) (*.f64 a (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 (*.f64 a c) 4) -1/2)) (*.f64 a (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite=> *-commutative_binary64 (*.f64 -1/2 (*.f64 (*.f64 a c) 4))) (*.f64 a (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b)))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> times-frac_binary64 (*.f64 (/.f64 -1/2 a) (/.f64 (*.f64 (*.f64 a c) 4) (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))))): 31 points increase in error, 24 points decrease in error
      (*.f64 (/.f64 (Rewrite<= metadata-eval (/.f64 1/2 -1)) a) (/.f64 (*.f64 (*.f64 a c) 4) (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= associate-/r*_binary64 (/.f64 1/2 (*.f64 -1 a))) (/.f64 (*.f64 (*.f64 a c) 4) (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 1/2 (Rewrite<= neg-mul-1_binary64 (neg.f64 a))) (/.f64 (*.f64 (*.f64 a c) 4) (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= times-frac_binary64 (/.f64 (*.f64 1/2 (*.f64 (*.f64 a c) 4)) (*.f64 (neg.f64 a) (neg.f64 (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))))): 24 points increase in error, 31 points decrease in error
      (/.f64 (*.f64 1/2 (*.f64 (*.f64 a c) 4)) (Rewrite=> distribute-rgt-neg-out_binary64 (neg.f64 (*.f64 (neg.f64 a) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (*.f64 1/2 (*.f64 (*.f64 a c) 4)) (neg.f64 (Rewrite=> distribute-lft-neg-out_binary64 (neg.f64 (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (*.f64 1/2 (*.f64 (*.f64 a c) 4)) (Rewrite=> remove-double-neg_binary64 (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite=> *-commutative_binary64 (*.f64 (*.f64 (*.f64 a c) 4) 1/2)) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite=> associate-*l*_binary64 (*.f64 (*.f64 a c) (*.f64 4 1/2))) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))): 0 points increase in error, 0 points decrease in error
      (/.f64 (*.f64 (*.f64 a c) (Rewrite=> metadata-eval 2)) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 2 (*.f64 a c))) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-/r*_binary64 (/.f64 (/.f64 (*.f64 2 (*.f64 a c)) a) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))): 9 points increase in error, 30 points decrease in error
      (Rewrite<= +-lft-identity_binary64 (+.f64 0 (/.f64 (/.f64 (*.f64 2 (*.f64 a c)) a) (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b)))): 0 points increase in error, 0 points decrease in error
    8. Applied egg-rr17.4

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

      \[\leadsto 1 \cdot \frac{c \cdot -2}{b - \mathsf{hypot}\left(b, \sqrt{\color{blue}{\left|a \cdot \left(c \cdot -4\right)\right|}}\right)} \]
      Proof
      (fabs.f64 (*.f64 a (*.f64 c -4))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= rem-sqrt-square_binary64 (sqrt.f64 (*.f64 (*.f64 a (*.f64 c -4)) (*.f64 a (*.f64 c -4))))): 49 points increase in error, 34 points decrease in error
      (sqrt.f64 (*.f64 (Rewrite=> associate-*r*_binary64 (*.f64 (*.f64 a c) -4)) (*.f64 a (*.f64 c -4)))): 0 points increase in error, 0 points decrease in error
      (sqrt.f64 (*.f64 (*.f64 (*.f64 a c) -4) (Rewrite=> associate-*r*_binary64 (*.f64 (*.f64 a c) -4)))): 0 points increase in error, 0 points decrease in error
      (sqrt.f64 (Rewrite=> swap-sqr_binary64 (*.f64 (*.f64 (*.f64 a c) (*.f64 a c)) (*.f64 -4 -4)))): 0 points increase in error, 0 points decrease in error
      (sqrt.f64 (*.f64 (Rewrite<= unpow2_binary64 (pow.f64 (*.f64 a c) 2)) (*.f64 -4 -4))): 0 points increase in error, 0 points decrease in error
      (sqrt.f64 (*.f64 (pow.f64 (*.f64 a c) 2) (Rewrite=> metadata-eval 16))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unpow1/2_binary64 (pow.f64 (*.f64 (pow.f64 (*.f64 a c) 2) 16) 1/2)): 0 points increase in error, 0 points decrease in error

    if 8.5e-269 < b < 2.29999999999999985e152

    1. Initial program 8.6

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

    if 2.29999999999999985e152 < b

    1. Initial program 63.4

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

      \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a \cdot c, -4, b \cdot b\right)}\right)} \]
      Proof
      (*.f64 (/.f64 -1/2 a) (+.f64 b (sqrt.f64 (fma.f64 (*.f64 a c) -4 (*.f64 b b))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (Rewrite<= metadata-eval (/.f64 -1 2)) a) (+.f64 b (sqrt.f64 (fma.f64 (*.f64 a c) -4 (*.f64 b b))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= associate-/r*_binary64 (/.f64 -1 (*.f64 2 a))) (+.f64 b (sqrt.f64 (fma.f64 (*.f64 a c) -4 (*.f64 b b))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (sqrt.f64 (fma.f64 (*.f64 a c) (Rewrite<= metadata-eval (neg.f64 4)) (*.f64 b b))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (sqrt.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (*.f64 a c) (neg.f64 4)) (*.f64 b b)))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (sqrt.f64 (+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (*.f64 a c) 4))) (*.f64 b b))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (sqrt.f64 (+.f64 (neg.f64 (Rewrite<= *-commutative_binary64 (*.f64 4 (*.f64 a c)))) (*.f64 b b))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (sqrt.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 b b) (neg.f64 (*.f64 4 (*.f64 a c)))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (sqrt.f64 (Rewrite<= sub-neg_binary64 (-.f64 (*.f64 b b) (*.f64 4 (*.f64 a c))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 4 (*.f64 a c))))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (Rewrite<= sub-neg_binary64 (-.f64 b (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 4 (*.f64 a c)))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (Rewrite=> sub-neg_binary64 (+.f64 b (neg.f64 (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 4 (*.f64 a c))))))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 -1 (*.f64 2 a)) (+.f64 b (Rewrite=> remove-double-neg_binary64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 4 (*.f64 a c))))))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 -1 (+.f64 b (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 4 (*.f64 a c)))))) (*.f64 2 a))): 7 points increase in error, 17 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<= distribute-neg-out_binary64 (+.f64 (neg.f64 b) (neg.f64 (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<= sub-neg_binary64 (-.f64 (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-rr63.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 8.5 \cdot 10^{-269}:\\ \;\;\;\;\frac{c \cdot -2}{b - \mathsf{hypot}\left(b, \sqrt{\left|a \cdot \left(c \cdot -4\right)\right|}\right)}\\ \mathbf{elif}\;b \leq 2.3 \cdot 10^{+152}:\\ \;\;\;\;-\frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{c \cdot -4}, b\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Error21.1
Cost20232
\[\begin{array}{l} \mathbf{if}\;b \leq 2 \cdot 10^{-265}:\\ \;\;\;\;\frac{c \cdot -2}{b - \mathsf{hypot}\left(b, {\left(a \cdot \left(c \cdot -4\right)\right)}^{0.5}\right)}\\ \mathbf{elif}\;b \leq 2.3 \cdot 10^{+152}:\\ \;\;\;\;-\frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{c \cdot -4}, b\right)\right)\\ \end{array} \]
Alternative 2
Error29.2
Cost13832
\[\begin{array}{l} t_0 := \frac{-0.5}{\frac{a}{b + \mathsf{hypot}\left(b, \sqrt{-4 \cdot \left(c \cdot a\right)}\right)}}\\ \mathbf{if}\;b \leq 10^{-99}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 2.3 \cdot 10^{+152}:\\ \;\;\;\;-\frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error29.2
Cost13832
\[\begin{array}{l} t_0 := b + \mathsf{hypot}\left(b, \sqrt{-4 \cdot \left(c \cdot a\right)}\right)\\ \mathbf{if}\;b \leq 10^{-99}:\\ \;\;\;\;\frac{-0.5}{\frac{a}{t_0}}\\ \mathbf{elif}\;b \leq 2.3 \cdot 10^{+152}:\\ \;\;\;\;-\frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{-2 \cdot a}\\ \end{array} \]
Alternative 4
Error20.0
Cost13832
\[\begin{array}{l} \mathbf{if}\;b \leq 6.8 \cdot 10^{-269}:\\ \;\;\;\;\frac{c \cdot -2}{b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)}\\ \mathbf{elif}\;b \leq 2.3 \cdot 10^{+152}:\\ \;\;\;\;-\frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + \mathsf{hypot}\left(b, \sqrt{-4 \cdot \left(c \cdot a\right)}\right)}{-2 \cdot a}\\ \end{array} \]
Alternative 5
Error20.0
Cost13832
\[\begin{array}{l} \mathbf{if}\;b \leq 3.4 \cdot 10^{-272}:\\ \;\;\;\;\frac{c \cdot -2}{b - \mathsf{hypot}\left(b, {\left(a \cdot \left(c \cdot -4\right)\right)}^{0.5}\right)}\\ \mathbf{elif}\;b \leq 2.3 \cdot 10^{+152}:\\ \;\;\;\;-\frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + \mathsf{hypot}\left(b, \sqrt{-4 \cdot \left(c \cdot a\right)}\right)}{-2 \cdot a}\\ \end{array} \]
Alternative 6
Error34.7
Cost7424
\[-\frac{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2} \]
Alternative 7
Error34.7
Cost7360
\[\frac{-0.5}{a} \cdot \left(b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right) \]

Error

Reproduce

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

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

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