Average Error: 34.1 → 6.5
Time: 10.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 -1.344663677076728 \cdot 10^{+139}:\\ \;\;\;\;\frac{c}{b_2 \cdot -2}\\ \mathbf{elif}\;b_2 \leq 1.0584144284358635 \cdot 10^{-270}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\ \mathbf{elif}\;b_2 \leq 4.5829281059216323 \cdot 10^{+120}:\\ \;\;\;\;\frac{b_2}{-a} - \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{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.344663677076728 \cdot 10^{+139}:\\
\;\;\;\;\frac{c}{b_2 \cdot -2}\\

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

\mathbf{elif}\;b_2 \leq 4.5829281059216323 \cdot 10^{+120}:\\
\;\;\;\;\frac{b_2}{-a} - \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{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.344663677076728e+139)
   (/ c (* b_2 -2.0))
   (if (<= b_2 1.0584144284358635e-270)
     (/ c (- (sqrt (- (* b_2 b_2) (* c a))) b_2))
     (if (<= b_2 4.5829281059216323e+120)
       (- (/ b_2 (- a)) (/ (sqrt (- (* b_2 b_2) (* c a))) a))
       (/ (* b_2 -2.0) 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.344663677076728e+139) {
		tmp = c / (b_2 * -2.0);
	} else if (b_2 <= 1.0584144284358635e-270) {
		tmp = c / (sqrt((b_2 * b_2) - (c * a)) - b_2);
	} else if (b_2 <= 4.5829281059216323e+120) {
		tmp = (b_2 / -a) - (sqrt((b_2 * b_2) - (c * a)) / a);
	} else {
		tmp = (b_2 * -2.0) / 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 4 regimes
  2. if b_2 < -1.344663677076728e139

    1. Initial program 62.6

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--_binary6462.6

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Simplified35.6

      \[\leadsto \frac{\frac{\color{blue}{a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Simplified35.6

      \[\leadsto \frac{\frac{a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity_binary6435.6

      \[\leadsto \frac{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied *-un-lft-identity_binary6435.6

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{1 \cdot a}\]
    9. Applied times-frac_binary6435.6

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

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

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

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

    if -1.344663677076728e139 < b_2 < 1.0584144284358635e-270

    1. Initial program 32.6

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--_binary6432.6

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

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

      \[\leadsto \frac{\frac{a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity_binary6415.7

      \[\leadsto \frac{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied *-un-lft-identity_binary6415.7

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{1 \cdot a}\]
    9. Applied times-frac_binary6415.7

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

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

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

    if 1.0584144284358635e-270 < b_2 < 4.5829281059216323e120

    1. Initial program 9.3

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied div-sub_binary649.3

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

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

    if 4.5829281059216323e120 < b_2

    1. Initial program 51.6

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around inf 2.4

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

      \[\leadsto \frac{\color{blue}{b_2 \cdot -2}}{a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.344663677076728 \cdot 10^{+139}:\\ \;\;\;\;\frac{c}{b_2 \cdot -2}\\ \mathbf{elif}\;b_2 \leq 1.0584144284358635 \cdot 10^{-270}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\ \mathbf{elif}\;b_2 \leq 4.5829281059216323 \cdot 10^{+120}:\\ \;\;\;\;\frac{b_2}{-a} - \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2021044 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))