Average Error: 20.2 → 6.8
Time: 4.0min
Precision: binary64
Cost: 39753
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array} \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\\ \mathbf{elif}\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array} \leq -2.905616384651 \cdot 10^{-314}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array} \leq 0:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c}{\frac{b}{a}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array} \leq 1.1144892510332327 \cdot 10^{+221}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-2 \cdot \left(0.5 \cdot \frac{c}{b}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

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

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

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

\end{array} \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\

\end{array}\\

\mathbf{elif}\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\

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

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

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

\end{array}\\

\mathbf{elif}\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\

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

\end{array} \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c}{\frac{b}{a}}\right)}\\

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

\end{array}\\

\mathbf{elif}\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\

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

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

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

\end{array}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

\end{array}
(FPCore (a b c)
 :precision binary64
 (if (>= b 0.0)
   (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))
   (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))
(FPCore (a b c)
 :precision binary64
 (if (<=
      (if (>= b 0.0)
        (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* c (* 4.0 a))))))
        (/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a)))
      (- INFINITY))
   (if (>= b 0.0) (* -2.0 (/ c (* 2.0 (- b (/ (* c a) b))))) (/ (- b) a))
   (if (<=
        (if (>= b 0.0)
          (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* c (* 4.0 a))))))
          (/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a)))
        -2.905616384651e-314)
     (if (>= b 0.0)
       (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* c (* 4.0 a))))))
       (/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a)))
     (if (<=
          (if (>= b 0.0)
            (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* c (* 4.0 a))))))
            (/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a)))
          0.0)
       (if (>= b 0.0)
         (* -2.0 (/ c (* 2.0 (- b (/ c (/ b a))))))
         (/ (* 2.0 (- (/ (* c a) b) b)) (* 2.0 a)))
       (if (<=
            (if (>= b 0.0)
              (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* c (* 4.0 a))))))
              (/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a)))
            1.1144892510332327e+221)
         (if (>= b 0.0)
           (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* c (* 4.0 a))))))
           (/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a)))
         (if (>= b 0.0) (* -2.0 (* 0.5 (/ c b))) (- (/ c b) (/ b a))))))))
double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - sqrt((b * b) - ((4.0 * a) * c)));
	} else {
		tmp = (-b + sqrt((b * b) - ((4.0 * a) * c))) / (2.0 * a);
	}
	return tmp;
}
double code(double a, double b, double c) {
	double tmp_1;
	if (b >= 0.0) {
		tmp_1 = (2.0 * c) / (-b - sqrt((b * b) - (c * (4.0 * a))));
	} else {
		tmp_1 = (sqrt((b * b) - (c * (4.0 * a))) - b) / (2.0 * a);
	}
	double tmp;
	if (tmp_1 <= -((double) INFINITY)) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = -2.0 * (c / (2.0 * (b - ((c * a) / b))));
		} else {
			tmp_2 = -b / a;
		}
		tmp = tmp_2;
	double tmp_3;
	if (b >= 0.0) {
		tmp_3 = (2.0 * c) / (-b - sqrt((b * b) - (c * (4.0 * a))));
	} else {
		tmp_3 = (sqrt((b * b) - (c * (4.0 * a))) - b) / (2.0 * a);
	}
	} else if (tmp_3 <= -2.905616384651e-314) {
		double tmp_4;
		if (b >= 0.0) {
			tmp_4 = (2.0 * c) / (-b - sqrt((b * b) - (c * (4.0 * a))));
		} else {
			tmp_4 = (sqrt((b * b) - (c * (4.0 * a))) - b) / (2.0 * a);
		}
		tmp = tmp_4;
	double tmp_5;
	if (b >= 0.0) {
		tmp_5 = (2.0 * c) / (-b - sqrt((b * b) - (c * (4.0 * a))));
	} else {
		tmp_5 = (sqrt((b * b) - (c * (4.0 * a))) - b) / (2.0 * a);
	}
	} else if (tmp_5 <= 0.0) {
		double tmp_6;
		if (b >= 0.0) {
			tmp_6 = -2.0 * (c / (2.0 * (b - (c / (b / a)))));
		} else {
			tmp_6 = (2.0 * (((c * a) / b) - b)) / (2.0 * a);
		}
		tmp = tmp_6;
	double tmp_7;
	if (b >= 0.0) {
		tmp_7 = (2.0 * c) / (-b - sqrt((b * b) - (c * (4.0 * a))));
	} else {
		tmp_7 = (sqrt((b * b) - (c * (4.0 * a))) - b) / (2.0 * a);
	}
	} else if (tmp_7 <= 1.1144892510332327e+221) {
		double tmp_8;
		if (b >= 0.0) {
			tmp_8 = (2.0 * c) / (-b - sqrt((b * b) - (c * (4.0 * a))));
		} else {
			tmp_8 = (sqrt((b * b) - (c * (4.0 * a))) - b) / (2.0 * a);
		}
		tmp = tmp_8;
	} else if (b >= 0.0) {
		tmp = -2.0 * (0.5 * (c / b));
	} else {
		tmp = (c / b) - (b / a);
	}
	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

