Average Error: 34.4 → 6.3
Time: 8.9s
Precision: binary64
\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.3907884444731015 \cdot 10^{+134}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq -2.45851834527593 \cdot 10^{-281}:\\ \;\;\;\;c \cdot \frac{1}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\ \mathbf{elif}\;b_2 \leq 6.79328400373391 \cdot 10^{+86}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\ \end{array}\]
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.3907884444731015 \cdot 10^{+134}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \leq -2.45851834527593 \cdot 10^{-281}:\\
\;\;\;\;c \cdot \frac{1}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\

\mathbf{elif}\;b_2 \leq 6.79328400373391 \cdot 10^{+86}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\

\end{array}
(FPCore (a b_2 c)
 :precision binary64
 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -1.3907884444731015e+134)
   (* -0.5 (/ c b_2))
   (if (<= b_2 -2.45851834527593e-281)
     (* c (/ 1.0 (- (sqrt (- (* b_2 b_2) (* c a))) b_2)))
     (if (<= b_2 6.79328400373391e+86)
       (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
       (+ (* -2.0 (/ b_2 a)) (* (/ c b_2) 0.5))))))
double code(double a, double b_2, double c) {
	return (-b_2 - sqrt((b_2 * b_2) - (a * c))) / a;
}
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -1.3907884444731015e+134) {
		tmp = -0.5 * (c / b_2);
	} else if (b_2 <= -2.45851834527593e-281) {
		tmp = c * (1.0 / (sqrt((b_2 * b_2) - (c * a)) - b_2));
	} else if (b_2 <= 6.79328400373391e+86) {
		tmp = (-b_2 - sqrt((b_2 * b_2) - (c * a))) / a;
	} else {
		tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -1.39078844447310152e134

    1. Initial program 62.3

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around -inf 1.5

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}}\]

    if -1.39078844447310152e134 < b_2 < -2.45851834527592995e-281

    1. Initial program 34.5

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied clear-num_binary6434.5

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    4. Using strategy rm
    5. Applied flip--_binary6434.6

      \[\leadsto \frac{1}{\frac{a}{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}\]
    6. Applied associate-/r/_binary6434.6

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    7. Applied add-sqr-sqrt_binary6434.6

      \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\frac{a}{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}\]
    8. Applied times-frac_binary6434.6

      \[\leadsto \color{blue}{\frac{\sqrt{1}}{\frac{a}{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}} \cdot \frac{\sqrt{1}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    9. Simplified14.0

      \[\leadsto \color{blue}{\frac{a \cdot c}{a}} \cdot \frac{\sqrt{1}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\]
    10. Simplified14.0

      \[\leadsto \frac{a \cdot c}{a} \cdot \color{blue}{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    11. Taylor expanded around 0 7.7

      \[\leadsto \color{blue}{c} \cdot \frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\]

    if -2.45851834527592995e-281 < b_2 < 6.7932840037339095e86

    1. Initial program 9.5

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]

    if 6.7932840037339095e86 < b_2

    1. Initial program 43.8

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around inf 3.8

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]
    3. Simplified3.8

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.3907884444731015 \cdot 10^{+134}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq -2.45851834527593 \cdot 10^{-281}:\\ \;\;\;\;c \cdot \frac{1}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\ \mathbf{elif}\;b_2 \leq 6.79328400373391 \cdot 10^{+86}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\ \end{array}\]

Reproduce

herbie shell --seed 2021045 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))