Average Error: 33.6 → 8.1
Time: 15.4s
Precision: binary64
Cost: 13960
\[\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 -4.4 \cdot 10^{+34}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \leq 3.9 \cdot 10^{-286}:\\ \;\;\;\;\frac{\frac{c}{-0.25}}{b - \mathsf{hypot}\left(\sqrt{c \cdot \left(-4 \cdot a\right)}, b\right)} \cdot 0.5\\ \mathbf{elif}\;b \leq 10^{+134}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{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
 (if (<= b -4.4e+34)
   (/ (- c) b)
   (if (<= b 3.9e-286)
     (* (/ (/ c -0.25) (- b (hypot (sqrt (* c (* -4.0 a))) b))) 0.5)
     (if (<= b 1e+134)
       (/ (- (- b) (sqrt (+ (* b b) (* -4.0 (* c a))))) (* a 2.0))
       (/ (- b) 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 tmp;
	if (b <= -4.4e+34) {
		tmp = -c / b;
	} else if (b <= 3.9e-286) {
		tmp = ((c / -0.25) / (b - hypot(sqrt((c * (-4.0 * a))), b))) * 0.5;
	} else if (b <= 1e+134) {
		tmp = (-b - sqrt(((b * b) + (-4.0 * (c * a))))) / (a * 2.0);
	} else {
		tmp = -b / 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 tmp;
	if (b <= -4.4e+34) {
		tmp = -c / b;
	} else if (b <= 3.9e-286) {
		tmp = ((c / -0.25) / (b - Math.hypot(Math.sqrt((c * (-4.0 * a))), b))) * 0.5;
	} else if (b <= 1e+134) {
		tmp = (-b - Math.sqrt(((b * b) + (-4.0 * (c * a))))) / (a * 2.0);
	} else {
		tmp = -b / 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):
	tmp = 0
	if b <= -4.4e+34:
		tmp = -c / b
	elif b <= 3.9e-286:
		tmp = ((c / -0.25) / (b - math.hypot(math.sqrt((c * (-4.0 * a))), b))) * 0.5
	elif b <= 1e+134:
		tmp = (-b - math.sqrt(((b * b) + (-4.0 * (c * a))))) / (a * 2.0)
	else:
		tmp = -b / a
	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 <= -4.4e+34)
		tmp = Float64(Float64(-c) / b);
	elseif (b <= 3.9e-286)
		tmp = Float64(Float64(Float64(c / -0.25) / Float64(b - hypot(sqrt(Float64(c * Float64(-4.0 * a))), b))) * 0.5);
	elseif (b <= 1e+134)
		tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) + Float64(-4.0 * Float64(c * a))))) / Float64(a * 2.0));
	else
		tmp = Float64(Float64(-b) / 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)
	tmp = 0.0;
	if (b <= -4.4e+34)
		tmp = -c / b;
	elseif (b <= 3.9e-286)
		tmp = ((c / -0.25) / (b - hypot(sqrt((c * (-4.0 * a))), b))) * 0.5;
	elseif (b <= 1e+134)
		tmp = (-b - sqrt(((b * b) + (-4.0 * (c * a))))) / (a * 2.0);
	else
		tmp = -b / a;
	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, -4.4e+34], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 3.9e-286], N[(N[(N[(c / -0.25), $MachinePrecision] / N[(b - N[Sqrt[N[Sqrt[N[(c * N[(-4.0 * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2 + b ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[b, 1e+134], 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[((-b) / a), $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 -4.4 \cdot 10^{+34}:\\
\;\;\;\;\frac{-c}{b}\\

\mathbf{elif}\;b \leq 3.9 \cdot 10^{-286}:\\
\;\;\;\;\frac{\frac{c}{-0.25}}{b - \mathsf{hypot}\left(\sqrt{c \cdot \left(-4 \cdot a\right)}, b\right)} \cdot 0.5\\

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

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original33.6
Target20.6
Herbie8.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 4 regimes
  2. if b < -4.4000000000000005e34

    1. Initial program 56.7

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
      Proof
      (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 a 2)): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (Rewrite<= associate-*r*_binary64 (*.f64 4 (*.f64 a c)))))) (*.f64 a 2)): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 4 (*.f64 a c))))) (Rewrite<= *-commutative_binary64 (*.f64 2 a))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in b around -inf 4.3

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    4. Simplified4.3

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
      Proof
      (/.f64 (neg.f64 c) b): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite=> neg-mul-1_binary64 (*.f64 -1 c)) b): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*r/_binary64 (*.f64 -1 (/.f64 c b))): 0 points increase in error, 0 points decrease in error

    if -4.4000000000000005e34 < b < 3.89999999999999995e-286

    1. Initial program 26.7

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

      \[\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))): 8 points increase in error, 24 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-rr29.7

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

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

      \[\leadsto \color{blue}{\frac{a \cdot \left(c \cdot -4\right) + 0}{a \cdot \left(\mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right) - b\right)} \cdot -0.5} \]
      Proof
      (*.f64 (/.f64 (+.f64 (*.f64 a (*.f64 c -4)) 0) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (+.f64 (*.f64 a (Rewrite=> *-commutative_binary64 (*.f64 -4 c))) 0) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (+.f64 (*.f64 a (*.f64 (Rewrite<= rem-square-sqrt_binary64 (*.f64 (sqrt.f64 -4) (sqrt.f64 -4))) c)) 0) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 129 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (+.f64 (*.f64 a (*.f64 (Rewrite<= unpow2_binary64 (pow.f64 (sqrt.f64 -4) 2)) c)) 0) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (+.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 a (pow.f64 (sqrt.f64 -4) 2)) c)) 0) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (+.f64 (*.f64 (*.f64 a (Rewrite=> unpow2_binary64 (*.f64 (sqrt.f64 -4) (sqrt.f64 -4)))) c) 0) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (+.f64 (*.f64 (*.f64 a (Rewrite=> rem-square-sqrt_binary64 -4)) c) 0) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 0 points increase in error, 129 points decrease in error
      (*.f64 (/.f64 (+.f64 (*.f64 (Rewrite<= *-commutative_binary64 (*.f64 -4 a)) c) 0) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (+.f64 (*.f64 (*.f64 -4 a) c) (Rewrite<= +-inverses_binary64 (-.f64 (*.f64 b b) (*.f64 b b)))) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 24 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (*.f64 (*.f64 -4 a) c) (*.f64 b b)) (*.f64 b b))) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 19 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (-.f64 (Rewrite<= fma-udef_binary64 (fma.f64 (*.f64 -4 a) c (*.f64 b b))) (*.f64 b b)) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (Rewrite=> sub-neg_binary64 (+.f64 (fma.f64 (*.f64 -4 a) c (*.f64 b b)) (neg.f64 (*.f64 b b)))) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (Rewrite=> +-commutative_binary64 (+.f64 (neg.f64 (*.f64 b b)) (fma.f64 (*.f64 -4 a) c (*.f64 b b)))) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 (*.f64 b b))) (fma.f64 (*.f64 -4 a) c (*.f64 b b))) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (Rewrite<= associate--r-_binary64 (-.f64 0 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b))))) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b))))) (*.f64 a (-.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) b))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b)))) (*.f64 a (Rewrite=> sub-neg_binary64 (+.f64 (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))) (neg.f64 b))))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b)))) (*.f64 a (Rewrite=> +-commutative_binary64 (+.f64 (neg.f64 b) (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))))))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b)))) (*.f64 a (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 b)) (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b)))) (*.f64 a (Rewrite<= associate--r-_binary64 (-.f64 0 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b)))) (*.f64 a (Rewrite<= neg-sub0_binary64 (neg.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= associate-/l/_binary64 (/.f64 (/.f64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b)))) (neg.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))) a)) -1/2): 11 points increase in error, 36 points decrease in error
      (*.f64 (/.f64 (/.f64 (neg.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b)))) (Rewrite=> neg-mul-1_binary64 (*.f64 -1 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))))))) a) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (/.f64 (Rewrite=> neg-mul-1_binary64 (*.f64 -1 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b))))) (*.f64 -1 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))) a) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (Rewrite=> times-frac_binary64 (*.f64 (/.f64 -1 -1) (/.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b))) (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))))))) a) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (*.f64 (Rewrite=> metadata-eval 1) (/.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b))) (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))) a) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (Rewrite=> *-lft-identity_binary64 (/.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b))) (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))))) a) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite=> associate-/l/_binary64 (/.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b))) (*.f64 a (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4)))))))) -1/2): 36 points increase in error, 11 points decrease in error
      (*.f64 (/.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b))) (Rewrite<= *-commutative_binary64 (*.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) a))) -1/2): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b))) (*.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) a)) (Rewrite<= metadata-eval (/.f64 1 -2))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= times-frac_binary64 (/.f64 (*.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b))) 1) (*.f64 (*.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) a) -2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (*.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b))) 1) (Rewrite<= associate-*r*_binary64 (*.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) (*.f64 a -2)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite=> *-rgt-identity_binary64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b)))) (*.f64 (-.f64 b (hypot.f64 b (sqrt.f64 (*.f64 a (*.f64 c -4))))) (*.f64 a -2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (*.f64 b b) (fma.f64 (*.f64 -4 a) c (*.f64 b b))) (Rewrite=> *-commutative_binary64 (*.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
    6. Applied egg-rr29.7

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

      \[\leadsto \color{blue}{\frac{-\frac{c}{-0.25}}{b - \mathsf{hypot}\left(\sqrt{c \cdot \left(-4 \cdot a\right)}, b\right)}} \cdot -0.5 \]
      Proof
      (/.f64 (neg.f64 (/.f64 c -1/4)) (-.f64 b (hypot.f64 (sqrt.f64 (*.f64 c (*.f64 -4 a))) b))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (/.f64 c (Rewrite<= metadata-eval (/.f64 1 -4)))) (-.f64 b (hypot.f64 (sqrt.f64 (*.f64 c (*.f64 -4 a))) b))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 c -4) 1))) (-.f64 b (hypot.f64 (sqrt.f64 (*.f64 c (*.f64 -4 a))) b))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (/.f64 (*.f64 c -4) (Rewrite<= *-inverses_binary64 (/.f64 a a)))) (-.f64 b (hypot.f64 (sqrt.f64 (*.f64 c (*.f64 -4 a))) b))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (Rewrite=> associate-/r/_binary64 (*.f64 (/.f64 (*.f64 c -4) a) a))) (-.f64 b (hypot.f64 (sqrt.f64 (*.f64 c (*.f64 -4 a))) b))): 17 points increase in error, 18 points decrease in error
      (/.f64 (neg.f64 (Rewrite=> *-commutative_binary64 (*.f64 a (/.f64 (*.f64 c -4) a)))) (-.f64 b (hypot.f64 (sqrt.f64 (*.f64 c (*.f64 -4 a))) b))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 a (*.f64 c -4)) a))) (-.f64 b (hypot.f64 (sqrt.f64 (*.f64 c (*.f64 -4 a))) b))): 43 points increase in error, 28 points decrease in error
      (/.f64 (neg.f64 (/.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 a c) -4)) a)) (-.f64 b (hypot.f64 (sqrt.f64 (*.f64 c (*.f64 -4 a))) b))): 1 points increase in error, 1 points decrease in error
      (/.f64 (neg.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 -4 (*.f64 a c))) a)) (-.f64 b (hypot.f64 (sqrt.f64 (*.f64 c (*.f64 -4 a))) b))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (/.f64 (*.f64 -4 (*.f64 a c)) a)) (-.f64 (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 b))) (hypot.f64 (sqrt.f64 (*.f64 c (*.f64 -4 a))) b))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (/.f64 (*.f64 -4 (*.f64 a c)) a)) (-.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 (neg.f64 b))) (hypot.f64 (sqrt.f64 (*.f64 c (*.f64 -4 a))) b))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (/.f64 (*.f64 -4 (*.f64 a c)) a)) (-.f64 (-.f64 0 (neg.f64 b)) (hypot.f64 (sqrt.f64 (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 -4 a) c))) b))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (/.f64 (*.f64 -4 (*.f64 a c)) a)) (-.f64 (-.f64 0 (neg.f64 b)) (hypot.f64 (sqrt.f64 (Rewrite<= associate-*r*_binary64 (*.f64 -4 (*.f64 a c)))) b))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (/.f64 (*.f64 -4 (*.f64 a c)) a)) (Rewrite<= associate--r+_binary64 (-.f64 0 (+.f64 (neg.f64 b) (hypot.f64 (sqrt.f64 (*.f64 -4 (*.f64 a c))) b))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (/.f64 (*.f64 -4 (*.f64 a c)) a)) (-.f64 0 (Rewrite=> +-commutative_binary64 (+.f64 (hypot.f64 (sqrt.f64 (*.f64 -4 (*.f64 a c))) b) (neg.f64 b))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (/.f64 (*.f64 -4 (*.f64 a c)) a)) (-.f64 0 (Rewrite=> unsub-neg_binary64 (-.f64 (hypot.f64 (sqrt.f64 (*.f64 -4 (*.f64 a c))) b) b)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (/.f64 (*.f64 -4 (*.f64 a c)) a)) (Rewrite<= neg-sub0_binary64 (neg.f64 (-.f64 (hypot.f64 (sqrt.f64 (*.f64 -4 (*.f64 a c))) b) b)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 (/.f64 (*.f64 -4 (*.f64 a c)) a) (neg.f64 (-.f64 (hypot.f64 (sqrt.f64 (*.f64 -4 (*.f64 a c))) b) b))))): 0 points increase in error, 0 points decrease in error
      (neg.f64 (Rewrite<= associate-/r*_binary64 (/.f64 (*.f64 -4 (*.f64 a c)) (*.f64 a (neg.f64 (-.f64 (hypot.f64 (sqrt.f64 (*.f64 -4 (*.f64 a c))) b) b)))))): 22 points increase in error, 36 points decrease in error
      (Rewrite=> distribute-neg-frac_binary64 (/.f64 (neg.f64 (*.f64 -4 (*.f64 a c))) (*.f64 a (neg.f64 (-.f64 (hypot.f64 (sqrt.f64 (*.f64 -4 (*.f64 a c))) b) b))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (neg.f64 (Rewrite=> *-commutative_binary64 (*.f64 (*.f64 a c) -4))) (*.f64 a (neg.f64 (-.f64 (hypot.f64 (sqrt.f64 (*.f64 -4 (*.f64 a c))) b) b)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite=> distribute-rgt-neg-in_binary64 (*.f64 (*.f64 a c) (neg.f64 -4))) (*.f64 a (neg.f64 (-.f64 (hypot.f64 (sqrt.f64 (*.f64 -4 (*.f64 a c))) b) b)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (*.f64 (*.f64 a c) (Rewrite=> metadata-eval 4)) (*.f64 a (neg.f64 (-.f64 (hypot.f64 (sqrt.f64 (*.f64 -4 (*.f64 a c))) b) b)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= *-rgt-identity_binary64 (*.f64 (*.f64 (*.f64 a c) 4) 1)) (*.f64 a (neg.f64 (-.f64 (hypot.f64 (sqrt.f64 (*.f64 -4 (*.f64 a c))) b) b)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*r/_binary64 (*.f64 (*.f64 (*.f64 a c) 4) (/.f64 1 (*.f64 a (neg.f64 (-.f64 (hypot.f64 (sqrt.f64 (*.f64 -4 (*.f64 a c))) b) b)))))): 16 points increase in error, 10 points decrease in error

    if 3.89999999999999995e-286 < b < 9.99999999999999921e133

    1. Initial program 8.4

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

    if 9.99999999999999921e133 < b

    1. Initial program 56.7

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

      \[\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))): 8 points increase in error, 24 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. Taylor expanded in a around 0 3.0

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}} \]
    4. Simplified3.0

      \[\leadsto \color{blue}{\frac{-b}{a}} \]
      Proof
      (/.f64 (neg.f64 b) a): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 b)) a): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*r/_binary64 (*.f64 -1 (/.f64 b a))): 0 points increase in error, 0 points decrease in error
  3. Recombined 4 regimes into one program.
  4. Final simplification8.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.4 \cdot 10^{+34}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \leq 3.9 \cdot 10^{-286}:\\ \;\;\;\;\frac{\frac{c}{-0.25}}{b - \mathsf{hypot}\left(\sqrt{c \cdot \left(-4 \cdot a\right)}, b\right)} \cdot 0.5\\ \mathbf{elif}\;b \leq 10^{+134}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]

