Average Error: 28.3 → 16.6
Time: 5.6s
Precision: binary64
\[1.0536712127723509 \cdot 10^{-08} < a \land a < 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} < b \land b < 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} < c \land c < 94906265.62425156\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \leq 391.5762305688583:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) - b \cdot b}{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \leq 391.5762305688583:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) - b \cdot b}{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\

\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
 (if (<= b 391.5762305688583)
   (/
    (/
     (- (- (* b b) (* (* 4.0 a) c)) (* b b))
     (+ b (sqrt (- (* b b) (* (* 4.0 a) c)))))
    (* a 2.0))
   (- (* 1.0 (/ c b)))))
double code(double a, double b, double c) {
	return (((double) (((double) -(b)) + ((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (4.0 * a)) * c)))))))) / ((double) (2.0 * a)));
}
double code(double a, double b, double c) {
	double tmp;
	if ((b <= 391.5762305688583)) {
		tmp = ((((double) (((double) (((double) (b * b)) - ((double) (((double) (4.0 * a)) * c)))) - ((double) (b * b)))) / ((double) (b + ((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (4.0 * a)) * c))))))))) / ((double) (a * 2.0)));
	} else {
		tmp = ((double) -(((double) (1.0 * (c / b)))));
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if b < 391.576230568858307

    1. Initial program 16.4

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2}}\]
    3. Using strategy rm
    4. Applied flip--_binary6416.4

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

      \[\leadsto \frac{\frac{\color{blue}{\left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) - b \cdot b}}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{a \cdot 2}\]
    6. Simplified15.4

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

    if 391.576230568858307 < b

    1. Initial program 34.9

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification16.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 391.5762305688583:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) - b \cdot b}{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2020204 
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :precision binary64
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))