jeff quadratic root 2

Percentage Accurate: 72.3% → 90.7%
Time: 31.6s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\ \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c)))))
   (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - t_0);
	} else {
		tmp = (-b + t_0) / (2.0 * a);
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
    if (b >= 0.0d0) then
        tmp = (2.0d0 * c) / (-b - t_0)
    else
        tmp = (-b + t_0) / (2.0d0 * a)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - t_0);
	} else {
		tmp = (-b + t_0) / (2.0 * a);
	}
	return tmp;
}
def code(a, b, c):
	t_0 = math.sqrt(((b * b) - ((4.0 * a) * c)))
	tmp = 0
	if b >= 0.0:
		tmp = (2.0 * c) / (-b - t_0)
	else:
		tmp = (-b + t_0) / (2.0 * a)
	return tmp
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0));
	else
		tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
	tmp = 0.0;
	if (b >= 0.0)
		tmp = (2.0 * c) / (-b - t_0);
	else
		tmp = (-b + t_0) / (2.0 * a);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 72.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\ \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c)))))
   (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - t_0);
	} else {
		tmp = (-b + t_0) / (2.0 * a);
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
    if (b >= 0.0d0) then
        tmp = (2.0d0 * c) / (-b - t_0)
    else
        tmp = (-b + t_0) / (2.0d0 * a)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - t_0);
	} else {
		tmp = (-b + t_0) / (2.0 * a);
	}
	return tmp;
}
def code(a, b, c):
	t_0 = math.sqrt(((b * b) - ((4.0 * a) * c)))
	tmp = 0
	if b >= 0.0:
		tmp = (2.0 * c) / (-b - t_0)
	else:
		tmp = (-b + t_0) / (2.0 * a)
	return tmp
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0));
	else
		tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
	tmp = 0.0;
	if (b >= 0.0)
		tmp = (2.0 * c) / (-b - t_0);
	else
		tmp = (-b + t_0) / (2.0 * a);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}

Alternative 1: 90.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\ \mathbf{if}\;b \leq -1.85 \cdot 10^{+152}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot -2\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 10^{+111}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
   (if (<= b -1.85e+152)
     (if (>= b 0.0) (* c -2.0) (/ (+ b b) (* -2.0 a)))
     (if (<= b 1e+111)
       (if (>= b 0.0) (/ (* c 2.0) (- (- b) t_0)) (/ (- t_0 b) (* a 2.0)))
       (if (>= b 0.0)
         (/ (* c 2.0) (* 2.0 (fma a (/ c b) (- b))))
         (* b (+ (/ c (pow b 2.0)) (/ -1.0 a))))))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	double tmp_1;
	if (b <= -1.85e+152) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = c * -2.0;
		} else {
			tmp_2 = (b + b) / (-2.0 * a);
		}
		tmp_1 = tmp_2;
	} else if (b <= 1e+111) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = (c * 2.0) / (-b - t_0);
		} else {
			tmp_3 = (t_0 - b) / (a * 2.0);
		}
		tmp_1 = tmp_3;
	} else if (b >= 0.0) {
		tmp_1 = (c * 2.0) / (2.0 * fma(a, (c / b), -b));
	} else {
		tmp_1 = b * ((c / pow(b, 2.0)) + (-1.0 / a));
	}
	return tmp_1;
}
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0))))
	tmp_1 = 0.0
	if (b <= -1.85e+152)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(c * -2.0);
		else
			tmp_2 = Float64(Float64(b + b) / Float64(-2.0 * a));
		end
		tmp_1 = tmp_2;
	elseif (b <= 1e+111)
		tmp_3 = 0.0
		if (b >= 0.0)
			tmp_3 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_0));
		else
			tmp_3 = Float64(Float64(t_0 - b) / Float64(a * 2.0));
		end
		tmp_1 = tmp_3;
	elseif (b >= 0.0)
		tmp_1 = Float64(Float64(c * 2.0) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b))));
	else
		tmp_1 = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a)));
	end
	return tmp_1
