Average Error: 19.4 → 8.5
Time: 4.4s
Precision: binary64
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \leq -2.7483400760500613 \cdot 10^{+159}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{2 \cdot \left(\frac{a \cdot c}{b} - b\right)}\\ \end{array}\\ \mathbf{elif}\;b \leq 5.179473729497393 \cdot 10^{+78}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{\sqrt{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{2 \cdot \left(b - \frac{a \cdot c}{b}\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

\end{array}
\begin{array}{l}
\mathbf{if}\;b \leq -2.7483400760500613 \cdot 10^{+159}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \left(\frac{a \cdot c}{b} - b\right)}\\

\end{array}\\

\mathbf{elif}\;b \leq 5.179473729497393 \cdot 10^{+78}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{\sqrt{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\

\end{array}\\

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{2 \cdot \left(b - \frac{a \cdot c}{b}\right)}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\

\end{array}
(FPCore (a b c)
 :precision binary64
 (if (>= b 0.0)
   (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))
   (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))
(FPCore (a b c)
 :precision binary64
 (if (<= b -2.7483400760500613e+159)
   (if (>= b 0.0)
     (* -0.5 (/ (+ b (sqrt (- (* b b) (* (* 4.0 a) c)))) a))
     (/ (* c 2.0) (* 2.0 (- (/ (* a c) b) b))))
   (if (<= b 5.179473729497393e+78)
     (if (>= b 0.0)
       (*
        -0.5
        (/
         (*
          (sqrt (+ b (sqrt (- (* b b) (* (* 4.0 a) c)))))
          (sqrt (+ b (sqrt (- (* b b) (* (* 4.0 a) c))))))
         a))
       (/ (* c 2.0) (- (sqrt (- (* b b) (* (* 4.0 a) c))) b)))
     (if (>= b 0.0)
       (* -0.5 (/ (* 2.0 (- b (/ (* a c) b))) a))
       (/ (* c 2.0) (- (sqrt (- (* b b) (* (* 4.0 a) c))) b))))))
double code(double a, double b, double c) {
	double tmp;
	if ((b >= 0.0)) {
		tmp = (((double) (((double) -(b)) - ((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (4.0 * a)) * c)))))))) / ((double) (2.0 * a)));
	} else {
		tmp = (((double) (2.0 * c)) / ((double) (((double) -(b)) + ((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (4.0 * a)) * c)))))))));
	}
	return tmp;
}
double code(double a, double b, double c) {
	double tmp;
	if ((b <= -2.7483400760500613e+159)) {
		double tmp_1;
		if ((b >= 0.0)) {
			tmp_1 = ((double) (-0.5 * (((double) (b + ((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (4.0 * a)) * c)))))))) / a)));
		} else {
			tmp_1 = (((double) (c * 2.0)) / ((double) (2.0 * ((double) ((((double) (a * c)) / b) - b)))));
		}
		tmp = tmp_1;
	} else {
		double tmp_2;
		if ((b <= 5.179473729497393e+78)) {
			double tmp_3;
			if ((b >= 0.0)) {
				tmp_3 = ((double) (-0.5 * (((double) (((double) sqrt(((double) (b + ((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (4.0 * a)) * c)))))))))) * ((double) sqrt(((double) (b + ((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (4.0 * a)) * c)))))))))))) / a)));
			} else {
				tmp_3 = (((double) (c * 2.0)) / ((double) (((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (4.0 * a)) * c)))))) - b)));
			}
			tmp_2 = tmp_3;
		} else {
			double tmp_4;
			if ((b >= 0.0)) {
				tmp_4 = ((double) (-0.5 * (((double) (2.0 * ((double) (b - (((double) (a * c)) / b))))) / a)));
			} else {
				tmp_4 = (((double) (c * 2.0)) / ((double) (((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (4.0 * a)) * c)))))) - b)));
			}
			tmp_2 = tmp_4;
		}
		tmp = tmp_2;
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus b

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.7483400760500613e159

    1. Initial program 38.4

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Simplified38.4

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt_binary6438.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\color{blue}{c} \cdot 2}{\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} - b}\\ \end{array}\]
    5. Applied sqrt-prod_binary6438.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\color{blue}{c \cdot 2}}{\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} - b}\\ \end{array}\]
    6. Taylor expanded around -inf 6.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\color{blue}{\frac{c \cdot 2}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}\\ \end{array}\]
    7. Simplified6.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\color{blue}{\frac{c \cdot 2}{2 \cdot \left(\frac{a \cdot c}{b} - b\right)}}\\ \end{array}\]

    if -2.7483400760500613e159 < b < 5.1794737294973928e78

    1. Initial program 8.6

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Simplified8.6

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt_binary648.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{\color{blue}{\sqrt{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]

    if 5.1794737294973928e78 < b

    1. Initial program 42.3

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Simplified42.4

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Taylor expanded around inf 9.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{\color{blue}{2 \cdot b - 2 \cdot \frac{a \cdot c}{b}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
    4. Simplified9.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{\color{blue}{2 \cdot \left(b - \frac{a \cdot c}{b}\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification8.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2.7483400760500613 \cdot 10^{+159}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{2 \cdot \left(\frac{a \cdot c}{b} - b\right)}\\ \end{array}\\ \mathbf{elif}\;b \leq 5.179473729497393 \cdot 10^{+78}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{\sqrt{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{2 \cdot \left(b - \frac{a \cdot c}{b}\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]

Reproduce

herbie shell --seed 2020219 
(FPCore (a b c)
  :name "jeff quadratic root 1"
  :precision binary64
  (if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))