Average Error: 33.3 → 6.5
Time: 6.2s
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.4567324551787413 \cdot 10^{+135}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_0 := \sqrt{b_2 \cdot b_2 - a \cdot c}\\ \mathbf{if}\;b_2 \leq -5.819383246893776 \cdot 10^{-242}:\\ \;\;\;\;\frac{t_0 - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 3.685097484787006 \cdot 10^{+117}:\\ \;\;\;\;\frac{-c}{b_2 + t_0}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array}\\ \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.4567324551787413 \cdot 10^{+135}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := \sqrt{b_2 \cdot b_2 - a \cdot c}\\
\mathbf{if}\;b_2 \leq -5.819383246893776 \cdot 10^{-242}:\\
\;\;\;\;\frac{t_0 - b_2}{a}\\

\mathbf{elif}\;b_2 \leq 3.685097484787006 \cdot 10^{+117}:\\
\;\;\;\;\frac{-c}{b_2 + t_0}\\

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


\end{array}\\


\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.4567324551787413e+135)
   (/ (* b_2 -2.0) a)
   (let* ((t_0 (sqrt (- (* b_2 b_2) (* a c)))))
     (if (<= b_2 -5.819383246893776e-242)
       (/ (- t_0 b_2) a)
       (if (<= b_2 3.685097484787006e+117)
         (/ (- c) (+ b_2 t_0))
         (* -0.5 (/ c b_2)))))))
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 <= -2.4567324551787413e+135) {
		tmp = (b_2 * -2.0) / a;
	} else {
		double t_0 = sqrt((b_2 * b_2) - (a * c));
		double tmp_1;
		if (b_2 <= -5.819383246893776e-242) {
			tmp_1 = (t_0 - b_2) / a;
		} else if (b_2 <= 3.685097484787006e+117) {
			tmp_1 = -c / (b_2 + t_0);
		} else {
			tmp_1 = -0.5 * (c / b_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.4567324551787413e135

    1. Initial program 56.2

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

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

      \[\leadsto \frac{\color{blue}{-2 \cdot b_2}}{a} \]
    4. Simplified2.7

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

    if -2.4567324551787413e135 < b_2 < -5.8193832468937762e-242

    1. Initial program 7.7

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    3. Using strategy rm
    4. Applied *-un-lft-identity_binary647.7

      \[\leadsto \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{\color{blue}{1 \cdot a}} \]
    5. Applied associate-/r*_binary647.7

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

    if -5.8193832468937762e-242 < b_2 < 3.6850974847870061e117

    1. Initial program 30.1

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}} \]
    6. Using strategy rm
    7. Applied flip--_binary6430.2

      \[\leadsto \frac{1}{\frac{a}{\color{blue}{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} \cdot \sqrt{b_2 \cdot b_2 - c \cdot a} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}}}} \]
    8. Applied associate-/r/_binary6430.2

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} \cdot \sqrt{b_2 \cdot b_2 - c \cdot a} - b_2 \cdot b_2} \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2\right)}} \]
    9. Applied associate-/r*_binary6430.2

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

      \[\leadsto \frac{\color{blue}{\frac{b_2 \cdot b_2 - \left(c \cdot a + b_2 \cdot b_2\right)}{a}}}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2} \]
    11. Taylor expanded around 0 9.3

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

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

    if 3.6850974847870061e117 < b_2

    1. Initial program 59.6

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

      \[\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 4 regimes into one program.
  4. Final simplification6.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -2.4567324551787413 \cdot 10^{+135}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \mathbf{elif}\;b_2 \leq -5.819383246893776 \cdot 10^{-242}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 3.685097484787006 \cdot 10^{+117}:\\ \;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]

Reproduce

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