Average Error: 34.0 → 21.9
Time: 4.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.3450496563396583 \cdot 10^{+154}:\\ \;\;\;\;\frac{-b_2}{a}\\ \mathbf{elif}\;b_2 \leq 4.0435292778603006 \cdot 10^{-92}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{\sqrt[3]{a}} \cdot \frac{-1}{\sqrt[3]{a} \cdot \sqrt[3]{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 -1.3450496563396583 \cdot 10^{+154}:\\
\;\;\;\;\frac{-b_2}{a}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{\sqrt[3]{a}} \cdot \frac{-1}{\sqrt[3]{a} \cdot \sqrt[3]{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 -1.3450496563396583e+154)
   (/ (- b_2) a)
   (if (<= b_2 4.0435292778603006e-92)
     (/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
     (*
      (/ (/ (* a c) (+ b_2 (sqrt (- (* b_2 b_2) (* a c))))) (cbrt a))
      (/ -1.0 (* (cbrt a) (cbrt 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 <= -1.3450496563396583e+154) {
		tmp = -b_2 / a;
	} else if (b_2 <= 4.0435292778603006e-92) {
		tmp = (sqrt((b_2 * b_2) - (a * c)) - b_2) / a;
	} else {
		tmp = (((a * c) / (b_2 + sqrt((b_2 * b_2) - (a * c)))) / cbrt(a)) * (-1.0 / (cbrt(a) * cbrt(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 3 regimes
  2. if b_2 < -1.34504965633965828e154

    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 0 52.2

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

    if -1.34504965633965828e154 < b_2 < 4.04352927786030063e-92

    1. Initial program 12.1

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

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

    if 4.04352927786030063e-92 < b_2

    1. Initial program 52.5

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

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

      \[\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 *-un-lft-identity_binary6452.6

      \[\leadsto \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - \color{blue}{1 \cdot b_2}}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}\]
    6. Applied *-un-lft-identity_binary6452.6

      \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}} - 1 \cdot b_2}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}\]
    7. Applied distribute-lft-out--_binary6452.6

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}\]
    8. Applied times-frac_binary6452.6

      \[\leadsto \color{blue}{\frac{1}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{\sqrt[3]{a}}}\]
    9. Using strategy rm
    10. Applied flip--_binary6452.6

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

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

      \[\leadsto \frac{1}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{\frac{-a \cdot c}{\color{blue}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{\sqrt[3]{a}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification21.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.3450496563396583 \cdot 10^{+154}:\\ \;\;\;\;\frac{-b_2}{a}\\ \mathbf{elif}\;b_2 \leq 4.0435292778603006 \cdot 10^{-92}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{\sqrt[3]{a}} \cdot \frac{-1}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\\ \end{array}\]

Reproduce

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