jeff quadratic root 1

Percentage Accurate: 71.8% → 76.9%
Time: 29.8s
Alternatives: 17
Speedup: 0.6×

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{\left(-b\right) - t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t\_0}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c)))))
   (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))))
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 = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (-b + t_0);
	}
	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 = (-b - t_0) / (2.0d0 * a)
    else
        tmp = (2.0d0 * c) / (-b + t_0)
    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 = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (-b + t_0);
	}
	return tmp;
}
def code(a, b, c):
	t_0 = math.sqrt(((b * b) - ((4.0 * a) * c)))
	tmp = 0
	if b >= 0.0:
		tmp = (-b - t_0) / (2.0 * a)
	else:
		tmp = (2.0 * c) / (-b + t_0)
	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(Float64(-b) - t_0) / Float64(2.0 * a));
	else
		tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0));
	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 = (-b - t_0) / (2.0 * a);
	else
		tmp = (2.0 * c) / (-b + t_0);
	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[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $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{\left(-b\right) - t\_0}{2 \cdot a}\\

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


\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 17 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: 71.8% 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{\left(-b\right) - t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t\_0}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c)))))
   (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))))
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 = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (-b + t_0);
	}
	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 = (-b - t_0) / (2.0d0 * a)
    else
        tmp = (2.0d0 * c) / (-b + t_0)
    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 = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (-b + t_0);
	}
	return tmp;
}
def code(a, b, c):
	t_0 = math.sqrt(((b * b) - ((4.0 * a) * c)))
	tmp = 0
	if b >= 0.0:
		tmp = (-b - t_0) / (2.0 * a)
	else:
		tmp = (2.0 * c) / (-b + t_0)
	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(Float64(-b) - t_0) / Float64(2.0 * a));
	else
		tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0));
	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 = (-b - t_0) / (2.0 * a);
	else
		tmp = (2.0 * c) / (-b + t_0);
	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[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $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{\left(-b\right) - t\_0}{2 \cdot a}\\

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


\end{array}
\end{array}

Alternative 1: 76.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\ t_1 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\ \end{array}\\ \mathbf{if}\;t\_1 \leq 5 \cdot 10^{+238}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{-2}{b \cdot \left(2 + -2 \cdot \left(a \cdot \frac{c}{{b}^{2}}\right)\right)}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
        (t_1
         (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))))
   (if (<= t_1 5e+238)
     t_1
     (if (>= b 0.0)
       (* -0.5 (/ (+ b b) a))
       (* c (/ (- 2.0) (* b (+ 2.0 (* -2.0 (* a (/ c (pow b 2.0))))))))))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	double tmp;
	if (b >= 0.0) {
		tmp = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (t_0 - b);
	}
	double t_1 = tmp;
	double tmp_1;
	if (t_1 <= 5e+238) {
		tmp_1 = t_1;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * ((b + b) / a);
	} else {
		tmp_1 = c * (-2.0 / (b * (2.0 + (-2.0 * (a * (c / pow(b, 2.0)))))));
	}
	return tmp_1;
}
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) :: t_1
    real(8) :: tmp
    real(8) :: tmp_1
    t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
    if (b >= 0.0d0) then
        tmp = (-b - t_0) / (2.0d0 * a)
    else
        tmp = (2.0d0 * c) / (t_0 - b)
    end if
    t_1 = tmp
    if (t_1 <= 5d+238) then
        tmp_1 = t_1
    else if (b >= 0.0d0) then
        tmp_1 = (-0.5d0) * ((b + b) / a)
    else
        tmp_1 = c * (-2.0d0 / (b * (2.0d0 + ((-2.0d0) * (a * (c / (b ** 2.0d0)))))))
    end if
    code = tmp_1
end function
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
	double tmp;
	if (b >= 0.0) {
		tmp = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (t_0 - b);
	}
	double t_1 = tmp;
	double tmp_1;
	if (t_1 <= 5e+238) {
		tmp_1 = t_1;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * ((b + b) / a);
	} else {
		tmp_1 = c * (-2.0 / (b * (2.0 + (-2.0 * (a * (c / Math.pow(b, 2.0)))))));
	}
	return tmp_1;
}
def code(a, b, c):
	t_0 = math.sqrt(((b * b) - (c * (a * 4.0))))
	tmp = 0
	if b >= 0.0:
		tmp = (-b - t_0) / (2.0 * a)
	else:
		tmp = (2.0 * c) / (t_0 - b)
	t_1 = tmp
	tmp_1 = 0
	if t_1 <= 5e+238:
		tmp_1 = t_1
	elif b >= 0.0:
		tmp_1 = -0.5 * ((b + b) / a)
	else:
		tmp_1 = c * (-2.0 / (b * (2.0 + (-2.0 * (a * (c / math.pow(b, 2.0)))))))
	return tmp_1
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0))))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a));
	else
		tmp = Float64(Float64(2.0 * c) / Float64(t_0 - b));
	end
	t_1 = tmp
	tmp_1 = 0.0
	if (t_1 <= 5e+238)
		tmp_1 = t_1;
	elseif (b >= 0.0)
		tmp_1 = Float64(-0.5 * Float64(Float64(b + b) / a));
	else
		tmp_1 = Float64(c * Float64(Float64(-2.0) / Float64(b * Float64(2.0 + Float64(-2.0 * Float64(a * Float64(c / (b ^ 2.0))))))));
	end
	return tmp_1