end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1.85e+152], If[GreaterEqual[b, 0.0], N[(c * -2.0), $MachinePrecision], N[(N[(b + b), $MachinePrecision] / N[(-2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1e+111], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -1.85 \cdot 10^{+152}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot -2\\

\mathbf{else}:\\
\;\;\;\;\frac{b + b}{-2 \cdot a}\\


\end{array}\\

\mathbf{elif}\;b \leq 10^{+111}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\


\end{array}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -1.84999999999999998e152

    1. Initial program 35.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. Simplified35.9%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \color{blue}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    6. Step-by-step derivation
      1. associate-*r/98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c \cdot -2}{b + b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      2. flip-+98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\color{blue}{\frac{b \cdot b - b \cdot b}{b - b}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      3. +-inverses98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\frac{\color{blue}{0}}{b - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      4. +-inverses98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\frac{0}{\color{blue}{0}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    7. Applied egg-rr98.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c \cdot -2}{\frac{0}{0}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    8. Simplified98.2%

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

    if -1.84999999999999998e152 < b < 9.99999999999999957e110

    1. Initial program 85.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. Add Preprocessing

    if 9.99999999999999957e110 < b

    1. Initial program 44.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. Add Preprocessing
    3. Taylor expanded in a around 0 85.0%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    4. Step-by-step derivation
      1. distribute-lft-out--85.0%

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \left(b \cdot \left(-1 \cdot \frac{c}{{b}^{2}} + \frac{1}{a}\right)\right)\\ \end{array} \]
    7. Step-by-step derivation
      1. associate-*r*95.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(-1 \cdot b\right) \cdot \left(-1 \cdot \frac{c}{{b}^{2}} + \frac{1}{a}\right)\\ \end{array} \]
      2. mul-1-neg95.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(-b\right) \cdot \left(-1 \cdot \frac{c}{{b}^{2}} + \frac{1}{a}\right)\\ \end{array} \]
      3. +-commutative95.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;\color{blue}{\left(-b\right) \cdot \left(\frac{1}{a} + -1 \cdot \frac{c}{{b}^{2}}\right)}\\ \end{array} \]
      4. mul-1-neg95.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(-b\right) \cdot \color{blue}{\left(\frac{1}{a} + \left(-\frac{c}{{b}^{2}}\right)\right)}\\ \end{array} \]
      5. unsub-neg95.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;\color{blue}{\left(-b\right) \cdot \left(\frac{1}{a} - \frac{c}{{b}^{2}}\right)}\\ \end{array} \]
    8. Simplified95.9%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(-b\right) \cdot \left(\frac{1}{a} - \frac{c}{{b}^{2}}\right)\\ \end{array} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification89.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.85 \cdot 10^{+152}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot -2\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 10^{+111}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 79.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b + b}{-2 \cdot a}\\ \mathbf{if}\;b \leq -1 \cdot 10^{+154}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot -2\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array}\\ \mathbf{elif}\;b \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{2} \cdot \frac{2}{\mathsf{fma}\left(a, \frac{c}{b}, b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{\frac{c}{b + \mathsf{fma}\left(-2, c \cdot \frac{a}{b}, b\right)}}{-0.5}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (/ (+ b b) (* -2.0 a))))
   (if (<= b -1e+154)
     (if (>= b 0.0) (* c -2.0) t_0)
     (if (<= b -4e-310)
       (if (>= b 0.0)
         (* (/ c 2.0) (/ 2.0 (fma a (/ c b) b)))
         (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))
       (if (>= b 0.0) (/ (/ c (+ b (fma -2.0 (* c (/ a b)) b))) -0.5) t_0)))))
