Average Error: 33.8 → 8.6
Time: 8.3s
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 -1.1611459299322468 \cdot 10^{+154}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \mathbf{elif}\;b_2 \leq 1.496397647743439 \cdot 10^{-129}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2101650834768822.8:\\ \;\;\;\;\frac{\frac{\frac{-a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{\sqrt[3]{a} \cdot \sqrt[3]{a}}}{\sqrt[3]{a}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \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 -1.1611459299322468 \cdot 10^{+154}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\

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

\mathbf{elif}\;b_2 \leq 2101650834768822.8:\\
\;\;\;\;\frac{\frac{\frac{-a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{\sqrt[3]{a} \cdot \sqrt[3]{a}}}{\sqrt[3]{a}}\\

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

\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 -1.1611459299322468e+154)
   (/ (* b_2 -2.0) a)
   (if (<= b_2 1.496397647743439e-129)
     (- (/ (sqrt (- (* b_2 b_2) (* a c))) a) (/ b_2 a))
     (if (<= b_2 2101650834768822.8)
       (/
        (/
         (/ (- (* a c)) (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))
         (* (cbrt a) (cbrt a)))
        (cbrt a))
       (* -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 <= -1.1611459299322468e+154) {
		tmp = (b_2 * -2.0) / a;
	} else if (b_2 <= 1.496397647743439e-129) {
		tmp = (sqrt((b_2 * b_2) - (a * c)) / a) - (b_2 / a);
	} else if (b_2 <= 2101650834768822.8) {
		tmp = ((-(a * c) / (b_2 + sqrt((b_2 * b_2) - (a * c)))) / (cbrt(a) * cbrt(a))) / cbrt(a);
	} else {
		tmp = -0.5 * (c / b_2);
	}
	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 < -1.1611459299322468e154

    1. Initial program 64.0

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

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

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

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

    if -1.1611459299322468e154 < b_2 < 1.4963976477434392e-129

    1. Initial program 10.9

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

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

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

    if 1.4963976477434392e-129 < b_2 < 2101650834768822.75

    1. Initial program 35.0

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt_binary6435.5

      \[\leadsto \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}}\]
    5. Applied associate-/r*_binary6435.5

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

      \[\leadsto \frac{\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}}}{\sqrt[3]{a} \cdot \sqrt[3]{a}}}{\sqrt[3]{a}}\]
    8. Simplified17.2

      \[\leadsto \frac{\frac{\frac{\color{blue}{-a \cdot c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}{\sqrt[3]{a} \cdot \sqrt[3]{a}}}{\sqrt[3]{a}}\]
    9. Simplified17.2

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

    if 2101650834768822.75 < b_2

    1. Initial program 56.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.1611459299322468 \cdot 10^{+154}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \mathbf{elif}\;b_2 \leq 1.496397647743439 \cdot 10^{-129}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2101650834768822.8:\\ \;\;\;\;\frac{\frac{\frac{-a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{\sqrt[3]{a} \cdot \sqrt[3]{a}}}{\sqrt[3]{a}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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