Average Error: 34.1 → 6.9
Time: 5.0s
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 -2.864560261090598 \cdot 10^{+142}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 3.0970905226445423 \cdot 10^{-144}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\ \mathbf{elif}\;b_2 \leq 1.6886076224176782 \cdot 10^{+105}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b_2\right) - \left(b_2 + -0.5 \cdot \left(c \cdot \frac{a}{b_2}\right)\right)}{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 -2.864560261090598 \cdot 10^{+142}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \leq 3.0970905226445423 \cdot 10^{-144}:\\
\;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\left(-b_2\right) - \left(b_2 + -0.5 \cdot \left(c \cdot \frac{a}{b_2}\right)\right)}{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 -2.864560261090598e+142)
   (* -0.5 (/ c b_2))
   (if (<= b_2 3.0970905226445423e-144)
     (/ c (- (sqrt (- (* b_2 b_2) (* c a))) b_2))
     (if (<= b_2 1.6886076224176782e+105)
       (/ 1.0 (/ a (- (- b_2) (sqrt (- (* b_2 b_2) (* c a))))))
       (/ (- (- b_2) (+ b_2 (* -0.5 (* c (/ a b_2))))) a)))))
double code(double a, double b_2, double c) {
	return (((double) (((double) -(b_2)) - ((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (a * c)))))))) / a);
}
double code(double a, double b_2, double c) {
	double tmp;
	if ((b_2 <= -2.864560261090598e+142)) {
		tmp = ((double) (-0.5 * (c / b_2)));
	} else {
		double tmp_1;
		if ((b_2 <= 3.0970905226445423e-144)) {
			tmp_1 = (c / ((double) (((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a)))))) - b_2)));
		} else {
			double tmp_2;
			if ((b_2 <= 1.6886076224176782e+105)) {
				tmp_2 = (1.0 / (a / ((double) (((double) -(b_2)) - ((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a))))))))));
			} else {
				tmp_2 = (((double) (((double) -(b_2)) - ((double) (b_2 + ((double) (-0.5 * ((double) (c * (a / b_2))))))))) / a);
			}
			tmp_1 = tmp_2;
		}
		tmp = tmp_1;
	}
	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 < -2.8645602610905979e142

    1. Initial program Error: 62.4 bits

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

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

    if -2.8645602610905979e142 < b_2 < 3.09709052264454234e-144

    1. Initial program Error: 30.9 bits

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--Error: 31.5 bits

      \[\leadsto \frac{\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}}}}{a}\]
    4. SimplifiedError: 16.6 bits

      \[\leadsto \frac{\frac{\color{blue}{a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. SimplifiedError: 16.6 bits

      \[\leadsto \frac{\frac{a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identityError: 16.6 bits

      \[\leadsto \frac{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied *-un-lft-identityError: 16.6 bits

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{1 \cdot a}\]
    9. Applied times-fracError: 16.6 bits

      \[\leadsto \color{blue}{\frac{1}{1} \cdot \frac{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}}\]
    10. SimplifiedError: 16.6 bits

      \[\leadsto \color{blue}{1} \cdot \frac{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}\]
    11. SimplifiedError: 10.4 bits

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

    if 3.09709052264454234e-144 < b_2 < 1.6886076224176782e105

    1. Initial program Error: 6.0 bits

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

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

    if 1.6886076224176782e105 < b_2

    1. Initial program Error: 48.1 bits

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

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{\left(b_2 - 0.5 \cdot \frac{a \cdot c}{b_2}\right)}}{a}\]
    3. SimplifiedError: 4.1 bits

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{\left(b_2 + \left(c \cdot \frac{a}{b_2}\right) \cdot -0.5\right)}}{a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplificationError: 6.9 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -2.864560261090598 \cdot 10^{+142}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 3.0970905226445423 \cdot 10^{-144}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\ \mathbf{elif}\;b_2 \leq 1.6886076224176782 \cdot 10^{+105}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b_2\right) - \left(b_2 + -0.5 \cdot \left(c \cdot \frac{a}{b_2}\right)\right)}{a}\\ \end{array}\]

Reproduce

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