Average Error: 34.4 → 6.7
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 -1.95155870856424 \cdot 10^{+129}:\\ \;\;\;\;0.5 \cdot \frac{c}{b_2} + b_2 \cdot \frac{-2}{a}\\ \mathbf{elif}\;b_2 \leq -2.8405866436241524 \cdot 10^{-198}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.9930311221408239 \cdot 10^{+59}:\\ \;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b_2 + \left(b_2 + a \cdot \frac{-0.5}{\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 -1.95155870856424 \cdot 10^{+129}:\\
\;\;\;\;0.5 \cdot \frac{c}{b_2} + b_2 \cdot \frac{-2}{a}\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{-c}{b_2 + \left(b_2 + a \cdot \frac{-0.5}{\frac{b_2}{c}}\right)}\\

\end{array}
double code(double a, double b_2, double c) {
	return (((double) (((double) -(b_2)) + ((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (a * c)))))))) / a);
}
double code(double a, double b_2, double c) {
	double VAR;
	if ((b_2 <= -1.95155870856424e+129)) {
		VAR = ((double) (((double) (0.5 * (c / b_2))) + ((double) (b_2 * (-2.0 / a)))));
	} else {
		double VAR_1;
		if ((b_2 <= -2.8405866436241524e-198)) {
			VAR_1 = (((double) (((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a)))))) - b_2)) / a);
		} else {
			double VAR_2;
			if ((b_2 <= 1.9930311221408239e+59)) {
				VAR_2 = (((double) -(c)) / ((double) (b_2 + ((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a)))))))));
			} else {
				VAR_2 = (((double) -(c)) / ((double) (b_2 + ((double) (b_2 + ((double) (a * (-0.5 / (b_2 / c)))))))));
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	return VAR;
}

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.95155870856424e129

    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 2.6

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

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

    if -1.95155870856424e129 < b_2 < -2.8405866436241524e-198

    1. Initial program 7.2

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

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

    if -2.8405866436241524e-198 < b_2 < 1.99303112214082389e59

    1. Initial program 27.1

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

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

      \[\leadsto \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}}}{a}\]
    5. Simplified16.8

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

      \[\leadsto \frac{\frac{a \cdot \left(-c\right)}{\color{blue}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    7. Using strategy rm
    8. Applied distribute-rgt-neg-out16.8

      \[\leadsto \frac{\frac{\color{blue}{-a \cdot c}}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    9. Applied distribute-frac-neg16.8

      \[\leadsto \frac{\color{blue}{-\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    10. Applied distribute-frac-neg16.8

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

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

    if 1.99303112214082389e59 < b_2

    1. Initial program 57.9

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

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

      \[\leadsto \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}}}{a}\]
    5. Simplified30.4

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

      \[\leadsto \frac{\frac{a \cdot \left(-c\right)}{\color{blue}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    7. Using strategy rm
    8. Applied distribute-rgt-neg-out30.4

      \[\leadsto \frac{\frac{\color{blue}{-a \cdot c}}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    9. Applied distribute-frac-neg30.4

      \[\leadsto \frac{\color{blue}{-\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    10. Applied distribute-frac-neg30.4

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

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

      \[\leadsto -\frac{c}{b_2 + \color{blue}{\left(b_2 - 0.5 \cdot \frac{a \cdot c}{b_2}\right)}}\]
    13. Simplified3.8

      \[\leadsto -\frac{c}{b_2 + \color{blue}{\left(b_2 + a \cdot \frac{-0.5}{\frac{b_2}{c}}\right)}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.95155870856424 \cdot 10^{+129}:\\ \;\;\;\;0.5 \cdot \frac{c}{b_2} + b_2 \cdot \frac{-2}{a}\\ \mathbf{elif}\;b_2 \leq -2.8405866436241524 \cdot 10^{-198}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.9930311221408239 \cdot 10^{+59}:\\ \;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b_2 + \left(b_2 + a \cdot \frac{-0.5}{\frac{b_2}{c}}\right)}\\ \end{array}\]

Reproduce

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