end
function tmp_3 = code(a, b, c)
	t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	tmp = 0.0;
	if (b >= 0.0)
		tmp = (-b - t_0) / (2.0 * a);
	else
		tmp = (2.0 * c) / (t_0 - b);
	end
	t_1 = tmp;
	tmp_2 = 0.0;
	if (t_1 <= 5e+238)
		tmp_2 = t_1;
	elseif (b >= 0.0)
		tmp_2 = -0.5 * ((b + b) / a);
	else
		tmp_2 = c * (-2.0 / (b * (2.0 + (-2.0 * (a * (c / (b ^ 2.0)))))));
	end
	tmp_3 = tmp_2;
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]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$1, 5e+238], t$95$1, If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(c * N[((-2.0) / N[(b * N[(2.0 + N[(-2.0 * N[(a * N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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


\end{array}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+238}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < 4.99999999999999995e238

    1. Initial program 75.7%

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

    if 4.99999999999999995e238 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c))))))

    1. Initial program 38.7%

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

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

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

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

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

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

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

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

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

Alternative 2: 76.3% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-124}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \left(b \cdot \frac{2}{a}\right)\\

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


\end{array}\\

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

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{c} \cdot \left(\frac{2}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, {b}^{2}\right)}} \cdot {\left(\sqrt[3]{c}\right)}^{2}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -5.0000000000000003e-124

    1. Initial program 67.1%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array} \]
    5. Step-by-step derivation
      1. mul-1-neg86.1%

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \color{blue}{\frac{-2 \cdot \frac{a \cdot c}{b} + 2 \cdot b}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    8. Taylor expanded in a around 0 86.1%

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{\color{blue}{b \cdot 2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
      3. associate-*r/86.1%

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

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

    if -5.0000000000000003e-124 < b

    1. Initial program 70.8%

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

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

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

Alternative 3: 76.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\ t_1 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\ \end{array}\\ \mathbf{if}\;t\_1 \leq 5 \cdot 10^{+238}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;{\left(-\sqrt[3]{\frac{c}{b}}\right)}^{3}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
        (t_1
         (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))))
   (if (<= t_1 5e+238)
     t_1
     (if (>= b 0.0) (* -0.5 (/ (+ b b) a)) (pow (- (cbrt (/ c b))) 3.0)))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	double tmp;
	if (b >= 0.0) {
		tmp = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (t_0 - b);
	}
	double t_1 = tmp;
	double tmp_1;
	if (t_1 <= 5e+238) {
		tmp_1 = t_1;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * ((b + b) / a);
	} else {
		tmp_1 = pow(-cbrt((c / b)), 3.0);
	}
	return tmp_1;
}
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
	double tmp;
	if (b >= 0.0) {
		tmp = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (t_0 - b);
	}
	double t_1 = tmp;
	double tmp_1;
	if (t_1 <= 5e+238) {
		tmp_1 = t_1;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * ((b + b) / a);
	} else {
		tmp_1 = Math.pow(-Math.cbrt((c / b)), 3.0);
	}
	return tmp_1;
}
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0))))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a));
	else
		tmp = Float64(Float64(2.0 * c) / Float64(t_0 - b));
	end
	t_1 = tmp
	tmp_1 = 0.0
	if (t_1 <= 5e+238)
		tmp_1 = t_1;
	elseif (b >= 0.0)
		tmp_1 = Float64(-0.5 * Float64(Float64(b + b) / a));
	else
		tmp_1 = Float64(-cbrt(Float64(c / b))) ^ 3.0;
	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]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$1, 5e+238], t$95$1, If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[Power[(-N[Power[N[(c / b), $MachinePrecision], 1/3], $MachinePrecision]), 3.0], $MachinePrecision]]]]]
\begin{array}{l}

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

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


\end{array}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+238}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\

\mathbf{else}:\\
\;\;\;\;{\left(-\sqrt[3]{\frac{c}{b}}\right)}^{3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < 4.99999999999999995e238

    1. Initial program 75.7%

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

    if 4.99999999999999995e238 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c))))))

    1. Initial program 38.7%

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \color{blue}{\frac{2}{b \cdot -2}}\\ \end{array} \]
    8. Step-by-step derivation
      1. add-cube-cbrt88.6%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt[3]{c \cdot \frac{2}{b \cdot -2}}\right)}^{3}\\ \end{array} \]
      3. associate-*r/88.6%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt[3]{\frac{c}{b} \cdot \frac{2}{-2}}\right)}^{3}\\ \end{array} \]
      5. metadata-eval88.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt[3]{\frac{c}{b} \cdot -1}\right)}^{3}\\ \end{array} \]
    9. Applied egg-rr88.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt[3]{\frac{c}{b} \cdot -1}\right)}^{3}\\ \end{array} \]
    10. Taylor expanded in c around -inf 88.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;{\left(-1 \cdot \sqrt[3]{\frac{c}{b}}\right)}^{3}\\ \end{array} \]
    11. Step-by-step derivation
      1. mul-1-neg88.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;{\left(-\sqrt[3]{\frac{c}{b}}\right)}^{3}\\ \end{array} \]
    12. Simplified88.6%

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

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

Alternative 4: 76.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\ t_1 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\ \end{array}\\ \mathbf{if}\;t\_1 \leq 5 \cdot 10^{+238}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{c}{-b}\right)}^{3}}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
        (t_1
         (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))))
   (if (<= t_1 5e+238)
     t_1
     (if (>= b 0.0) (* -0.5 (/ (+ b b) a)) (cbrt (pow (/ c (- b)) 3.0))))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	double tmp;
	if (b >= 0.0) {
		tmp = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (t_0 - b);
	}
	double t_1 = tmp;
	double tmp_1;
	if (t_1 <= 5e+238) {
		tmp_1 = t_1;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * ((b + b) / a);
	} else {
		tmp_1 = cbrt(pow((c / -b), 3.0));
	}
	return tmp_1;
}
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
	double tmp;
	if (b >= 0.0) {
		tmp = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (t_0 - b);
	}
	double t_1 = tmp;
	double tmp_1;
	if (t_1 <= 5e+238) {
		tmp_1 = t_1;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * ((b + b) / a);
	} else {
		tmp_1 = Math.cbrt(Math.pow((c / -b), 3.0));
	}
	return tmp_1;
}
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0))))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a));
	else
		tmp = Float64(Float64(2.0 * c) / Float64(t_0 - b));
	end
	t_1 = tmp
	tmp_1 = 0.0
	if (t_1 <= 5e+238)
		tmp_1 = t_1;
	elseif (b >= 0.0)
		tmp_1 = Float64(-0.5 * Float64(Float64(b + b) / a));
	else
		tmp_1 = cbrt((Float64(c / Float64(-b)) ^ 3.0));
	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]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$1, 5e+238], t$95$1, If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(c / (-b)), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]]]]]