double code(double a, double b, double c) {
	double t_0 = (b + b) / (-2.0 * a);
	double tmp_1;
	if (b <= -1e+154) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = c * -2.0;
		} else {
			tmp_2 = t_0;
		}
		tmp_1 = tmp_2;
	} else if (b <= -4e-310) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = (c / 2.0) * (2.0 / fma(a, (c / b), b));
		} else {
			tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
		}
		tmp_1 = tmp_3;
	} else if (b >= 0.0) {
		tmp_1 = (c / (b + fma(-2.0, (c * (a / b)), b))) / -0.5;
	} else {
		tmp_1 = t_0;
	}
	return tmp_1;
}
function code(a, b, c)
	t_0 = Float64(Float64(b + b) / Float64(-2.0 * a))
	tmp_1 = 0.0
	if (b <= -1e+154)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(c * -2.0);
		else
			tmp_2 = t_0;
		end
		tmp_1 = tmp_2;
	elseif (b <= -4e-310)
		tmp_3 = 0.0
		if (b >= 0.0)
			tmp_3 = Float64(Float64(c / 2.0) * Float64(2.0 / fma(a, Float64(c / b), b)));
		else
			tmp_3 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0));
		end
		tmp_1 = tmp_3;
	elseif (b >= 0.0)
		tmp_1 = Float64(Float64(c / Float64(b + fma(-2.0, Float64(c * Float64(a / b)), b))) / -0.5);
	else
		tmp_1 = t_0;
	end
	return tmp_1
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(b + b), $MachinePrecision] / N[(-2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1e+154], If[GreaterEqual[b, 0.0], N[(c * -2.0), $MachinePrecision], t$95$0], If[LessEqual[b, -4e-310], If[GreaterEqual[b, 0.0], N[(N[(c / 2.0), $MachinePrecision] * N[(2.0 / N[(a * N[(c / b), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / N[(b + N[(-2.0 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -0.5), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{b + b}{-2 \cdot a}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+154}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot -2\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}\\

\mathbf{elif}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{2} \cdot \frac{2}{\mathsf{fma}\left(a, \frac{c}{b}, b\right)}\\

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


\end{array}\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -1.00000000000000004e154

    1. Initial program 35.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. Simplified35.9%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \color{blue}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    6. Step-by-step derivation
      1. associate-*r/98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c \cdot -2}{b + b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      2. flip-+98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\color{blue}{\frac{b \cdot b - b \cdot b}{b - b}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      3. +-inverses98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\frac{\color{blue}{0}}{b - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      4. +-inverses98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\frac{0}{\color{blue}{0}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    7. Applied egg-rr98.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c \cdot -2}{\frac{0}{0}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    8. Simplified98.2%

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

    if -1.00000000000000004e154 < b < -3.999999999999988e-310

    1. Initial program 92.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. Add Preprocessing
    3. Taylor expanded in a around 0 92.3%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    4. Step-by-step derivation
      1. distribute-lft-out--92.3%

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    6. Step-by-step derivation
      1. *-commutative92.3%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c}{2} \cdot \frac{2}{\mathsf{fma}\left(a, \frac{c}{b}, -b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      3. add-sqr-sqrt92.3%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{2} \cdot \frac{2}{\mathsf{fma}\left(a, \frac{c}{b}, \color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      5. sqr-neg92.3%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{2} \cdot \frac{2}{\mathsf{fma}\left(a, \frac{c}{b}, \color{blue}{\sqrt{b} \cdot \sqrt{b}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      7. add-sqr-sqrt92.3%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{2} \cdot \frac{2}{\mathsf{fma}\left(a, \frac{c}{b}, \color{blue}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    7. Applied egg-rr92.3%

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

    if -3.999999999999988e-310 < b

    1. Initial program 65.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. Simplified65.0%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \color{blue}{\left(b + -2 \cdot \frac{a \cdot c}{b}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    6. Step-by-step derivation
      1. associate-/l*58.7%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \color{blue}{\left(b + -2 \cdot \left(a \cdot \frac{c}{b}\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    8. Step-by-step derivation
      1. clear-num58.7%

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{\left(b + \color{blue}{\mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)}\right) \cdot \frac{1}{-2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      6. clear-num59.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{\left(b + \mathsf{fma}\left(-2, a \cdot \color{blue}{\frac{1}{\frac{b}{c}}}, b\right)\right) \cdot \frac{1}{-2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      7. un-div-inv59.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{\left(b + \mathsf{fma}\left(-2, \color{blue}{\frac{a}{\frac{b}{c}}}, b\right)\right) \cdot \frac{1}{-2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      8. metadata-eval59.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{\left(b + \mathsf{fma}\left(-2, \frac{a}{\frac{b}{c}}, b\right)\right) \cdot \color{blue}{-0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    9. Applied egg-rr59.0%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c}{\left(b + \mathsf{fma}\left(-2, \frac{a}{\frac{b}{c}}, b\right)\right) \cdot -0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    10. Step-by-step derivation
      1. associate-/r*59.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{\frac{c}{b + \mathsf{fma}\left(-2, \frac{a}{\frac{b}{c}}, b\right)}}{-0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      2. associate-/r/59.1%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\frac{c}{b + \mathsf{fma}\left(-2, \color{blue}{\frac{a}{b} \cdot c}, b\right)}}{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      3. *-commutative59.1%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\frac{c}{b + \mathsf{fma}\left(-2, \color{blue}{c \cdot \frac{a}{b}}, b\right)}}{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    11. Simplified59.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{+154}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot -2\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{2} \cdot \frac{2}{\mathsf{fma}\left(a, \frac{c}{b}, b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{\frac{c}{b + \mathsf{fma}\left(-2, c \cdot \frac{a}{b}, b\right)}}{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 78.9% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b + b}{-2 \cdot a}\\ \mathbf{if}\;b \leq -9.1 \cdot 10^{+151}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot -2\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array}\\ \mathbf{elif}\;b \leq 10^{-189}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{\frac{c}{b + \mathsf{fma}\left(-2, c \cdot \frac{a}{b}, b\right)}}{-0.5}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (/ (+ b b) (* -2.0 a))))
   (if (<= b -9.1e+151)
     (if (>= b 0.0) (* c -2.0) t_0)
     (if (<= b 1e-189)
       (if (>= b 0.0)
         (/ b a)
         (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))
       (if (>= b 0.0) (/ (/ c (+ b (fma -2.0 (* c (/ a b)) b))) -0.5) t_0)))))
double code(double a, double b, double c) {
	double t_0 = (b + b) / (-2.0 * a);
	double tmp_1;
	if (b <= -9.1e+151) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = c * -2.0;
		} else {
			tmp_2 = t_0;
		}
		tmp_1 = tmp_2;
	} else if (b <= 1e-189) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = b / a;
		} else {
			tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
		}
		tmp_1 = tmp_3;
	} else if (b >= 0.0) {
		tmp_1 = (c / (b + fma(-2.0, (c * (a / b)), b))) / -0.5;
	} else {
		tmp_1 = t_0;
	}
	return tmp_1;
}
function code(a, b, c)
	t_0 = Float64(Float64(b + b) / Float64(-2.0 * a))
	tmp_1 = 0.0
	if (b <= -9.1e+151)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(c * -2.0);
		else
			tmp_2 = t_0;
		end
		tmp_1 = tmp_2;
	elseif (b <= 1e-189)
		tmp_3 = 0.0
		if (b >= 0.0)
			tmp_3 = Float64(b / a);
		else
			tmp_3 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0));
		end
		tmp_1 = tmp_3;
	elseif (b >= 0.0)
		tmp_1 = Float64(Float64(c / Float64(b + fma(-2.0, Float64(c * Float64(a / b)), b))) / -0.5);
	else
		tmp_1 = t_0;
	end
	return tmp_1
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(b + b), $MachinePrecision] / N[(-2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -9.1e+151], If[GreaterEqual[b, 0.0], N[(c * -2.0), $MachinePrecision], t$95$0], If[LessEqual[b, 1e-189], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / N[(b + N[(-2.0 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -0.5), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{b + b}{-2 \cdot a}\\
\mathbf{if}\;b \leq -9.1 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot -2\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}\\

\mathbf{elif}\;b \leq 10^{-189}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\

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


\end{array}\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -9.10000000000000003e151

    1. Initial program 35.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. Simplified35.9%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \color{blue}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    6. Step-by-step derivation
      1. associate-*r/98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c \cdot -2}{b + b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      2. flip-+98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\color{blue}{\frac{b \cdot b - b \cdot b}{b - b}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      3. +-inverses98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\frac{\color{blue}{0}}{b - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      4. +-inverses98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\frac{0}{\color{blue}{0}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    7. Applied egg-rr98.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c \cdot -2}{\frac{0}{0}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    8. Simplified98.2%

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

    if -9.10000000000000003e151 < b < 1.00000000000000007e-189

    1. Initial program 88.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. Add Preprocessing
    3. Taylor expanded in a around 0 77.3%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    4. Step-by-step derivation
      1. distribute-lft-out--77.3%

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

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

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

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

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

    if 1.00000000000000007e-189 < b

    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. Simplified63.9%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \color{blue}{\left(b + -2 \cdot \frac{a \cdot c}{b}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    6. Step-by-step derivation
      1. associate-/l*67.6%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \color{blue}{\left(b + -2 \cdot \left(a \cdot \frac{c}{b}\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    8. Step-by-step derivation
      1. clear-num67.6%

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{\left(b + \color{blue}{\mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)}\right) \cdot \frac{1}{-2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      6. clear-num67.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{\left(b + \mathsf{fma}\left(-2, a \cdot \color{blue}{\frac{1}{\frac{b}{c}}}, b\right)\right) \cdot \frac{1}{-2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      7. un-div-inv67.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{\left(b + \mathsf{fma}\left(-2, \color{blue}{\frac{a}{\frac{b}{c}}}, b\right)\right) \cdot \frac{1}{-2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      8. metadata-eval67.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{\left(b + \mathsf{fma}\left(-2, \frac{a}{\frac{b}{c}}, b\right)\right) \cdot \color{blue}{-0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    9. Applied egg-rr67.9%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c}{\left(b + \mathsf{fma}\left(-2, \frac{a}{\frac{b}{c}}, b\right)\right) \cdot -0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    10. Step-by-step derivation
      1. associate-/r*67.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{\frac{c}{b + \mathsf{fma}\left(-2, \frac{a}{\frac{b}{c}}, b\right)}}{-0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      2. associate-/r/68.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\frac{c}{b + \mathsf{fma}\left(-2, \color{blue}{\frac{a}{b} \cdot c}, b\right)}}{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      3. *-commutative68.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\frac{c}{b + \mathsf{fma}\left(-2, \color{blue}{c \cdot \frac{a}{b}}, b\right)}}{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    11. Simplified68.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -9.1 \cdot 10^{+151}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot -2\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 10^{-189}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{\frac{c}{b + \mathsf{fma}\left(-2, c \cdot \frac{a}{b}, b\right)}}{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 79.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -8.1 \cdot 10^{+152}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot -2\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -8.1e+152)
   (if (>= b 0.0) (* c -2.0) (/ (+ b b) (* -2.0 a)))
   (if (>= b 0.0)
     (/ (* c 2.0) (* 2.0 (fma a (/ c b) (- b))))
     (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))))
double code(double a, double b, double c) {
	double tmp_1;
	if (b <= -8.1e+152) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = c * -2.0;
		} else {
			tmp_2 = (b + b) / (-2.0 * a);
		}
		tmp_1 = tmp_2;
	} else if (b >= 0.0) {
		tmp_1 = (c * 2.0) / (2.0 * fma(a, (c / b), -b));
	} else {
		tmp_1 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
	}
	return tmp_1;
}
function code(a, b, c)
	tmp_1 = 0.0
	if (b <= -8.1e+152)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(c * -2.0);
		else
			tmp_2 = Float64(Float64(b + b) / Float64(-2.0 * a));
		end
		tmp_1 = tmp_2;
	elseif (b >= 0.0)
		tmp_1 = Float64(Float64(c * 2.0) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b))));
	else
		tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0));
	end
	return tmp_1
end
code[a_, b_, c_] := If[LessEqual[b, -8.1e+152], If[GreaterEqual[b, 0.0], N[(c * -2.0), $MachinePrecision], N[(N[(b + b), $MachinePrecision] / N[(-2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.1 \cdot 10^{+152}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot -2\\

\mathbf{else}:\\
\;\;\;\;\frac{b + b}{-2 \cdot a}\\


\end{array}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -8.09999999999999998e152

    1. Initial program 35.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. Simplified35.9%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \color{blue}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    6. Step-by-step derivation
      1. associate-*r/98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c \cdot -2}{b + b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      2. flip-+98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\color{blue}{\frac{b \cdot b - b \cdot b}{b - b}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      3. +-inverses98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\frac{\color{blue}{0}}{b - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
      4. +-inverses98.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\frac{0}{\color{blue}{0}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    7. Applied egg-rr98.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c \cdot -2}{\frac{0}{0}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    8. Simplified98.2%

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

    if -8.09999999999999998e152 < b

    1. Initial program 76.1%

      \[\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. Add Preprocessing
    3. Taylor expanded in a around 0 70.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    4. Step-by-step derivation
      1. distribute-lft-out--70.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -8.1 \cdot 10^{+152}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot -2\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 67.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\frac{c}{b + \mathsf{fma}\left(-2, c \cdot \frac{a}{b}, b\right)}}{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (>= b 0.0)
   (/ (/ c (+ b (fma -2.0 (* c (/ a b)) b))) -0.5)
   (/ (+ b b) (* -2.0 a))))
double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = (c / (b + fma(-2.0, (c * (a / b)), b))) / -0.5;
	} else {
		tmp = (b + b) / (-2.0 * a);
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(c / Float64(b + fma(-2.0, Float64(c * Float64(a / b)), b))) / -0.5);
	else
		tmp = Float64(Float64(b + b) / Float64(-2.0 * a));
	end
	return tmp
end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(c / N[(b + N[(-2.0 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -0.5), $MachinePrecision], N[(N[(b + b), $MachinePrecision] / N[(-2.0 * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\frac{c}{b + \mathsf{fma}\left(-2, c \cdot \frac{a}{b}, b\right)}}{-0.5}\\

\mathbf{else}:\\
\;\;\;\;\frac{b + b}{-2 \cdot a}\\


\end{array}
\end{array}
Derivation
  1. Initial program 67.9%

    \[\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. Simplified67.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \color{blue}{\left(b + -2 \cdot \frac{a \cdot c}{b}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  6. Step-by-step derivation
    1. associate-/l*68.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \color{blue}{\left(b + -2 \cdot \left(a \cdot \frac{c}{b}\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  8. Step-by-step derivation
    1. clear-num68.5%

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{\left(b + \color{blue}{\mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)}\right) \cdot \frac{1}{-2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    6. clear-num68.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{\left(b + \mathsf{fma}\left(-2, a \cdot \color{blue}{\frac{1}{\frac{b}{c}}}, b\right)\right) \cdot \frac{1}{-2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    7. un-div-inv68.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{\left(b + \mathsf{fma}\left(-2, \color{blue}{\frac{a}{\frac{b}{c}}}, b\right)\right) \cdot \frac{1}{-2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    8. metadata-eval68.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{\left(b + \mathsf{fma}\left(-2, \frac{a}{\frac{b}{c}}, b\right)\right) \cdot \color{blue}{-0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  9. Applied egg-rr68.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c}{\left(b + \mathsf{fma}\left(-2, \frac{a}{\frac{b}{c}}, b\right)\right) \cdot -0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  10. Step-by-step derivation
    1. associate-/r*68.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{\frac{c}{b + \mathsf{fma}\left(-2, \frac{a}{\frac{b}{c}}, b\right)}}{-0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    2. associate-/r/68.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\frac{c}{b + \mathsf{fma}\left(-2, \color{blue}{\frac{a}{b} \cdot c}, b\right)}}{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    3. *-commutative68.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\frac{c}{b + \mathsf{fma}\left(-2, \color{blue}{c \cdot \frac{a}{b}}, b\right)}}{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  11. Simplified68.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{\frac{c}{b + \mathsf{fma}\left(-2, c \cdot \frac{a}{b}, b\right)}}{-0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  12. Final simplification68.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\frac{c}{b + \mathsf{fma}\left(-2, c \cdot \frac{a}{b}, b\right)}}{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array} \]
  13. Add Preprocessing

Alternative 6: 36.4% accurate, 10.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot -2\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (>= b 0.0) (* c -2.0) (/ (+ b b) (* -2.0 a))))
double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = c * -2.0;
	} else {
		tmp = (b + b) / (-2.0 * a);
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b >= 0.0d0) then
        tmp = c * (-2.0d0)
    else
        tmp = (b + b) / ((-2.0d0) * a)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = c * -2.0;
	} else {
		tmp = (b + b) / (-2.0 * a);
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b >= 0.0:
		tmp = c * -2.0
	else:
		tmp = (b + b) / (-2.0 * a)
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(c * -2.0);
	else
		tmp = Float64(Float64(b + b) / Float64(-2.0 * a));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b >= 0.0)
		tmp = c * -2.0;
	else
		tmp = (b + b) / (-2.0 * a);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c * -2.0), $MachinePrecision], N[(N[(b + b), $MachinePrecision] / N[(-2.0 * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot -2\\

\mathbf{else}:\\
\;\;\;\;\frac{b + b}{-2 \cdot a}\\


\end{array}
\end{array}
Derivation
  1. Initial program 67.9%

    \[\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. Simplified67.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \color{blue}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  6. Step-by-step derivation
    1. associate-*r/68.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c \cdot -2}{b + b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    2. flip-+40.8%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\color{blue}{\frac{b \cdot b - b \cdot b}{b - b}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    3. +-inverses40.8%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\frac{\color{blue}{0}}{b - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    4. +-inverses40.8%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c \cdot -2}{\frac{0}{\color{blue}{0}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  7. Applied egg-rr40.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{c \cdot -2}{\frac{0}{0}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  8. Simplified43.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{c \cdot -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  9. Final simplification43.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot -2\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array} \]
  10. Add Preprocessing

Alternative 7: 67.4% accurate, 10.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (>= b 0.0) (* c (/ -2.0 (+ b b))) (/ (+ b b) (* -2.0 a))))
double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = c * (-2.0 / (b + b));
	} else {
		tmp = (b + b) / (-2.0 * a);
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b >= 0.0d0) then
        tmp = c * ((-2.0d0) / (b + b))
    else
        tmp = (b + b) / ((-2.0d0) * a)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = c * (-2.0 / (b + b));
	} else {
		tmp = (b + b) / (-2.0 * a);
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b >= 0.0:
		tmp = c * (-2.0 / (b + b))
	else:
		tmp = (b + b) / (-2.0 * a)
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(c * Float64(-2.0 / Float64(b + b)));
	else
		tmp = Float64(Float64(b + b) / Float64(-2.0 * a));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b >= 0.0)
		tmp = c * (-2.0 / (b + b));
	else
		tmp = (b + b) / (-2.0 * a);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + b), $MachinePrecision] / N[(-2.0 * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\

\mathbf{else}:\\
\;\;\;\;\frac{b + b}{-2 \cdot a}\\


\end{array}
\end{array}
Derivation
  1. Initial program 67.9%

    \[\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. Simplified67.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + \color{blue}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  6. Final simplification68.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;c \cdot \frac{-2}{b + b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array} \]
  7. Add Preprocessing

Alternative 8: 67.5% accurate, 10.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{-b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (>= b 0.0) (/ c (- b)) (/ (+ b b) (* -2.0 a))))
double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = c / -b;
	} else {
		tmp = (b + b) / (-2.0 * a);
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b >= 0.0d0) then
        tmp = c / -b
    else
        tmp = (b + b) / ((-2.0d0) * a)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = c / -b;
	} else {
		tmp = (b + b) / (-2.0 * a);
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b >= 0.0:
		tmp = c / -b
	else:
		tmp = (b + b) / (-2.0 * a)
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(c / Float64(-b));
	else
		tmp = Float64(Float64(b + b) / Float64(-2.0 * a));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b >= 0.0)
		tmp = c / -b;
	else
		tmp = (b + b) / (-2.0 * a);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(N[(b + b), $MachinePrecision] / N[(-2.0 * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\

\mathbf{else}:\\
\;\;\;\;\frac{b + b}{-2 \cdot a}\\


\end{array}
\end{array}
Derivation
  1. Initial program 67.9%

    \[\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. Simplified67.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{-1 \cdot \frac{c}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  6. Step-by-step derivation
    1. associate-*r/68.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{-1 \cdot c}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
    2. mul-1-neg68.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\color{blue}{-c}}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  7. Simplified68.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{-c}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - -1 \cdot b}{a \cdot -2}\\ \end{array} \]
  8. Final simplification68.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{c}{-b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + b}{-2 \cdot a}\\ \end{array} \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2024060 
(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))))