Average Error: 31.0 → 8.0
Time: 13.1s
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.96537383651797 \cdot 10^{+82}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq -1.148291726482369 \cdot 10^{-308}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}\\ \mathbf{elif}\;b_2 \leq 2.4756347151901527 \cdot 10^{+129}:\\ \;\;\;\;\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.96537383651797 \cdot 10^{+82}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \leq -1.148291726482369 \cdot 10^{-308}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}\\

\mathbf{elif}\;b_2 \leq 2.4756347151901527 \cdot 10^{+129}:\\
\;\;\;\;\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.96537383651797e+82)
   (* -0.5 (/ c b_2))
   (if (<= b_2 -1.148291726482369e-308)
     (/ c (- (hypot (sqrt (- (* c a))) b_2) b_2))
     (if (<= b_2 2.4756347151901527e+129)
       (/ (- (- 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.96537383651797e+82) {
		tmp = -0.5 * (c / b_2);
	} else if (b_2 <= -1.148291726482369e-308) {
		tmp = c / (hypot(sqrt(-(c * a)), b_2) - b_2);
	} else if (b_2 <= 2.4756347151901527e+129) {
		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 4 regimes
  2. if b_2 < -1.96537383651796996e82

    1. Initial program 57.8

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

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

    if -1.96537383651796996e82 < b_2 < -1.148291726482369e-308

    1. Initial program 31.3

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Applied flip--_binary6431.5

      \[\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} \]
    3. Simplified15.0

      \[\leadsto \frac{\frac{\color{blue}{c \cdot a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a} \]
    4. Simplified24.5

      \[\leadsto \frac{\frac{c \cdot a}{\color{blue}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}}}{a} \]
    5. Applied *-un-lft-identity_binary6424.5

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

      \[\leadsto \frac{\color{blue}{\frac{c}{1} \cdot \frac{a}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}}}{a} \]
    7. Applied associate-/l*_binary6417.1

      \[\leadsto \color{blue}{\frac{\frac{c}{1}}{\frac{a}{\frac{a}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}}}} \]
    8. Simplified16.5

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

    if -1.148291726482369e-308 < b_2 < 2.475634715190153e129

    1. Initial program 8.3

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

    if 2.475634715190153e129 < b_2

    1. Initial program 33.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.96537383651797 \cdot 10^{+82}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq -1.148291726482369 \cdot 10^{-308}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}\\ \mathbf{elif}\;b_2 \leq 2.4756347151901527 \cdot 10^{+129}:\\ \;\;\;\;\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 2022068 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))