\begin{array}{l}

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

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


\end{array}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+238}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{c}{-b}\right)}^{3}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < 4.99999999999999995e238

    1. Initial program 75.7%

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

    if 4.99999999999999995e238 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c))))))

    1. Initial program 38.7%

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \color{blue}{\frac{2}{b \cdot -2}}\\ \end{array} \]
    8. Step-by-step derivation
      1. add-cbrt-cube86.5%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{{\left(c \cdot \frac{2}{b \cdot -2}\right)}^{3}}\\ \end{array} \]
      3. associate-*r/86.6%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{c}{b} \cdot \frac{2}{-2}\right)}^{3}}\\ \end{array} \]
      5. metadata-eval86.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{c}{b} \cdot -1\right)}^{3}}\\ \end{array} \]
    9. Applied egg-rr86.6%

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

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

Alternative 5: 76.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\ t_1 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\ \end{array}\\ \mathbf{if}\;t\_1 \leq 5 \cdot 10^{+238}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;e^{\log \left(\frac{c}{-b}\right)}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
        (t_1
         (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))))
   (if (<= t_1 5e+238)
     t_1
     (if (>= b 0.0) (* -0.5 (/ (+ b b) a)) (exp (log (/ c (- b))))))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	double tmp;
	if (b >= 0.0) {
		tmp = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (t_0 - b);
	}
	double t_1 = tmp;
	double tmp_1;
	if (t_1 <= 5e+238) {
		tmp_1 = t_1;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * ((b + b) / a);
	} else {
		tmp_1 = exp(log((c / -b)));
	}
	return tmp_1;
}
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) :: t_1
    real(8) :: tmp
    real(8) :: tmp_1
    t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
    if (b >= 0.0d0) then
        tmp = (-b - t_0) / (2.0d0 * a)
    else
        tmp = (2.0d0 * c) / (t_0 - b)
    end if
    t_1 = tmp
    if (t_1 <= 5d+238) then
        tmp_1 = t_1
    else if (b >= 0.0d0) then
        tmp_1 = (-0.5d0) * ((b + b) / a)
    else
        tmp_1 = exp(log((c / -b)))
    end if
    code = tmp_1
end function
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
	double tmp;
	if (b >= 0.0) {
		tmp = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (t_0 - b);
	}
	double t_1 = tmp;
	double tmp_1;
	if (t_1 <= 5e+238) {
		tmp_1 = t_1;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * ((b + b) / a);
	} else {
		tmp_1 = Math.exp(Math.log((c / -b)));
	}
	return tmp_1;
}
def code(a, b, c):
	t_0 = math.sqrt(((b * b) - (c * (a * 4.0))))
	tmp = 0
	if b >= 0.0:
		tmp = (-b - t_0) / (2.0 * a)
	else:
		tmp = (2.0 * c) / (t_0 - b)
	t_1 = tmp
	tmp_1 = 0
	if t_1 <= 5e+238:
		tmp_1 = t_1
	elif b >= 0.0:
		tmp_1 = -0.5 * ((b + b) / a)
	else:
		tmp_1 = math.exp(math.log((c / -b)))
	return tmp_1
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0))))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a));
	else
		tmp = Float64(Float64(2.0 * c) / Float64(t_0 - b));
	end
	t_1 = tmp
	tmp_1 = 0.0
	if (t_1 <= 5e+238)
		tmp_1 = t_1;
	elseif (b >= 0.0)
		tmp_1 = Float64(-0.5 * Float64(Float64(b + b) / a));
	else
		tmp_1 = exp(log(Float64(c / Float64(-b))));
	end
	return tmp_1
end
function tmp_3 = code(a, b, c)
	t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	tmp = 0.0;
	if (b >= 0.0)
		tmp = (-b - t_0) / (2.0 * a);
	else
		tmp = (2.0 * c) / (t_0 - b);
	end
	t_1 = tmp;
	tmp_2 = 0.0;
	if (t_1 <= 5e+238)
		tmp_2 = t_1;
	elseif (b >= 0.0)
		tmp_2 = -0.5 * ((b + b) / a);
	else
		tmp_2 = exp(log((c / -b)));
	end
	tmp_3 = tmp_2;
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]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$1, 5e+238], t$95$1, If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[Exp[N[Log[N[(c / (-b)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}

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

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


\end{array}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+238}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\

\mathbf{else}:\\
\;\;\;\;e^{\log \left(\frac{c}{-b}\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < 4.99999999999999995e238

    1. Initial program 75.7%

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

    if 4.99999999999999995e238 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c))))))

    1. Initial program 38.7%

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \color{blue}{\frac{2}{b \cdot -2}}\\ \end{array} \]
    8. Step-by-step derivation
      1. add-exp-log85.8%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;e^{\log \left(c \cdot \frac{2}{b \cdot -2}\right)}\\ \end{array} \]
      2. associate-*r/85.8%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;e^{\log \left(\frac{c \cdot 2}{b \cdot -2}\right)}\\ \end{array} \]
      3. times-frac85.8%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;e^{\log \left(\frac{c}{b} \cdot \frac{2}{-2}\right)}\\ \end{array} \]
      4. metadata-eval85.8%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;e^{\log \left(\frac{c}{b} \cdot -1\right)}\\ \end{array} \]
    9. Applied egg-rr85.8%

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

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

