Average Error: 33.9 → 10.1
Time: 10.5s
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.9663641729603736 \cdot 10^{-44}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 8.279245329538253 \cdot 10^{+124}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \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.9663641729603736 \cdot 10^{-44}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

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

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


\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.9663641729603736e-44)
   (* -0.5 (/ c b_2))
   (if (<= b_2 8.279245329538253e+124)
     (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
     (/ (* b_2 -2.0) a))))
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.9663641729603736e-44) {
		tmp = -0.5 * (c / b_2);
	} else if (b_2 <= 8.279245329538253e+124) {
		tmp = (-b_2 - sqrt((b_2 * b_2) - (c * a))) / a;
	} else {
		tmp = (b_2 * -2.0) / a;
	}
	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 3 regimes
  2. if b_2 < -1.9663641729603736e-44

    1. Initial program 54.4

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

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

    if -1.9663641729603736e-44 < b_2 < 8.279245329538253e124

    1. Initial program 13.7

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

    if 8.279245329538253e124 < b_2

    1. Initial program 53.7

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Applied *-un-lft-identity_binary6453.7

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{\color{blue}{1 \cdot a}} \]
    3. Applied associate-/r*_binary6453.7

      \[\leadsto \color{blue}{\frac{\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{1}}{a}} \]
    4. Simplified38.3

      \[\leadsto \frac{\color{blue}{\left(-b_2\right) - \mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right)}}{a} \]
    5. Applied add-cube-cbrt_binary6438.3

      \[\leadsto \frac{\left(-b_2\right) - \mathsf{hypot}\left(\sqrt{\color{blue}{\left(\sqrt[3]{-c \cdot a} \cdot \sqrt[3]{-c \cdot a}\right) \cdot \sqrt[3]{-c \cdot a}}}, b_2\right)}{a} \]
    6. Applied sqrt-prod_binary6438.3

      \[\leadsto \frac{\left(-b_2\right) - \mathsf{hypot}\left(\color{blue}{\sqrt{\sqrt[3]{-c \cdot a} \cdot \sqrt[3]{-c \cdot a}} \cdot \sqrt{\sqrt[3]{-c \cdot a}}}, b_2\right)}{a} \]
    7. Simplified38.3

      \[\leadsto \frac{\left(-b_2\right) - \mathsf{hypot}\left(\color{blue}{\left|\sqrt[3]{-c \cdot a}\right|} \cdot \sqrt{\sqrt[3]{-c \cdot a}}, b_2\right)}{a} \]
    8. Taylor expanded in b_2 around inf 3.1

      \[\leadsto \frac{\color{blue}{-2 \cdot b_2}}{a} \]
    9. Simplified3.1

      \[\leadsto \frac{\color{blue}{b_2 \cdot -2}}{a} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.9663641729603736 \cdot 10^{-44}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 8.279245329538253 \cdot 10^{+124}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \]

Reproduce

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