Alternatives

Alternative 1
Error6.5
Cost8323
\[\begin{array}{l} \mathbf{if}\;b \leq -2.722545686769443 \cdot 10^{+105}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\\ \mathbf{elif}\;b \leq 8.621300584337685 \cdot 10^{+126}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c}{\frac{b}{a}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\]
Alternative 2
Error6.6
Cost8644
\[\begin{array}{l} \mathbf{if}\;b \leq -4.945406241679591 \cdot 10^{+107}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\\ \mathbf{elif}\;b \leq 2.8876228352283496 \cdot 10^{-305}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 2.971848196543166 \cdot 10^{+127}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)}}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c}{\frac{b}{a}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\]
Alternative 3
Error6.5
Cost8644
\[\begin{array}{l} \mathbf{if}\;b \leq -9.737737070630436 \cdot 10^{+105}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\\ \mathbf{elif}\;b \leq -5.71767290532408 \cdot 10^{-288}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \frac{c \cdot a}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 8.42048681559436 \cdot 10^{+126}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)}}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c}{\frac{b}{a}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\]
Alternative 4
Error11.0
Cost8965
\[\begin{array}{l} \mathbf{if}\;b \leq -6.72133216817676 \cdot 10^{+31}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \left(\frac{b}{a} \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{elif}\;b \leq -205.80431908938797:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)}}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq -1.0759145171596486 \cdot 10^{-123}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\\ \mathbf{elif}\;b \leq 1.0227810734284296 \cdot 10^{+127}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)}}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c}{\frac{b}{a}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\]
Alternative 5
Error17.4
Cost8067
\[\begin{array}{l} \mathbf{if}\;b \leq 2.8876228352283496 \cdot 10^{-305}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\\ \mathbf{elif}\;b \leq 5.7638403936058 \cdot 10^{-95}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{b + \sqrt{c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c}{\frac{b}{a}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\]
Alternative 6
Error17.7
Cost7939
\[\begin{array}{l} \mathbf{if}\;b \leq 2.8876228352283496 \cdot 10^{-305}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\\ \mathbf{elif}\;b \leq 3.670653900529757 \cdot 10^{-104}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{\sqrt{c \cdot \left(a \cdot -4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c}{\frac{b}{a}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\]
Alternative 7
Error22.3
Cost1153
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c}{\frac{b}{a}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]
Alternative 8
Error22.5
Cost769
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]
Alternative 9
Error22.5
Cost769
\[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \left(0.5 \cdot \frac{c}{b}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]
Alternative 10
Error38.7
Cost1090
\[\begin{array}{l} \mathbf{if}\;b \leq 1.6674147068593327 \cdot 10^{-25}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \left(\frac{b}{a} \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 11
Error56.2
Cost64
\[0\]
Alternative 12
Error61.6
Cost64
\[1\]

Error

Time

Derivation

  1. Split input into 4 regimes
  2. if (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < -inf.0

    1. Initial program 64.0

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{\color{blue}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\]
    7. Taylor expanded around 0 17.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{b}{a}\\ \end{array}\]
    8. Simplified17.6

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

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

    if -inf.0 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < -2.90561638465e-314 or -0.0 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < 1.11448925103323265e221

    1. Initial program 2.6

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

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

    if -2.90561638465e-314 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < -0.0

    1. Initial program 37.3

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{\color{blue}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\]
    7. Using strategy rm
    8. Applied associate-/l*_binary6410.6

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

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

    if 1.11448925103323265e221 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)))

    1. Initial program 49.7

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{\color{blue}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\]
    7. Taylor expanded around 0 18.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-2 \cdot \frac{c}{2 \cdot \left(b - \frac{c \cdot a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]
    8. Taylor expanded around 0 14.3

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

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

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

Reproduce

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