Alternative 6: 76.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\ t_1 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\ \end{array}\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
        (t_1
         (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))))
   (if (<= t_1 (- INFINITY))
     (if (>= b 0.0)
       (/ (* 2.0 (- (* a (/ c b)) b)) (* 2.0 a))
       (/ (* 2.0 c) (- (- b) b)))
     t_1)))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	double tmp;
	if (b >= 0.0) {
		tmp = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (t_0 - b);
	}
	double t_1 = tmp;
	double tmp_2;
	if (t_1 <= -((double) INFINITY)) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = (2.0 * ((a * (c / b)) - b)) / (2.0 * a);
		} else {
			tmp_3 = (2.0 * c) / (-b - b);
		}
		tmp_2 = tmp_3;
	} else {
		tmp_2 = t_1;
	}
	return tmp_2;
}
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
	double tmp;
	if (b >= 0.0) {
		tmp = (-b - t_0) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (t_0 - b);
	}
	double t_1 = tmp;
	double tmp_2;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = (2.0 * ((a * (c / b)) - b)) / (2.0 * a);
		} else {
			tmp_3 = (2.0 * c) / (-b - b);
		}
		tmp_2 = tmp_3;
	} else {
		tmp_2 = t_1;
	}
	return tmp_2;
}
def code(a, b, c):
	t_0 = math.sqrt(((b * b) - (c * (a * 4.0))))
	tmp = 0
	if b >= 0.0:
		tmp = (-b - t_0) / (2.0 * a)
	else:
		tmp = (2.0 * c) / (t_0 - b)
	t_1 = tmp
	tmp_2 = 0
	if t_1 <= -math.inf:
		tmp_3 = 0
		if b >= 0.0:
			tmp_3 = (2.0 * ((a * (c / b)) - b)) / (2.0 * a)
		else:
			tmp_3 = (2.0 * c) / (-b - b)
		tmp_2 = tmp_3
	else:
		tmp_2 = t_1
	return tmp_2
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0))))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a));
	else
		tmp = Float64(Float64(2.0 * c) / Float64(t_0 - b));
	end
	t_1 = tmp
	tmp_2 = 0.0
	if (t_1 <= Float64(-Inf))
		tmp_3 = 0.0
		if (b >= 0.0)
			tmp_3 = Float64(Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b)) / Float64(2.0 * a));
		else
			tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b));
		end
		tmp_2 = tmp_3;
	else
		tmp_2 = t_1;
	end
	return tmp_2
end
function tmp_5 = code(a, b, c)
	t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	tmp = 0.0;
	if (b >= 0.0)
		tmp = (-b - t_0) / (2.0 * a);
	else
		tmp = (2.0 * c) / (t_0 - b);
	end
	t_1 = tmp;
	tmp_3 = 0.0;
	if (t_1 <= -Inf)
		tmp_4 = 0.0;
		if (b >= 0.0)
			tmp_4 = (2.0 * ((a * (c / b)) - b)) / (2.0 * a);
		else
			tmp_4 = (2.0 * c) / (-b - b);
		end
		tmp_3 = tmp_4;
	else
		tmp_3 = t_1;
	end
	tmp_5 = tmp_3;
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]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$1, (-Infinity)], If[GreaterEqual[b, 0.0], N[(N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision]], t$95$1]]]
\begin{array}{l}

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

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


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

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


\end{array}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < -inf.0

    1. Initial program 38.9%

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

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

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

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

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

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

    if -inf.0 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c))))))

    1. Initial program 73.7%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array} \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification75.0%

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

Alternative 7: 75.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\ t_1 := \frac{2 \cdot c}{t\_0 - b}\\ t_2 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array}\\ \mathbf{if}\;t\_2 \leq 5 \cdot 10^{+169}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - b \cdot 2}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
        (t_1 (/ (* 2.0 c) (- t_0 b)))
        (t_2 (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) t_1)))
   (if (<= t_2 5e+169)
     t_2
     (if (>= b 0.0) (/ (- (* 2.0 (/ (* a c) b)) (* b 2.0)) (* 2.0 a)) t_1))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	double t_1 = (2.0 * c) / (t_0 - b);
	double tmp;
	if (b >= 0.0) {
		tmp = (-b - t_0) / (2.0 * a);
	} else {
		tmp = t_1;
	}
	double t_2 = tmp;
	double tmp_1;
	if (t_2 <= 5e+169) {
		tmp_1 = t_2;
	} else if (b >= 0.0) {
		tmp_1 = ((2.0 * ((a * c) / b)) - (b * 2.0)) / (2.0 * a);
	} else {
		tmp_1 = t_1;
	}
	return tmp_1;
}
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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    real(8) :: tmp_1
    t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
    t_1 = (2.0d0 * c) / (t_0 - b)
    if (b >= 0.0d0) then
        tmp = (-b - t_0) / (2.0d0 * a)
    else
        tmp = t_1
    end if
    t_2 = tmp
    if (t_2 <= 5d+169) then
        tmp_1 = t_2
    else if (b >= 0.0d0) then
        tmp_1 = ((2.0d0 * ((a * c) / b)) - (b * 2.0d0)) / (2.0d0 * a)
    else
        tmp_1 = t_1
    end if
    code = tmp_1
