Average Error: 34.8 → 9.3
Time: 5.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 -9.156580055033079 \cdot 10^{+151}:\\ \;\;\;\;0.5 \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.4844516945955604 \cdot 10^{-140}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 5.835011607741609 \cdot 10^{-124} \lor \neg \left(b_2 \leq 1.8362622646806402 \cdot 10^{+105}\right):\\ \;\;\;\;\frac{c}{b_2} \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}{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 -9.156580055033079 \cdot 10^{+151}:\\
\;\;\;\;0.5 \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\

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

\mathbf{elif}\;b_2 \leq 5.835011607741609 \cdot 10^{-124} \lor \neg \left(b_2 \leq 1.8362622646806402 \cdot 10^{+105}\right):\\
\;\;\;\;\frac{c}{b_2} \cdot -0.5\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}{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 -9.156580055033079e+151)
   (- (* 0.5 (/ c b_2)) (* 2.0 (/ b_2 a)))
   (if (<= b_2 1.4844516945955604e-140)
     (/ (- (sqrt (- (* b_2 b_2) (* c a))) b_2) a)
     (if (or (<= b_2 5.835011607741609e-124)
             (not (<= b_2 1.8362622646806402e+105)))
       (* (/ c b_2) -0.5)
       (/ (/ (* c a) (- (- b_2) (sqrt (- (* b_2 b_2) (* c a))))) 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 <= -9.156580055033079e+151) {
		tmp = (0.5 * (c / b_2)) - (2.0 * (b_2 / a));
	} else if (b_2 <= 1.4844516945955604e-140) {
		tmp = (sqrt((b_2 * b_2) - (c * a)) - b_2) / a;
	} else if ((b_2 <= 5.835011607741609e-124) || !(b_2 <= 1.8362622646806402e+105)) {
		tmp = (c / b_2) * -0.5;
	} else {
		tmp = ((c * a) / (-b_2 - sqrt((b_2 * b_2) - (c * a)))) / 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 < -9.1565800550330794e151

    1. Initial program 63.2

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

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

    if -9.1565800550330794e151 < b_2 < 1.4844516945955604e-140

    1. Initial program 11.1

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

    if 1.4844516945955604e-140 < b_2 < 5.835011607741609e-124 or 1.8362622646806402e105 < b_2

    1. Initial program 58.6

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

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

    if 5.835011607741609e-124 < b_2 < 1.8362622646806402e105

    1. Initial program 41.4

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip-+_binary6441.4

      \[\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. Simplified15.6

      \[\leadsto \frac{\frac{\color{blue}{a \cdot c}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification9.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -9.156580055033079 \cdot 10^{+151}:\\ \;\;\;\;0.5 \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.4844516945955604 \cdot 10^{-140}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 5.835011607741609 \cdot 10^{-124} \lor \neg \left(b_2 \leq 1.8362622646806402 \cdot 10^{+105}\right):\\ \;\;\;\;\frac{c}{b_2} \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020292 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  :precision binary64
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))