Average Error: 34.0 → 9.5
Time: 8.6s
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 -9.131732657146973 \cdot 10^{+152}:\\ \;\;\;\;\frac{\left(-b_2\right) - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.7908910694223973 \cdot 10^{-96}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{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 -9.131732657146973 \cdot 10^{+152}:\\
\;\;\;\;\frac{\left(-b_2\right) - b_2}{a}\\

\mathbf{elif}\;b_2 \leq 1.7908910694223973 \cdot 10^{-96}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{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 -9.131732657146973e+152)
   (/ (- (- b_2) b_2) a)
   (if (<= b_2 1.7908910694223973e-96)
     (/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) 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 <= -9.131732657146973e+152) {
		tmp = (-b_2 - b_2) / a;
	} else if (b_2 <= 1.7908910694223973e-96) {
		tmp = (sqrt((b_2 * b_2) - (a * c)) - b_2) / 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 3 regimes
  2. if b_2 < -9.1317326571469729e152

    1. Initial program 63.7

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    3. Applied div-inv_binary6463.7

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}} \]
    4. Applied pow1_binary6463.7

      \[\leadsto \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \color{blue}{{\left(\frac{1}{a}\right)}^{1}} \]
    5. Applied pow1_binary6463.7

      \[\leadsto \color{blue}{{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}^{1}} \cdot {\left(\frac{1}{a}\right)}^{1} \]
    6. Applied pow-prod-down_binary6463.7

      \[\leadsto \color{blue}{{\left(\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}\right)}^{1}} \]
    7. Simplified37.5

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

      \[\leadsto {\left(\frac{\color{blue}{-1 \cdot b_2} - b_2}{a}\right)}^{1} \]
    9. Simplified2.4

      \[\leadsto {\left(\frac{\color{blue}{\left(-b_2\right)} - b_2}{a}\right)}^{1} \]

    if -9.1317326571469729e152 < b_2 < 1.7908910694223973e-96

    1. Initial program 11.1

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

    if 1.7908910694223973e-96 < b_2

    1. Initial program 53.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -9.131732657146973 \cdot 10^{+152}:\\ \;\;\;\;\frac{\left(-b_2\right) - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.7908910694223973 \cdot 10^{-96}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]

Reproduce

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