?

Average Error: 33.8 → 8.3
Time: 20.4s
Precision: binary64
Cost: 14096

?

\[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]
\[\begin{array}{l} t_0 := \frac{-c}{b}\\ t_1 := 2 \cdot \frac{c}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right) - b}\\ \mathbf{if}\;b \leq -8.5 \cdot 10^{+55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq -7.5 \cdot 10^{+27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -1 \cdot 10^{-20}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 3.2 \cdot 10^{-261}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 2.25 \cdot 10^{+65}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \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
 (let* ((t_0 (/ (- c) b))
        (t_1 (* 2.0 (/ c (- (hypot b (sqrt (* c (* a -4.0)))) b)))))
   (if (<= b -8.5e+55)
     t_0
     (if (<= b -7.5e+27)
       t_1
       (if (<= b -1e-20)
         t_0
         (if (<= b 3.2e-261)
           t_1
           (if (<= b 2.25e+65)
             (/ (- (- b) (sqrt (+ (* b b) (* -4.0 (* c a))))) (* 2.0 a))
             (- (/ c b) (/ 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 t_0 = -c / b;
	double t_1 = 2.0 * (c / (hypot(b, sqrt((c * (a * -4.0)))) - b));
	double tmp;
	if (b <= -8.5e+55) {
		tmp = t_0;
	} else if (b <= -7.5e+27) {
		tmp = t_1;
	} else if (b <= -1e-20) {
		tmp = t_0;
	} else if (b <= 3.2e-261) {
		tmp = t_1;
	} else if (b <= 2.25e+65) {
		tmp = (-b - sqrt(((b * b) + (-4.0 * (c * a))))) / (2.0 * a);
	} else {
		tmp = (c / b) - (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 t_0 = -c / b;
	double t_1 = 2.0 * (c / (Math.hypot(b, Math.sqrt((c * (a * -4.0)))) - b));
	double tmp;
	if (b <= -8.5e+55) {
		tmp = t_0;
	} else if (b <= -7.5e+27) {
		tmp = t_1;
	} else if (b <= -1e-20) {
		tmp = t_0;
	} else if (b <= 3.2e-261) {
		tmp = t_1;
	} else if (b <= 2.25e+65) {
		tmp = (-b - Math.sqrt(((b * b) + (-4.0 * (c * a))))) / (2.0 * a);
	} else {
		tmp = (c / b) - (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):
	t_0 = -c / b
	t_1 = 2.0 * (c / (math.hypot(b, math.sqrt((c * (a * -4.0)))) - b))
	tmp = 0
	if b <= -8.5e+55:
		tmp = t_0
	elif b <= -7.5e+27:
		tmp = t_1
	elif b <= -1e-20:
		tmp = t_0
	elif b <= 3.2e-261:
		tmp = t_1
	elif b <= 2.25e+65:
		tmp = (-b - math.sqrt(((b * b) + (-4.0 * (c * a))))) / (2.0 * a)
	else:
		tmp = (c / b) - (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)
	t_0 = Float64(Float64(-c) / b)
	t_1 = Float64(2.0 * Float64(c / Float64(hypot(b, sqrt(Float64(c * Float64(a * -4.0)))) - b)))
	tmp = 0.0
	if (b <= -8.5e+55)
		tmp = t_0;
	elseif (b <= -7.5e+27)
		tmp = t_1;
	elseif (b <= -1e-20)
		tmp = t_0;
	elseif (b <= 3.2e-261)
		tmp = t_1;
	elseif (b <= 2.25e+65)
		tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) + Float64(-4.0 * Float64(c * a))))) / Float64(2.0 * a));
	else
		tmp = Float64(Float64(c / b) - 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)
	t_0 = -c / b;
	t_1 = 2.0 * (c / (hypot(b, sqrt((c * (a * -4.0)))) - b));
	tmp = 0.0;
	if (b <= -8.5e+55)
		tmp = t_0;
	elseif (b <= -7.5e+27)
		tmp = t_1;
	elseif (b <= -1e-20)
		tmp = t_0;
	elseif (b <= 3.2e-261)
		tmp = t_1;
	elseif (b <= 2.25e+65)
		tmp = (-b - sqrt(((b * b) + (-4.0 * (c * a))))) / (2.0 * a);
	else
		tmp = (c / b) - (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_] := Block[{t$95$0 = N[((-c) / b), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(c / N[(N[Sqrt[b ^ 2 + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -8.5e+55], t$95$0, If[LessEqual[b, -7.5e+27], t$95$1, If[LessEqual[b, -1e-20], t$95$0, If[LessEqual[b, 3.2e-261], t$95$1, If[LessEqual[b, 2.25e+65], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $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 := \frac{-c}{b}\\
t_1 := 2 \cdot \frac{c}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right) - b}\\
\mathbf{if}\;b \leq -8.5 \cdot 10^{+55}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;b \leq -7.5 \cdot 10^{+27}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;b \leq -1 \cdot 10^{-20}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;b \leq 3.2 \cdot 10^{-261}:\\
\;\;\;\;t_1\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original33.8
Target21.0
Herbie8.3
\[\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 < -8.50000000000000002e55 or -7.5000000000000002e27 < b < -9.99999999999999945e-21

    1. Initial program 56.0

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

      \[\leadsto \color{blue}{\left(b + \sqrt{\mathsf{fma}\left(b, b, \frac{a \cdot c}{-0.25}\right)}\right) \cdot \frac{-0.5}{a}} \]
      Proof

      [Start]56.0

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

      *-rgt-identity [<=]56.0

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

      metadata-eval [<=]56.0

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

      associate-*l/ [=>]56.0

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

      associate-*r/ [<=]56.0

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

      distribute-neg-frac [<=]56.0

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

      distribute-rgt-neg-in [<=]56.0

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

      distribute-lft-neg-out [<=]56.0

      \[ \color{blue}{\left(-\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right) \cdot \frac{-1}{2 \cdot a}} \]
    3. Taylor expanded in b around -inf 5.7

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

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
      Proof

      [Start]5.7

      \[ -1 \cdot \frac{c}{b} \]

      mul-1-neg [=>]5.7

      \[ \color{blue}{-\frac{c}{b}} \]

      distribute-neg-frac [=>]5.7

      \[ \color{blue}{\frac{-c}{b}} \]

    if -8.50000000000000002e55 < b < -7.5000000000000002e27 or -9.99999999999999945e-21 < b < 3.20000000000000004e-261

    1. Initial program 24.8

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

      \[\leadsto \color{blue}{\left(b + \sqrt{\mathsf{fma}\left(b, b, \frac{a \cdot c}{-0.25}\right)}\right) \cdot \frac{-0.5}{a}} \]
      Proof

      [Start]24.8

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

      *-rgt-identity [<=]24.8

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

      metadata-eval [<=]24.8

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

      associate-*l/ [=>]24.8

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

      associate-*r/ [<=]24.8

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

      distribute-neg-frac [<=]24.8

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

      distribute-rgt-neg-in [<=]24.8

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

      distribute-lft-neg-out [<=]24.8

      \[ \color{blue}{\left(-\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right) \cdot \frac{-1}{2 \cdot a}} \]
    3. Applied egg-rr31.2

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

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

      [Start]31.2

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

      fma-def [<=]31.2

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

      +-commutative [=>]31.2

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

      fma-def [=>]31.2

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

      *-commutative [=>]31.2

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

      associate-*r* [=>]31.2

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

      *-commutative [<=]31.2

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

      associate-*l* [=>]31.2

      \[ \frac{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right) - b \cdot b}{\left(\mathsf{hypot}\left(b, \sqrt{\color{blue}{c \cdot \left(a \cdot -4\right)}}\right) - b\right) \cdot \left(a \cdot -2\right)} \]
    5. Taylor expanded in a around 0 27.1

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

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

      [Start]27.1

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

      associate-*r* [=>]27.1

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

      *-commutative [<=]27.1

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

      *-commutative [<=]27.1

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

      *-commutative [=>]27.1

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{a \cdot \left(2 \cdot \frac{c}{a}\right)}{\mathsf{hypot}\left(b, \sqrt{a \cdot \left(-4 \cdot c\right)}\right) - b}\right)} - 1} \]
    8. Simplified13.8

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

      [Start]54.4

      \[ e^{\mathsf{log1p}\left(\frac{a \cdot \left(2 \cdot \frac{c}{a}\right)}{\mathsf{hypot}\left(b, \sqrt{a \cdot \left(-4 \cdot c\right)}\right) - b}\right)} - 1 \]

      expm1-def [=>]35.9

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

      expm1-log1p [=>]27.9

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

      *-commutative [=>]27.9

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

      associate-*r/ [<=]28.3

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

      associate-*l* [=>]28.3

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

      times-frac [<=]27.0

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

      *-commutative [=>]27.0

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

      times-frac [=>]13.8

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

      associate-*r/ [=>]13.8

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

      *-inverses [=>]13.8

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

      *-lft-identity [=>]13.8

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

      associate-*r* [=>]13.8

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

      *-commutative [=>]13.8

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

    if 3.20000000000000004e-261 < b < 2.25e65

    1. Initial program 8.5

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

    if 2.25e65 < b

    1. Initial program 41.3

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

      \[\leadsto \color{blue}{\left(b + \sqrt{\mathsf{fma}\left(b, b, \frac{a \cdot c}{-0.25}\right)}\right) \cdot \frac{-0.5}{a}} \]
      Proof

      [Start]41.3

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

      *-rgt-identity [<=]41.3

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

      metadata-eval [<=]41.3

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

      associate-*l/ [=>]41.3

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

      associate-*r/ [<=]41.4

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

      distribute-neg-frac [<=]41.4

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

      distribute-rgt-neg-in [<=]41.4

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

      distribute-lft-neg-out [<=]41.4

      \[ \color{blue}{\left(-\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right) \cdot \frac{-1}{2 \cdot a}} \]
    3. Taylor expanded in b around inf 4.9

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

      \[\leadsto \color{blue}{\frac{-b}{a} + \frac{c}{b}} \]
      Proof

      [Start]4.9

      \[ \frac{c}{b} + -1 \cdot \frac{b}{a} \]

      +-commutative [=>]4.9

      \[ \color{blue}{-1 \cdot \frac{b}{a} + \frac{c}{b}} \]

      associate-*r/ [=>]4.9

      \[ \color{blue}{\frac{-1 \cdot b}{a}} + \frac{c}{b} \]

      mul-1-neg [=>]4.9

      \[ \frac{\color{blue}{-b}}{a} + \frac{c}{b} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -8.5 \cdot 10^{+55}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \leq -7.5 \cdot 10^{+27}:\\ \;\;\;\;2 \cdot \frac{c}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right) - b}\\ \mathbf{elif}\;b \leq -1 \cdot 10^{-20}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \leq 3.2 \cdot 10^{-261}:\\ \;\;\;\;2 \cdot \frac{c}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right) - b}\\ \mathbf{elif}\;b \leq 2.25 \cdot 10^{+65}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]

Alternatives

Alternative 1
Error10.3
Cost7688
\[\begin{array}{l} \mathbf{if}\;b \leq -7 \cdot 10^{-88}:\\ \;\;\;\;\frac{-0.5}{0.5 \cdot \left(\frac{b}{c} - \frac{a}{b}\right)}\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{+65}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 2
Error10.3
Cost7624
\[\begin{array}{l} \mathbf{if}\;b \leq -7.5 \cdot 10^{-90}:\\ \;\;\;\;\frac{-0.5}{0.5 \cdot \left(\frac{b}{c} - \frac{a}{b}\right)}\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{+65}:\\ \;\;\;\;\left(b + \sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)}\right) \cdot \frac{-0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 3
Error13.9
Cost7432
\[\begin{array}{l} \mathbf{if}\;b \leq -3.2 \cdot 10^{-89}:\\ \;\;\;\;\frac{-0.5}{0.5 \cdot \left(\frac{b}{c} - \frac{a}{b}\right)}\\ \mathbf{elif}\;b \leq 1.6 \cdot 10^{-132}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 4
Error13.9
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -6.4 \cdot 10^{-83}:\\ \;\;\;\;\frac{-0.5}{0.5 \cdot \left(\frac{b}{c} - \frac{a}{b}\right)}\\ \mathbf{elif}\;b \leq 1.6 \cdot 10^{-132}:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{c \cdot \left(a \cdot -4\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 5
Error23.1
Cost836
\[\begin{array}{l} \mathbf{if}\;b \leq 2.2 \cdot 10^{-258}:\\ \;\;\;\;\frac{-0.5}{0.5 \cdot \left(\frac{b}{c} - \frac{a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 6
Error39.8
Cost388
\[\begin{array}{l} \mathbf{if}\;b \leq -29000000000000:\\ \;\;\;\;\frac{c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]
Alternative 7
Error23.1
Cost388
\[\begin{array}{l} \mathbf{if}\;b \leq -1.65 \cdot 10^{-228}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]
Alternative 8
Error62.3
Cost192
\[\frac{b}{a} \]
Alternative 9
Error56.7
Cost192
\[\frac{c}{b} \]

Error

Reproduce?

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