end function
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
	double t_1 = (2.0 * c) / (t_0 - b);
	double tmp;
	if (b >= 0.0) {
		tmp = (-b - t_0) / (2.0 * a);
	} else {
		tmp = t_1;
	}
	double t_2 = tmp;
	double tmp_1;
	if (t_2 <= 5e+169) {
		tmp_1 = t_2;
	} else if (b >= 0.0) {
		tmp_1 = ((2.0 * ((a * c) / b)) - (b * 2.0)) / (2.0 * a);
	} else {
		tmp_1 = t_1;
	}
	return tmp_1;
}
def code(a, b, c):
	t_0 = math.sqrt(((b * b) - (c * (a * 4.0))))
	t_1 = (2.0 * c) / (t_0 - b)
	tmp = 0
	if b >= 0.0:
		tmp = (-b - t_0) / (2.0 * a)
	else:
		tmp = t_1
	t_2 = tmp
	tmp_1 = 0
	if t_2 <= 5e+169:
		tmp_1 = t_2
	elif b >= 0.0:
		tmp_1 = ((2.0 * ((a * c) / b)) - (b * 2.0)) / (2.0 * a)
	else:
		tmp_1 = t_1
	return tmp_1
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0))))
	t_1 = Float64(Float64(2.0 * c) / Float64(t_0 - b))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a));
	else
		tmp = t_1;
	end
	t_2 = tmp
	tmp_1 = 0.0
	if (t_2 <= 5e+169)
		tmp_1 = t_2;
	elseif (b >= 0.0)
		tmp_1 = Float64(Float64(Float64(2.0 * Float64(Float64(a * c) / b)) - Float64(b * 2.0)) / Float64(2.0 * a));
	else
		tmp_1 = t_1;
	end
	return tmp_1
end
function tmp_3 = code(a, b, c)
	t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	t_1 = (2.0 * c) / (t_0 - b);
	tmp = 0.0;
	if (b >= 0.0)
		tmp = (-b - t_0) / (2.0 * a);
	else
		tmp = t_1;
	end
	t_2 = tmp;
	tmp_2 = 0.0;
	if (t_2 <= 5e+169)
		tmp_2 = t_2;
	elseif (b >= 0.0)
		tmp_2 = ((2.0 * ((a * c) / b)) - (b * 2.0)) / (2.0 * a);
	else
		tmp_2 = t_1;
	end
	tmp_3 = tmp_2;
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]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], t$95$1]}, If[LessEqual[t$95$2, 5e+169], t$95$2, If[GreaterEqual[b, 0.0], N[(N[(N[(2.0 * N[(N[(a * c), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(b * 2.0), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}

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

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


\end{array}\\
\mathbf{if}\;t\_2 \leq 5 \cdot 10^{+169}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - b \cdot 2}{2 \cdot a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < 5.00000000000000017e169

    1. Initial program 74.4%

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

    if 5.00000000000000017e169 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c))))))

    1. Initial program 51.2%

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

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

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

Alternative 8: 71.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\ \mathbf{if}\;a \leq 4 \cdot 10^{+210}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot {\left({\left(\frac{b}{a \cdot 0.5}\right)}^{3}\right)}^{0.3333333333333333}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
   (if (<= a 4e+210)
     (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))
     (if (>= b 0.0)
       (* -0.5 (pow (pow (/ b (* a 0.5)) 3.0) 0.3333333333333333))
       (/ c (- b))))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	double tmp_1;
	if (a <= 4e+210) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (-b - t_0) / (2.0 * a);
		} else {
			tmp_2 = (2.0 * c) / (t_0 - b);
		}
		tmp_1 = tmp_2;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * pow(pow((b / (a * 0.5)), 3.0), 0.3333333333333333);
	} else {
		tmp_1 = c / -b;
	}
	return tmp_1;
}
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
    real(8) :: tmp_1
    real(8) :: tmp_2
    t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
    if (a <= 4d+210) then
        if (b >= 0.0d0) then
            tmp_2 = (-b - t_0) / (2.0d0 * a)
        else
            tmp_2 = (2.0d0 * c) / (t_0 - b)
        end if
        tmp_1 = tmp_2
    else if (b >= 0.0d0) then
        tmp_1 = (-0.5d0) * (((b / (a * 0.5d0)) ** 3.0d0) ** 0.3333333333333333d0)
    else
        tmp_1 = c / -b
    end if
    code = tmp_1
end function
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
	double tmp_1;
	if (a <= 4e+210) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (-b - t_0) / (2.0 * a);
		} else {
			tmp_2 = (2.0 * c) / (t_0 - b);
		}
		tmp_1 = tmp_2;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * Math.pow(Math.pow((b / (a * 0.5)), 3.0), 0.3333333333333333);
	} else {
		tmp_1 = c / -b;
	}
	return tmp_1;
}
def code(a, b, c):
	t_0 = math.sqrt(((b * b) - (c * (a * 4.0))))
	tmp_1 = 0
	if a <= 4e+210:
		tmp_2 = 0
		if b >= 0.0:
			tmp_2 = (-b - t_0) / (2.0 * a)
		else:
			tmp_2 = (2.0 * c) / (t_0 - b)
		tmp_1 = tmp_2
	elif b >= 0.0:
		tmp_1 = -0.5 * math.pow(math.pow((b / (a * 0.5)), 3.0), 0.3333333333333333)
	else:
		tmp_1 = c / -b
	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 (a <= 4e+210)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a));
		else
			tmp_2 = Float64(Float64(2.0 * c) / Float64(t_0 - b));
		end
		tmp_1 = tmp_2;
	elseif (b >= 0.0)
		tmp_1 = Float64(-0.5 * ((Float64(b / Float64(a * 0.5)) ^ 3.0) ^ 0.3333333333333333));
	else
		tmp_1 = Float64(c / Float64(-b));
	end
	return tmp_1
