Average Error: 34.4 → 10.4
Time: 14.4s
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.3543135764255064 \cdot 10^{+153}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\ \mathbf{elif}\;b_2 \leq 3.021168818743586 \cdot 10^{-70}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(0.5, \frac{a}{b_2}, 2 \cdot \frac{b_2}{-c}\right)}\\ \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.3543135764255064 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(0.5, \frac{a}{b_2}, 2 \cdot \frac{b_2}{-c}\right)}\\


\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.3543135764255064e+153)
   (fma 0.5 (/ c b_2) (* -2.0 (/ b_2 a)))
   (if (<= b_2 3.021168818743586e-70)
     (/ (- (sqrt (- (* b_2 b_2) (* c a))) b_2) a)
     (/ 1.0 (fma 0.5 (/ a b_2) (* 2.0 (/ b_2 (- c))))))))
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.3543135764255064e+153) {
		tmp = fma(0.5, (c / b_2), (-2.0 * (b_2 / a)));
	} else if (b_2 <= 3.021168818743586e-70) {
		tmp = (sqrt((b_2 * b_2) - (c * a)) - b_2) / a;
	} else {
		tmp = 1.0 / fma(0.5, (a / b_2), (2.0 * (b_2 / -c)));
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b_2 < -4.3543135764255064e153

    1. Initial program 63.8

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)} \]

    if -4.3543135764255064e153 < b_2 < 3.02116881874358578e-70

    1. Initial program 13.0

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    3. Applied *-un-lft-identity_binary6413.0

      \[\leadsto \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{\color{blue}{1 \cdot a}} \]
    4. Applied associate-/r*_binary6413.0

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

    if 3.02116881874358578e-70 < b_2

    1. Initial program 53.5

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    3. Applied clear-num_binary6453.5

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

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}}} \]
    5. Taylor expanded in b_2 around inf 40.4

      \[\leadsto \frac{1}{\color{blue}{0.5 \cdot \frac{a}{b_2} + 2 \cdot \frac{a \cdot b_2}{{\left(\sqrt{-c \cdot a}\right)}^{2}}}} \]
    6. Simplified9.5

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(0.5, \frac{a}{b_2}, 2 \cdot \frac{b_2}{-c}\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -4.3543135764255064 \cdot 10^{+153}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\ \mathbf{elif}\;b_2 \leq 3.021168818743586 \cdot 10^{-70}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(0.5, \frac{a}{b_2}, 2 \cdot \frac{b_2}{-c}\right)}\\ \end{array} \]

Reproduce

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