Average Error: 34.1 → 9.8
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 -4.0639773095563594 \cdot 10^{+117}:\\ \;\;\;\;\left(\sqrt[3]{0.5} \cdot \sqrt[3]{0.5}\right) \cdot \left(\sqrt[3]{0.5} \cdot \frac{c}{b_2}\right) + -2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 4.75264682550615 \cdot 10^{-107}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{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 -4.0639773095563594 \cdot 10^{+117}:\\
\;\;\;\;\left(\sqrt[3]{0.5} \cdot \sqrt[3]{0.5}\right) \cdot \left(\sqrt[3]{0.5} \cdot \frac{c}{b_2}\right) + -2 \cdot \frac{b_2}{a}\\

\mathbf{elif}\;b_2 \leq 4.75264682550615 \cdot 10^{-107}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{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 -4.0639773095563594e+117)
   (+
    (* (* (cbrt 0.5) (cbrt 0.5)) (* (cbrt 0.5) (/ c b_2)))
    (* -2.0 (/ b_2 a)))
   (if (<= b_2 4.75264682550615e-107)
     (- (/ (sqrt (- (* b_2 b_2) (* c a))) a) (/ b_2 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 <= -4.0639773095563594e+117) {
		tmp = ((cbrt(0.5) * cbrt(0.5)) * (cbrt(0.5) * (c / b_2))) + (-2.0 * (b_2 / a));
	} else if (b_2 <= 4.75264682550615e-107) {
		tmp = (sqrt((b_2 * b_2) - (c * a)) / a) - (b_2 / 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 3 regimes
  2. if b_2 < -4.0639773095563594e117

    1. Initial program 50.7

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b_2} + -2 \cdot \frac{b_2}{a}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt_binary642.7

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{0.5} \cdot \sqrt[3]{0.5}\right) \cdot \sqrt[3]{0.5}\right)} \cdot \frac{c}{b_2} + -2 \cdot \frac{b_2}{a}\]
    7. Applied associate-*l*_binary642.7

      \[\leadsto \color{blue}{\left(\sqrt[3]{0.5} \cdot \sqrt[3]{0.5}\right) \cdot \left(\sqrt[3]{0.5} \cdot \frac{c}{b_2}\right)} + -2 \cdot \frac{b_2}{a}\]
    8. Simplified2.7

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

    if -4.0639773095563594e117 < b_2 < 4.75264682550615004e-107

    1. Initial program 11.6

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

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

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

    if 4.75264682550615004e-107 < b_2

    1. Initial program 52.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -4.0639773095563594 \cdot 10^{+117}:\\ \;\;\;\;\left(\sqrt[3]{0.5} \cdot \sqrt[3]{0.5}\right) \cdot \left(\sqrt[3]{0.5} \cdot \frac{c}{b_2}\right) + -2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 4.75264682550615 \cdot 10^{-107}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot -0.5\\ \end{array}\]

Reproduce

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