end
function tmp_4 = code(a, b, c)
	t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	tmp_2 = 0.0;
	if (a <= 4e+210)
		tmp_3 = 0.0;
		if (b >= 0.0)
			tmp_3 = (-b - t_0) / (2.0 * a);
		else
			tmp_3 = (2.0 * c) / (t_0 - b);
		end
		tmp_2 = tmp_3;
	elseif (b >= 0.0)
		tmp_2 = -0.5 * (((b / (a * 0.5)) ^ 3.0) ^ 0.3333333333333333);
	else
		tmp_2 = c / -b;
	end
	tmp_4 = tmp_2;
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[a, 4e+210], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-0.5 * N[Power[N[Power[N[(b / N[(a * 0.5), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]]
\begin{array}{l}

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

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


\end{array}\\

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot {\left({\left(\frac{b}{a \cdot 0.5}\right)}^{3}\right)}^{0.3333333333333333}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 3.99999999999999971e210

    1. Initial program 73.1%

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

    if 3.99999999999999971e210 < a

    1. Initial program 14.9%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array} \]
    5. Step-by-step derivation
      1. mul-1-neg33.7%

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \color{blue}{\frac{-2 \cdot \frac{a \cdot c}{b} + 2 \cdot b}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    8. Taylor expanded in a around 0 64.2%

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{\color{blue}{b \cdot 2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
      3. associate-*r/64.1%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \color{blue}{\left(b \cdot \frac{2}{a}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    11. Step-by-step derivation
      1. add-cbrt-cube64.0%

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot {\color{blue}{\left({\left(b \cdot \frac{2}{a}\right)}^{3}\right)}}^{0.3333333333333333}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
      4. clear-num61.8%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot {\left({\left(b \cdot \color{blue}{\frac{1}{\frac{a}{2}}}\right)}^{3}\right)}^{0.3333333333333333}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
      5. un-div-inv61.8%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot {\left({\left(\frac{b}{\color{blue}{a \cdot \frac{1}{2}}}\right)}^{3}\right)}^{0.3333333333333333}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
      7. metadata-eval61.8%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot {\left({\left(\frac{b}{a \cdot \color{blue}{0.5}}\right)}^{3}\right)}^{0.3333333333333333}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    12. Applied egg-rr61.8%

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

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

Alternative 9: 71.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\ \mathbf{if}\;a \leq 1.4 \cdot 10^{+211}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \sqrt[3]{{\left(\frac{b}{a \cdot 0.5}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
   (if (<= a 1.4e+211)
     (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))
     (if (>= b 0.0) (* -0.5 (cbrt (pow (/ b (* a 0.5)) 3.0))) (/ c (- b))))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	double tmp_1;
	if (a <= 1.4e+211) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (-b - t_0) / (2.0 * a);
		} else {
			tmp_2 = (2.0 * c) / (t_0 - b);
		}
		tmp_1 = tmp_2;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * cbrt(pow((b / (a * 0.5)), 3.0));
	} else {
		tmp_1 = c / -b;
	}
	return tmp_1;
}
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
	double tmp_1;
	if (a <= 1.4e+211) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (-b - t_0) / (2.0 * a);
		} else {
			tmp_2 = (2.0 * c) / (t_0 - b);
		}
		tmp_1 = tmp_2;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * Math.cbrt(Math.pow((b / (a * 0.5)), 3.0));
	} else {
		tmp_1 = c / -b;
	}
	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 (a <= 1.4e+211)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a));
		else
			tmp_2 = Float64(Float64(2.0 * c) / Float64(t_0 - b));
		end
		tmp_1 = tmp_2;
	elseif (b >= 0.0)
		tmp_1 = Float64(-0.5 * cbrt((Float64(b / Float64(a * 0.5)) ^ 3.0)));
	else
		tmp_1 = Float64(c / Float64(-b));
	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[a, 1.4e+211], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-0.5 * N[Power[N[Power[N[(b / N[(a * 0.5), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]]
\begin{array}{l}

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

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


\end{array}\\

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \sqrt[3]{{\left(\frac{b}{a \cdot 0.5}\right)}^{3}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 1.4e211

    1. Initial program 73.1%

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

    if 1.4e211 < a

    1. Initial program 14.9%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array} \]
    5. Step-by-step derivation
      1. mul-1-neg33.7%

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \color{blue}{\frac{-2 \cdot \frac{a \cdot c}{b} + 2 \cdot b}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    8. Taylor expanded in a around 0 64.2%

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{\color{blue}{b \cdot 2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
      3. associate-*r/64.1%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \color{blue}{\left(b \cdot \frac{2}{a}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    11. Step-by-step derivation
      1. add-cbrt-cube64.0%

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

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \sqrt[3]{{\left(\frac{b}{a \cdot \color{blue}{0.5}}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    12. Applied egg-rr64.0%

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

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

Alternative 10: 71.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\ \mathbf{if}\;a \leq 210000000:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot {\left(\sqrt{\frac{b}{a \cdot 0.5}}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
   (if (<= a 210000000.0)
     (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))
     (if (>= b 0.0) (* -0.5 (pow (sqrt (/ b (* a 0.5))) 2.0)) (/ c (- b))))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	double tmp_1;
	if (a <= 210000000.0) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (-b - t_0) / (2.0 * a);
		} else {
			tmp_2 = (2.0 * c) / (t_0 - b);
		}
		tmp_1 = tmp_2;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * pow(sqrt((b / (a * 0.5))), 2.0);
	} else {
		tmp_1 = c / -b;
	}
	return tmp_1;
}
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
    real(8) :: tmp_1
    real(8) :: tmp_2
    t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
    if (a <= 210000000.0d0) then
        if (b >= 0.0d0) then
            tmp_2 = (-b - t_0) / (2.0d0 * a)
        else
            tmp_2 = (2.0d0 * c) / (t_0 - b)
        end if
        tmp_1 = tmp_2
    else if (b >= 0.0d0) then
        tmp_1 = (-0.5d0) * (sqrt((b / (a * 0.5d0))) ** 2.0d0)
    else
        tmp_1 = c / -b
    end if
    code = tmp_1
end function
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
	double tmp_1;
	if (a <= 210000000.0) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (-b - t_0) / (2.0 * a);
		} else {
			tmp_2 = (2.0 * c) / (t_0 - b);
		}
		tmp_1 = tmp_2;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * Math.pow(Math.sqrt((b / (a * 0.5))), 2.0);
	} else {
		tmp_1 = c / -b;
	}
	return tmp_1;
}
def code(a, b, c):
	t_0 = math.sqrt(((b * b) - (c * (a * 4.0))))
	tmp_1 = 0
	if a <= 210000000.0:
		tmp_2 = 0
		if b >= 0.0:
			tmp_2 = (-b - t_0) / (2.0 * a)
		else:
			tmp_2 = (2.0 * c) / (t_0 - b)
		tmp_1 = tmp_2
	elif b >= 0.0:
		tmp_1 = -0.5 * math.pow(math.sqrt((b / (a * 0.5))), 2.0)
	else:
		tmp_1 = c / -b
	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 (a <= 210000000.0)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a));
		else
			tmp_2 = Float64(Float64(2.0 * c) / Float64(t_0 - b));
		end
		tmp_1 = tmp_2;
	elseif (b >= 0.0)
		tmp_1 = Float64(-0.5 * (sqrt(Float64(b / Float64(a * 0.5))) ^ 2.0));
	else
		tmp_1 = Float64(c / Float64(-b));
	end
	return tmp_1
end
function tmp_4 = code(a, b, c)
	t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	tmp_2 = 0.0;
	if (a <= 210000000.0)
		tmp_3 = 0.0;
		if (b >= 0.0)
			tmp_3 = (-b - t_0) / (2.0 * a);
		else
			tmp_3 = (2.0 * c) / (t_0 - b);
		end
		tmp_2 = tmp_3;
	elseif (b >= 0.0)
		tmp_2 = -0.5 * (sqrt((b / (a * 0.5))) ^ 2.0);
	else
		tmp_2 = c / -b;
	end
	tmp_4 = tmp_2;
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[a, 210000000.0], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-0.5 * N[Power[N[Sqrt[N[(b / N[(a * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]]
\begin{array}{l}

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

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


\end{array}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 2.1e8

    1. Initial program 77.3%

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

    if 2.1e8 < a

    1. Initial program 45.5%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array} \]
    5. Step-by-step derivation
      1. mul-1-neg47.0%

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \color{blue}{\frac{-2 \cdot \frac{a \cdot c}{b} + 2 \cdot b}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    8. Taylor expanded in a around 0 62.2%

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{\color{blue}{b \cdot 2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
      3. associate-*r/62.2%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \color{blue}{\left(b \cdot \frac{2}{a}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    11. Step-by-step derivation
      1. add-sqr-sqrt62.0%

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

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot {\left(\sqrt{\frac{b}{a \cdot \color{blue}{0.5}}}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    12. Applied egg-rr62.1%

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

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

Alternative 11: 70.2% accurate, 0.6× speedup?

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

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

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


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

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

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

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

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

Alternative 12: 71.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\ \mathbf{if}\;a \leq 3.4 \cdot 10^{+16}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{b}{a \cdot 0.5}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
   (if (<= a 3.4e+16)
     (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))
     (if (>= b 0.0) (* -0.5 (expm1 (log1p (/ b (* a 0.5))))) (/ c (- b))))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	double tmp_1;
	if (a <= 3.4e+16) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (-b - t_0) / (2.0 * a);
		} else {
			tmp_2 = (2.0 * c) / (t_0 - b);
		}
		tmp_1 = tmp_2;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * expm1(log1p((b / (a * 0.5))));
	} else {
		tmp_1 = c / -b;
	}
	return tmp_1;
}
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
	double tmp_1;
	if (a <= 3.4e+16) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (-b - t_0) / (2.0 * a);
		} else {
			tmp_2 = (2.0 * c) / (t_0 - b);
		}
		tmp_1 = tmp_2;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * Math.expm1(Math.log1p((b / (a * 0.5))));
	} else {
		tmp_1 = c / -b;
	}
	return tmp_1;
}
def code(a, b, c):
	t_0 = math.sqrt(((b * b) - (c * (a * 4.0))))
	tmp_1 = 0
	if a <= 3.4e+16:
		tmp_2 = 0
		if b >= 0.0:
			tmp_2 = (-b - t_0) / (2.0 * a)
		else:
			tmp_2 = (2.0 * c) / (t_0 - b)
		tmp_1 = tmp_2
	elif b >= 0.0:
		tmp_1 = -0.5 * math.expm1(math.log1p((b / (a * 0.5))))
	else:
		tmp_1 = c / -b
	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 (a <= 3.4e+16)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a));
		else
			tmp_2 = Float64(Float64(2.0 * c) / Float64(t_0 - b));
		end
		tmp_1 = tmp_2;
	elseif (b >= 0.0)
		tmp_1 = Float64(-0.5 * expm1(log1p(Float64(b / Float64(a * 0.5)))));
	else
		tmp_1 = Float64(c / Float64(-b));
	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[a, 3.4e+16], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(Exp[N[Log[1 + N[(b / N[(a * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]]
\begin{array}{l}

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

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


\end{array}\\

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{b}{a \cdot 0.5}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 3.4e16

    1. Initial program 77.2%

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

    if 3.4e16 < a

    1. Initial program 44.4%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array} \]
    5. Step-by-step derivation
      1. mul-1-neg47.4%

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \color{blue}{\frac{-2 \cdot \frac{a \cdot c}{b} + 2 \cdot b}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    8. Taylor expanded in a around 0 61.9%

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{\color{blue}{b \cdot 2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
      3. associate-*r/61.9%

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(b \cdot \frac{2}{a}\right)} - 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
      3. clear-num54.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \left(e^{\mathsf{log1p}\left(b \cdot \color{blue}{\frac{1}{\frac{a}{2}}}\right)} - 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
      4. un-div-inv54.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{b}{\frac{a}{2}}}\right)} - 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
      5. div-inv54.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{b}{\color{blue}{a \cdot \frac{1}{2}}}\right)} - 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
      6. metadata-eval54.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{b}{a \cdot \color{blue}{0.5}}\right)} - 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    12. Applied egg-rr54.0%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{b}{a \cdot 0.5}\right)} - 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    13. Step-by-step derivation
      1. expm1-define60.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{b}{a \cdot 0.5}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    14. Simplified60.6%

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

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

Alternative 13: 71.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\ \mathbf{if}\;a \leq 2200000000:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt[3]{\frac{c}{-b}}\right)}^{3}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
   (if (<= a 2200000000.0)
     (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))
     (if (>= b 0.0) (* -0.5 (/ (+ b b) a)) (pow (cbrt (/ c (- b))) 3.0)))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	double tmp_1;
	if (a <= 2200000000.0) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (-b - t_0) / (2.0 * a);
		} else {
			tmp_2 = (2.0 * c) / (t_0 - b);
		}
		tmp_1 = tmp_2;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * ((b + b) / a);
	} else {
		tmp_1 = pow(cbrt((c / -b)), 3.0);
	}
	return tmp_1;
}
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
	double tmp_1;
	if (a <= 2200000000.0) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (-b - t_0) / (2.0 * a);
		} else {
			tmp_2 = (2.0 * c) / (t_0 - b);
		}
		tmp_1 = tmp_2;
	} else if (b >= 0.0) {
		tmp_1 = -0.5 * ((b + b) / a);
	} else {
		tmp_1 = Math.pow(Math.cbrt((c / -b)), 3.0);
	}
	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 (a <= 2200000000.0)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a));
		else
			tmp_2 = Float64(Float64(2.0 * c) / Float64(t_0 - b));
		end
		tmp_1 = tmp_2;
	elseif (b >= 0.0)
		tmp_1 = Float64(-0.5 * Float64(Float64(b + b) / a));
	else
		tmp_1 = cbrt(Float64(c / Float64(-b))) ^ 3.0;
	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[a, 2200000000.0], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(c / (-b)), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]]]]