Alternatives

Alternative 1
Error8.2
Cost13960
\[\begin{array}{l} \mathbf{if}\;b \leq -3 \cdot 10^{+34}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \leq 8 \cdot 10^{-300}:\\ \;\;\;\;-0.5 \cdot \frac{-4}{\frac{\mathsf{hypot}\left(\sqrt{c \cdot \left(-4 \cdot a\right)}, b\right) - b}{c}}\\ \mathbf{elif}\;b \leq 1.7 \cdot 10^{+124}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]
Alternative 2
Error9.9
Cost7688
\[\begin{array}{l} \mathbf{if}\;b \leq -2.2 \cdot 10^{-33}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \leq 10^{+122}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]
Alternative 3
Error13.3
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -2.5 \cdot 10^{-33}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \leq 3 \cdot 10^{-42}:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{c \cdot \left(-4 \cdot a\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 4
Error13.3
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -1.55 \cdot 10^{-33}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \leq 1.4 \cdot 10^{-44}:\\ \;\;\;\;\frac{b + \sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 5
Error39.4
Cost388
\[\begin{array}{l} \mathbf{if}\;b \leq -1.45 \cdot 10^{+23}:\\ \;\;\;\;\frac{c}{b}\\ \mathbf{else}:\\ \;\;\;\;-\frac{b}{a}\\ \end{array} \]
Alternative 6
Error22.8
Cost388
\[\begin{array}{l} \mathbf{if}\;b \leq -3.8 \cdot 10^{-235}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;-\frac{b}{a}\\ \end{array} \]
Alternative 7
Error62.3
Cost192
\[\frac{b}{a} \]
Alternative 8
Error56.6
Cost192
\[\frac{c}{b} \]

Error

Reproduce

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