Average Error: 34.8 → 9.2
Time: 5.9s
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 4.664337940942095 \cdot 10^{-142}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.350743022224145 \cdot 10^{-69}:\\ \;\;\;\;\frac{-\frac{c}{a}}{\frac{b_2}{a} + \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}}\\ \mathbf{elif}\;b_2 \leq 5.38924907603627 \cdot 10^{+103}:\\ \;\;\;\;\frac{\frac{-c \cdot a}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot -0.5\\ \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 4.664337940942095 \cdot 10^{-142}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\

\mathbf{elif}\;b_2 \leq 1.350743022224145 \cdot 10^{-69}:\\
\;\;\;\;\frac{-\frac{c}{a}}{\frac{b_2}{a} + \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}}\\

\mathbf{elif}\;b_2 \leq 5.38924907603627 \cdot 10^{+103}:\\
\;\;\;\;\frac{\frac{-c \cdot a}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{b_2} \cdot -0.5\\

\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 4.664337940942095e-142)
     (- (/ (sqrt (- (* b_2 b_2) (* c a))) a) (/ b_2 a))
     (if (<= b_2 1.350743022224145e-69)
       (/ (- (/ c a)) (+ (/ b_2 a) (/ (sqrt (- (* b_2 b_2) (* c a))) a)))
       (if (<= b_2 5.38924907603627e+103)
         (/ (/ (- (* c a)) (+ b_2 (sqrt (- (* b_2 b_2) (* c a))))) a)
         (* (/ c b_2) -0.5))))))
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 <= 4.664337940942095e-142) {
		tmp = (sqrt((b_2 * b_2) - (c * a)) / a) - (b_2 / a);
	} else if (b_2 <= 1.350743022224145e-69) {
		tmp = -(c / a) / ((b_2 / a) + (sqrt((b_2 * b_2) - (c * a)) / a));
	} else if (b_2 <= 5.38924907603627e+103) {
		tmp = (-(c * a) / (b_2 + sqrt((b_2 * b_2) - (c * a)))) / a;
	} else {
		tmp = (c / b_2) * -0.5;
	}
	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 5 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. Simplified63.2

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. 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 < 4.664337940942095e-142

    1. Initial program 11.1

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-sub_binary6411.1

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

    if 4.664337940942095e-142 < b_2 < 1.3507430222241449e-69

    1. Initial program 27.8

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-sub_binary6427.8

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}}\]
    5. Using strategy rm
    6. Applied flip--_binary6441.0

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \cdot \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a} \cdot \frac{b_2}{a}}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} + \frac{b_2}{a}}}\]
    7. Simplified21.2

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

    if 1.3507430222241449e-69 < b_2 < 5.38924907603627023e103

    1. Initial program 44.1

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied flip--_binary6444.1

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}{a}\]
    5. Simplified15.4

      \[\leadsto \frac{\frac{\color{blue}{-a \cdot c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}{a}\]
    6. Simplified15.4

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

    if 5.38924907603627023e103 < b_2

    1. Initial program 60.1

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around inf 2.4

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}}\]
  3. Recombined 5 regimes into one program.
  4. Final simplification9.2

    \[\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 4.664337940942095 \cdot 10^{-142}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.350743022224145 \cdot 10^{-69}:\\ \;\;\;\;\frac{-\frac{c}{a}}{\frac{b_2}{a} + \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}}\\ \mathbf{elif}\;b_2 \leq 5.38924907603627 \cdot 10^{+103}:\\ \;\;\;\;\frac{\frac{-c \cdot a}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot -0.5\\ \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))