\begin{array}{l}

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

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


\end{array}\\

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\

\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{\frac{c}{-b}}\right)}^{3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 2.2e9

    1. Initial program 77.3%

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

    if 2.2e9 < a

    1. Initial program 45.5%

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \color{blue}{\frac{2}{b \cdot -2}}\\ \end{array} \]
    8. Step-by-step derivation
      1. add-cube-cbrt61.6%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt[3]{c \cdot \frac{2}{b \cdot -2}}\right)}^{3}\\ \end{array} \]
      3. associate-*r/61.8%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt[3]{\frac{c}{b} \cdot \frac{2}{-2}}\right)}^{3}\\ \end{array} \]
      5. metadata-eval61.8%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt[3]{\frac{c}{b} \cdot -1}\right)}^{3}\\ \end{array} \]
    9. Applied egg-rr61.8%

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

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

Alternative 14: 70.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (>= b 0.0)
   (/ (* 2.0 (- (* a (/ c b)) b)) (* 2.0 a))
   (/ (* 2.0 c) (- (sqrt (- (* b b) (* c (* a 4.0)))) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * ((a * (c / b)) - b)) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (sqrt(((b * b) - (c * (a * 4.0)))) - b);
	}
	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 = (2.0d0 * ((a * (c / b)) - b)) / (2.0d0 * a)
    else
        tmp = (2.0d0 * c) / (sqrt(((b * b) - (c * (a * 4.0d0)))) - b)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * ((a * (c / b)) - b)) / (2.0 * a);
	} else {
		tmp = (2.0 * c) / (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b);
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b >= 0.0:
		tmp = (2.0 * ((a * (c / b)) - b)) / (2.0 * a)
	else:
		tmp = (2.0 * c) / (math.sqrt(((b * b) - (c * (a * 4.0)))) - b)
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b)) / Float64(2.0 * a));
	else
		tmp = Float64(Float64(2.0 * c) / Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b >= 0.0)
		tmp = (2.0 * ((a * (c / b)) - b)) / (2.0 * a);
	else
		tmp = (2.0 * c) / (sqrt(((b * b) - (c * (a * 4.0)))) - b);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

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

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

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

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

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

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

Alternative 15: 69.2% accurate, 10.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \left(b \cdot \frac{2}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (>= b 0.0) (* -0.5 (* b (/ 2.0 a))) (/ c (- b))))
double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = -0.5 * (b * (2.0 / a));
	} else {
		tmp = c / -b;
	}
	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 = (-0.5d0) * (b * (2.0d0 / a))
    else
        tmp = c / -b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = -0.5 * (b * (2.0 / a));
	} else {
		tmp = c / -b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b >= 0.0:
		tmp = -0.5 * (b * (2.0 / a))
	else:
		tmp = c / -b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(-0.5 * Float64(b * Float64(2.0 / a)));
	else
		tmp = Float64(c / Float64(-b));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b >= 0.0)
		tmp = -0.5 * (b * (2.0 / a));
	else
		tmp = c / -b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-0.5 * N[(b * N[(2.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}

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

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


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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array} \]
  5. Step-by-step derivation
    1. mul-1-neg67.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \color{blue}{\frac{-2 \cdot \frac{a \cdot c}{b} + 2 \cdot b}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
  8. Taylor expanded in a around 0 69.0%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{\color{blue}{b \cdot 2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
    3. associate-*r/68.9%

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

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

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

Alternative 16: 69.2% accurate, 10.1× speedup?

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

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

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


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

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

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

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

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

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

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

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

Alternative 17: 69.3% accurate, 10.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (>= b 0.0) (* -0.5 (/ (+ b b) a)) (/ c (- b))))
double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = -0.5 * ((b + b) / a);
	} else {
		tmp = c / -b;
	}
	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 = (-0.5d0) * ((b + b) / a)
    else
        tmp = c / -b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = -0.5 * ((b + b) / a);
	} else {
		tmp = c / -b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b >= 0.0:
		tmp = -0.5 * ((b + b) / a)
	else:
		tmp = c / -b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(-0.5 * Float64(Float64(b + b) / a));
	else
		tmp = Float64(c / Float64(-b));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b >= 0.0)
		tmp = -0.5 * ((b + b) / a);
	else
		tmp = c / -b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}

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

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


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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array} \]
  5. Step-by-step derivation
    1. mul-1-neg67.9%

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

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

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

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

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

Reproduce

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