Cubic critical

Percentage Accurate: 52.6% → 84.6%
Time: 15.5s
Alternatives: 13
Speedup: 16.4×

Specification

?
\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\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 13 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: 52.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}

Alternative 1: 84.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{+153}:\\ \;\;\;\;\frac{\frac{1}{\frac{a}{b \cdot 2}}}{-3}\\ \mathbf{elif}\;b \leq 1.2 \cdot 10^{-143}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -5e+153)
   (/ (/ 1.0 (/ a (* b 2.0))) -3.0)
   (if (<= b 1.2e-143)
     (/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
     (/ (* c -0.5) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -5e+153) {
		tmp = (1.0 / (a / (b * 2.0))) / -3.0;
	} else if (b <= 1.2e-143) {
		tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
	} else {
		tmp = (c * -0.5) / 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 <= (-5d+153)) then
        tmp = (1.0d0 / (a / (b * 2.0d0))) / (-3.0d0)
    else if (b <= 1.2d-143) then
        tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
    else
        tmp = (c * (-0.5d0)) / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -5e+153) {
		tmp = (1.0 / (a / (b * 2.0))) / -3.0;
	} else if (b <= 1.2e-143) {
		tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -5e+153:
		tmp = (1.0 / (a / (b * 2.0))) / -3.0
	elif b <= 1.2e-143:
		tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0)
	else:
		tmp = (c * -0.5) / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -5e+153)
		tmp = Float64(Float64(1.0 / Float64(a / Float64(b * 2.0))) / -3.0);
	elseif (b <= 1.2e-143)
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0));
	else
		tmp = Float64(Float64(c * -0.5) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -5e+153)
		tmp = (1.0 / (a / (b * 2.0))) / -3.0;
	elseif (b <= 1.2e-143)
		tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
	else
		tmp = (c * -0.5) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -5e+153], N[(N[(1.0 / N[(a / N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 1.2e-143], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+153}:\\
\;\;\;\;\frac{\frac{1}{\frac{a}{b \cdot 2}}}{-3}\\

\mathbf{elif}\;b \leq 1.2 \cdot 10^{-143}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\

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


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

    1. Initial program 33.7%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Applied egg-rr18.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)} - 1} \]
    3. Step-by-step derivation
      1. expm1-def18.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)\right)} \]
      2. expm1-log1p33.8%

        \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}} \]
      3. *-lft-identity33.8%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}}{a \cdot -3} \]
      4. *-commutative33.8%

        \[\leadsto \frac{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}{\color{blue}{-3 \cdot a}} \]
      5. times-frac33.8%

        \[\leadsto \color{blue}{\frac{1}{-3} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
      6. metadata-eval33.8%

        \[\leadsto \color{blue}{-0.3333333333333333} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a} \]
    4. Simplified33.8%

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
    5. Step-by-step derivation
      1. *-commutative33.8%

        \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a} \cdot -0.3333333333333333} \]
      2. metadata-eval33.8%

        \[\leadsto \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a} \cdot \color{blue}{\frac{1}{-3}} \]
      3. div-inv33.8%

        \[\leadsto \color{blue}{\frac{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}}{-3}} \]
    6. Applied egg-rr33.8%

      \[\leadsto \color{blue}{\frac{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}}{-3}} \]
    7. Step-by-step derivation
      1. clear-num33.8%

        \[\leadsto \frac{\color{blue}{\frac{1}{\frac{a}{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}}}}{-3} \]
      2. inv-pow33.8%

        \[\leadsto \frac{\color{blue}{{\left(\frac{a}{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}\right)}^{-1}}}{-3} \]
    8. Applied egg-rr33.8%

      \[\leadsto \frac{\color{blue}{{\left(\frac{a}{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}\right)}^{-1}}}{-3} \]
    9. Step-by-step derivation
      1. unpow-133.8%

        \[\leadsto \frac{\color{blue}{\frac{1}{\frac{a}{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}}}}{-3} \]
    10. Simplified33.8%

      \[\leadsto \frac{\color{blue}{\frac{1}{\frac{a}{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}}}}{-3} \]
    11. Taylor expanded in b around -inf 99.7%

      \[\leadsto \frac{\frac{1}{\frac{a}{\color{blue}{2 \cdot b}}}}{-3} \]
    12. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \frac{\frac{1}{\frac{a}{\color{blue}{b \cdot 2}}}}{-3} \]
    13. Simplified99.7%

      \[\leadsto \frac{\frac{1}{\frac{a}{\color{blue}{b \cdot 2}}}}{-3} \]

    if -5.00000000000000018e153 < b < 1.1999999999999999e-143

    1. Initial program 83.1%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

    if 1.1999999999999999e-143 < b

    1. Initial program 20.9%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around inf 85.4%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative85.4%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/85.4%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    4. Simplified85.4%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification86.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{+153}:\\ \;\;\;\;\frac{\frac{1}{\frac{a}{b \cdot 2}}}{-3}\\ \mathbf{elif}\;b \leq 1.2 \cdot 10^{-143}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 2: 79.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -3 \cdot 10^{-147}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.55 \cdot 10^{-142}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -3e-147)
   (+ (* 0.5 (/ c b)) (* -0.6666666666666666 (/ b a)))
   (if (<= b 1.55e-142)
     (/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
     (/ (* c -0.5) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -3e-147) {
		tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
	} else if (b <= 1.55e-142) {
		tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
	} else {
		tmp = (c * -0.5) / 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 <= (-3d-147)) then
        tmp = (0.5d0 * (c / b)) + ((-0.6666666666666666d0) * (b / a))
    else if (b <= 1.55d-142) then
        tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (a * 3.0d0)
    else
        tmp = (c * (-0.5d0)) / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -3e-147) {
		tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
	} else if (b <= 1.55e-142) {
		tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -3e-147:
		tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a))
	elif b <= 1.55e-142:
		tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0)
	else:
		tmp = (c * -0.5) / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -3e-147)
		tmp = Float64(Float64(0.5 * Float64(c / b)) + Float64(-0.6666666666666666 * Float64(b / a)));
	elseif (b <= 1.55e-142)
		tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0));
	else
		tmp = Float64(Float64(c * -0.5) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -3e-147)
		tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
	elseif (b <= 1.55e-142)
		tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
	else
		tmp = (c * -0.5) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -3e-147], N[(N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.55e-142], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{-147}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \leq 1.55 \cdot 10^{-142}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -3.0000000000000002e-147

    1. Initial program 70.0%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around -inf 83.3%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}} \]

    if -3.0000000000000002e-147 < b < 1.55e-142

    1. Initial program 73.2%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Step-by-step derivation
      1. prod-diff73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, -c \cdot \left(3 \cdot a\right)\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)}}}{3 \cdot a} \]
      2. *-commutative73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, -\color{blue}{\left(3 \cdot a\right) \cdot c}\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)}}{3 \cdot a} \]
      3. fma-def73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b \cdot b + \left(-\left(3 \cdot a\right) \cdot c\right)\right)} + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)}}{3 \cdot a} \]
      4. associate-+l+73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b + \left(\left(-\left(3 \cdot a\right) \cdot c\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}}{3 \cdot a} \]
      5. pow273.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{{b}^{2}} + \left(\left(-\left(3 \cdot a\right) \cdot c\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      6. *-commutative73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(\left(-\color{blue}{c \cdot \left(3 \cdot a\right)}\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      7. distribute-rgt-neg-in73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(\color{blue}{c \cdot \left(-3 \cdot a\right)} + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      8. *-commutative73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(-\color{blue}{a \cdot 3}\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      9. distribute-rgt-neg-in73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \color{blue}{\left(a \cdot \left(-3\right)\right)} + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      10. metadata-eval73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot \color{blue}{-3}\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      11. *-commutative73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \mathsf{fma}\left(-c, 3 \cdot a, \color{blue}{\left(3 \cdot a\right) \cdot c}\right)\right)}}{3 \cdot a} \]
      12. fma-udef73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \color{blue}{\left(\left(-c\right) \cdot \left(3 \cdot a\right) + \left(3 \cdot a\right) \cdot c\right)}\right)}}{3 \cdot a} \]
      13. distribute-lft-neg-in73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(\color{blue}{\left(-c \cdot \left(3 \cdot a\right)\right)} + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      14. distribute-rgt-neg-in73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(\color{blue}{c \cdot \left(-3 \cdot a\right)} + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      15. *-commutative73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(-\color{blue}{a \cdot 3}\right) + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      16. distribute-rgt-neg-in73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \color{blue}{\left(a \cdot \left(-3\right)\right)} + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      17. metadata-eval73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(a \cdot \color{blue}{-3}\right) + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      18. associate-*l*72.8%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(a \cdot -3\right) + \color{blue}{3 \cdot \left(a \cdot c\right)}\right)\right)}}{3 \cdot a} \]
    3. Applied egg-rr72.8%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(a \cdot -3\right) + 3 \cdot \left(a \cdot c\right)\right)\right)}}}{3 \cdot a} \]
    4. Taylor expanded in b around 0 72.9%

      \[\leadsto \frac{\color{blue}{\sqrt{-6 \cdot \left(a \cdot c\right) + 3 \cdot \left(a \cdot c\right)} + -1 \cdot b}}{3 \cdot a} \]
    5. Step-by-step derivation
      1. mul-1-neg72.9%

        \[\leadsto \frac{\sqrt{-6 \cdot \left(a \cdot c\right) + 3 \cdot \left(a \cdot c\right)} + \color{blue}{\left(-b\right)}}{3 \cdot a} \]
      2. unsub-neg72.9%

        \[\leadsto \frac{\color{blue}{\sqrt{-6 \cdot \left(a \cdot c\right) + 3 \cdot \left(a \cdot c\right)} - b}}{3 \cdot a} \]
      3. distribute-rgt-out73.2%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(a \cdot c\right) \cdot \left(-6 + 3\right)}} - b}{3 \cdot a} \]
      4. metadata-eval73.2%

        \[\leadsto \frac{\sqrt{\left(a \cdot c\right) \cdot \color{blue}{-3}} - b}{3 \cdot a} \]
      5. *-commutative73.2%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(c \cdot a\right)} \cdot -3} - b}{3 \cdot a} \]
      6. associate-*r*73.4%

        \[\leadsto \frac{\sqrt{\color{blue}{c \cdot \left(a \cdot -3\right)}} - b}{3 \cdot a} \]
    6. Simplified73.4%

      \[\leadsto \frac{\color{blue}{\sqrt{c \cdot \left(a \cdot -3\right)} - b}}{3 \cdot a} \]

    if 1.55e-142 < b

    1. Initial program 20.9%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around inf 85.4%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative85.4%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/85.4%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    4. Simplified85.4%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification82.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -3 \cdot 10^{-147}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.55 \cdot 10^{-142}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 3: 79.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -3 \cdot 10^{-147}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -2, \left(c \cdot \frac{a}{b}\right) \cdot 1.5\right)}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.55 \cdot 10^{-142}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -3e-147)
   (/ (fma b -2.0 (* (* c (/ a b)) 1.5)) (* a 3.0))
   (if (<= b 1.55e-142)
     (/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
     (/ (* c -0.5) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -3e-147) {
		tmp = fma(b, -2.0, ((c * (a / b)) * 1.5)) / (a * 3.0);
	} else if (b <= 1.55e-142) {
		tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0);
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= -3e-147)
		tmp = Float64(fma(b, -2.0, Float64(Float64(c * Float64(a / b)) * 1.5)) / Float64(a * 3.0));
	elseif (b <= 1.55e-142)
		tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(a * 3.0));
	else
		tmp = Float64(Float64(c * -0.5) / b);
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, -3e-147], N[(N[(b * -2.0 + N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.55e-142], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{-147}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, -2, \left(c \cdot \frac{a}{b}\right) \cdot 1.5\right)}{a \cdot 3}\\

\mathbf{elif}\;b \leq 1.55 \cdot 10^{-142}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -3.0000000000000002e-147

    1. Initial program 70.0%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around -inf 76.1%

      \[\leadsto \frac{\color{blue}{-2 \cdot b + 1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a} \]
    3. Step-by-step derivation
      1. *-commutative76.1%

        \[\leadsto \frac{\color{blue}{b \cdot -2} + 1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a} \]
      2. fma-def76.1%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(b, -2, 1.5 \cdot \frac{a \cdot c}{b}\right)}}{3 \cdot a} \]
      3. *-commutative76.1%

        \[\leadsto \frac{\mathsf{fma}\left(b, -2, \color{blue}{\frac{a \cdot c}{b} \cdot 1.5}\right)}{3 \cdot a} \]
      4. associate-/l*83.3%

        \[\leadsto \frac{\mathsf{fma}\left(b, -2, \color{blue}{\frac{a}{\frac{b}{c}}} \cdot 1.5\right)}{3 \cdot a} \]
      5. associate-/r/83.3%

        \[\leadsto \frac{\mathsf{fma}\left(b, -2, \color{blue}{\left(\frac{a}{b} \cdot c\right)} \cdot 1.5\right)}{3 \cdot a} \]
    4. Simplified83.3%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(b, -2, \left(\frac{a}{b} \cdot c\right) \cdot 1.5\right)}}{3 \cdot a} \]

    if -3.0000000000000002e-147 < b < 1.55e-142

    1. Initial program 73.2%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Step-by-step derivation
      1. prod-diff73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, -c \cdot \left(3 \cdot a\right)\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)}}}{3 \cdot a} \]
      2. *-commutative73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, -\color{blue}{\left(3 \cdot a\right) \cdot c}\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)}}{3 \cdot a} \]
      3. fma-def73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b \cdot b + \left(-\left(3 \cdot a\right) \cdot c\right)\right)} + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)}}{3 \cdot a} \]
      4. associate-+l+73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b + \left(\left(-\left(3 \cdot a\right) \cdot c\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}}{3 \cdot a} \]
      5. pow273.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{{b}^{2}} + \left(\left(-\left(3 \cdot a\right) \cdot c\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      6. *-commutative73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(\left(-\color{blue}{c \cdot \left(3 \cdot a\right)}\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      7. distribute-rgt-neg-in73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(\color{blue}{c \cdot \left(-3 \cdot a\right)} + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      8. *-commutative73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(-\color{blue}{a \cdot 3}\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      9. distribute-rgt-neg-in73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \color{blue}{\left(a \cdot \left(-3\right)\right)} + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      10. metadata-eval73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot \color{blue}{-3}\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      11. *-commutative73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \mathsf{fma}\left(-c, 3 \cdot a, \color{blue}{\left(3 \cdot a\right) \cdot c}\right)\right)}}{3 \cdot a} \]
      12. fma-udef73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \color{blue}{\left(\left(-c\right) \cdot \left(3 \cdot a\right) + \left(3 \cdot a\right) \cdot c\right)}\right)}}{3 \cdot a} \]
      13. distribute-lft-neg-in73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(\color{blue}{\left(-c \cdot \left(3 \cdot a\right)\right)} + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      14. distribute-rgt-neg-in73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(\color{blue}{c \cdot \left(-3 \cdot a\right)} + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      15. *-commutative73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(-\color{blue}{a \cdot 3}\right) + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      16. distribute-rgt-neg-in73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \color{blue}{\left(a \cdot \left(-3\right)\right)} + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      17. metadata-eval73.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(a \cdot \color{blue}{-3}\right) + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      18. associate-*l*72.8%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(a \cdot -3\right) + \color{blue}{3 \cdot \left(a \cdot c\right)}\right)\right)}}{3 \cdot a} \]
    3. Applied egg-rr72.8%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(a \cdot -3\right) + 3 \cdot \left(a \cdot c\right)\right)\right)}}}{3 \cdot a} \]
    4. Taylor expanded in b around 0 72.9%

      \[\leadsto \frac{\color{blue}{\sqrt{-6 \cdot \left(a \cdot c\right) + 3 \cdot \left(a \cdot c\right)} + -1 \cdot b}}{3 \cdot a} \]
    5. Step-by-step derivation
      1. mul-1-neg72.9%

        \[\leadsto \frac{\sqrt{-6 \cdot \left(a \cdot c\right) + 3 \cdot \left(a \cdot c\right)} + \color{blue}{\left(-b\right)}}{3 \cdot a} \]
      2. unsub-neg72.9%

        \[\leadsto \frac{\color{blue}{\sqrt{-6 \cdot \left(a \cdot c\right) + 3 \cdot \left(a \cdot c\right)} - b}}{3 \cdot a} \]
      3. distribute-rgt-out73.2%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(a \cdot c\right) \cdot \left(-6 + 3\right)}} - b}{3 \cdot a} \]
      4. metadata-eval73.2%

        \[\leadsto \frac{\sqrt{\left(a \cdot c\right) \cdot \color{blue}{-3}} - b}{3 \cdot a} \]
      5. *-commutative73.2%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(c \cdot a\right)} \cdot -3} - b}{3 \cdot a} \]
      6. associate-*r*73.4%

        \[\leadsto \frac{\sqrt{\color{blue}{c \cdot \left(a \cdot -3\right)}} - b}{3 \cdot a} \]
    6. Simplified73.4%

      \[\leadsto \frac{\color{blue}{\sqrt{c \cdot \left(a \cdot -3\right)} - b}}{3 \cdot a} \]

    if 1.55e-142 < b

    1. Initial program 20.9%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around inf 85.4%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative85.4%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/85.4%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    4. Simplified85.4%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification82.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -3 \cdot 10^{-147}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -2, \left(c \cdot \frac{a}{b}\right) \cdot 1.5\right)}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.55 \cdot 10^{-142}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 4: 78.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.6 \cdot 10^{-168}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.55 \cdot 10^{-142}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -1.6e-168)
   (+ (* 0.5 (/ c b)) (* -0.6666666666666666 (/ b a)))
   (if (<= b 1.55e-142)
     (* 0.3333333333333333 (/ (sqrt (* c (* a -3.0))) a))
     (/ (* c -0.5) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -1.6e-168) {
		tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
	} else if (b <= 1.55e-142) {
		tmp = 0.3333333333333333 * (sqrt((c * (a * -3.0))) / a);
	} else {
		tmp = (c * -0.5) / 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 <= (-1.6d-168)) then
        tmp = (0.5d0 * (c / b)) + ((-0.6666666666666666d0) * (b / a))
    else if (b <= 1.55d-142) then
        tmp = 0.3333333333333333d0 * (sqrt((c * (a * (-3.0d0)))) / a)
    else
        tmp = (c * (-0.5d0)) / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -1.6e-168) {
		tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
	} else if (b <= 1.55e-142) {
		tmp = 0.3333333333333333 * (Math.sqrt((c * (a * -3.0))) / a);
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -1.6e-168:
		tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a))
	elif b <= 1.55e-142:
		tmp = 0.3333333333333333 * (math.sqrt((c * (a * -3.0))) / a)
	else:
		tmp = (c * -0.5) / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -1.6e-168)
		tmp = Float64(Float64(0.5 * Float64(c / b)) + Float64(-0.6666666666666666 * Float64(b / a)));
	elseif (b <= 1.55e-142)
		tmp = Float64(0.3333333333333333 * Float64(sqrt(Float64(c * Float64(a * -3.0))) / a));
	else
		tmp = Float64(Float64(c * -0.5) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -1.6e-168)
		tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
	elseif (b <= 1.55e-142)
		tmp = 0.3333333333333333 * (sqrt((c * (a * -3.0))) / a);
	else
		tmp = (c * -0.5) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -1.6e-168], N[(N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.55e-142], N[(0.3333333333333333 * N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{-168}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \leq 1.55 \cdot 10^{-142}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -1.60000000000000003e-168

    1. Initial program 69.7%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around -inf 82.6%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}} \]

    if -1.60000000000000003e-168 < b < 1.55e-142

    1. Initial program 73.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Step-by-step derivation
      1. prod-diff73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, -c \cdot \left(3 \cdot a\right)\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)}}}{3 \cdot a} \]
      2. *-commutative73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, -\color{blue}{\left(3 \cdot a\right) \cdot c}\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)}}{3 \cdot a} \]
      3. fma-def73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b \cdot b + \left(-\left(3 \cdot a\right) \cdot c\right)\right)} + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)}}{3 \cdot a} \]
      4. associate-+l+73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b + \left(\left(-\left(3 \cdot a\right) \cdot c\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}}{3 \cdot a} \]
      5. pow273.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{{b}^{2}} + \left(\left(-\left(3 \cdot a\right) \cdot c\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      6. *-commutative73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(\left(-\color{blue}{c \cdot \left(3 \cdot a\right)}\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      7. distribute-rgt-neg-in73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(\color{blue}{c \cdot \left(-3 \cdot a\right)} + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      8. *-commutative73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(-\color{blue}{a \cdot 3}\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      9. distribute-rgt-neg-in73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \color{blue}{\left(a \cdot \left(-3\right)\right)} + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      10. metadata-eval73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot \color{blue}{-3}\right) + \mathsf{fma}\left(-c, 3 \cdot a, c \cdot \left(3 \cdot a\right)\right)\right)}}{3 \cdot a} \]
      11. *-commutative73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \mathsf{fma}\left(-c, 3 \cdot a, \color{blue}{\left(3 \cdot a\right) \cdot c}\right)\right)}}{3 \cdot a} \]
      12. fma-udef73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \color{blue}{\left(\left(-c\right) \cdot \left(3 \cdot a\right) + \left(3 \cdot a\right) \cdot c\right)}\right)}}{3 \cdot a} \]
      13. distribute-lft-neg-in73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(\color{blue}{\left(-c \cdot \left(3 \cdot a\right)\right)} + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      14. distribute-rgt-neg-in73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(\color{blue}{c \cdot \left(-3 \cdot a\right)} + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      15. *-commutative73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(-\color{blue}{a \cdot 3}\right) + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      16. distribute-rgt-neg-in73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \color{blue}{\left(a \cdot \left(-3\right)\right)} + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      17. metadata-eval73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(a \cdot \color{blue}{-3}\right) + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      18. associate-*l*73.3%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(a \cdot -3\right) + \color{blue}{3 \cdot \left(a \cdot c\right)}\right)\right)}}{3 \cdot a} \]
    3. Applied egg-rr73.3%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(a \cdot -3\right) + 3 \cdot \left(a \cdot c\right)\right)\right)}}}{3 \cdot a} \]
    4. Taylor expanded in b around 0 72.0%

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(\frac{1}{a} \cdot \sqrt{-6 \cdot \left(a \cdot c\right) + 3 \cdot \left(a \cdot c\right)}\right)} \]
    5. Step-by-step derivation
      1. associate-*l/72.2%

        \[\leadsto 0.3333333333333333 \cdot \color{blue}{\frac{1 \cdot \sqrt{-6 \cdot \left(a \cdot c\right) + 3 \cdot \left(a \cdot c\right)}}{a}} \]
      2. *-lft-identity72.2%

        \[\leadsto 0.3333333333333333 \cdot \frac{\color{blue}{\sqrt{-6 \cdot \left(a \cdot c\right) + 3 \cdot \left(a \cdot c\right)}}}{a} \]
      3. distribute-rgt-out72.5%

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{\color{blue}{\left(a \cdot c\right) \cdot \left(-6 + 3\right)}}}{a} \]
      4. metadata-eval72.5%

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{\left(a \cdot c\right) \cdot \color{blue}{-3}}}{a} \]
      5. *-commutative72.5%

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{\color{blue}{\left(c \cdot a\right)} \cdot -3}}{a} \]
      6. associate-*r*72.7%

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{\color{blue}{c \cdot \left(a \cdot -3\right)}}}{a} \]
    6. Simplified72.7%

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{\sqrt{c \cdot \left(a \cdot -3\right)}}{a}} \]

    if 1.55e-142 < b

    1. Initial program 20.9%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around inf 85.4%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative85.4%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/85.4%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    4. Simplified85.4%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification81.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.6 \cdot 10^{-168}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.55 \cdot 10^{-142}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 5: 67.3% accurate, 8.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\

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


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

    1. Initial program 70.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around -inf 64.9%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}} \]

    if -4.999999999999985e-310 < b

    1. Initial program 30.2%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around inf 72.7%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative72.7%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/72.7%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    4. Simplified72.7%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 6: 67.1% accurate, 12.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -5e-310) (/ 1.0 (* (/ a b) -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -5e-310) {
		tmp = 1.0 / ((a / b) * -1.5);
	} else {
		tmp = (c * -0.5) / 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 <= (-5d-310)) then
        tmp = 1.0d0 / ((a / b) * (-1.5d0))
    else
        tmp = (c * (-0.5d0)) / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -5e-310) {
		tmp = 1.0 / ((a / b) * -1.5);
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -5e-310:
		tmp = 1.0 / ((a / b) * -1.5)
	else:
		tmp = (c * -0.5) / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -5e-310)
		tmp = Float64(1.0 / Float64(Float64(a / b) * -1.5));
	else
		tmp = Float64(Float64(c * -0.5) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -5e-310)
		tmp = 1.0 / ((a / b) * -1.5);
	else
		tmp = (c * -0.5) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(1.0 / N[(N[(a / b), $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\

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


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

    1. Initial program 70.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Applied egg-rr20.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)} - 1} \]
    3. Step-by-step derivation
      1. expm1-def41.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)\right)} \]
      2. expm1-log1p70.8%

        \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}} \]
      3. *-lft-identity70.8%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}}{a \cdot -3} \]
      4. *-commutative70.8%

        \[\leadsto \frac{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}{\color{blue}{-3 \cdot a}} \]
      5. times-frac70.7%

        \[\leadsto \color{blue}{\frac{1}{-3} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
      6. metadata-eval70.7%

        \[\leadsto \color{blue}{-0.3333333333333333} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a} \]
    4. Simplified70.7%

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
    5. Taylor expanded in b around -inf 64.8%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    6. Step-by-step derivation
      1. associate-*r/64.7%

        \[\leadsto \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}} \]
      2. associate-/l*64.7%

        \[\leadsto \color{blue}{\frac{-0.6666666666666666}{\frac{a}{b}}} \]
    7. Simplified64.7%

      \[\leadsto \color{blue}{\frac{-0.6666666666666666}{\frac{a}{b}}} \]
    8. Step-by-step derivation
      1. clear-num64.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{a}{b}}{-0.6666666666666666}}} \]
      2. inv-pow64.7%

        \[\leadsto \color{blue}{{\left(\frac{\frac{a}{b}}{-0.6666666666666666}\right)}^{-1}} \]
      3. div-inv64.8%

        \[\leadsto {\color{blue}{\left(\frac{a}{b} \cdot \frac{1}{-0.6666666666666666}\right)}}^{-1} \]
      4. metadata-eval64.8%

        \[\leadsto {\left(\frac{a}{b} \cdot \color{blue}{-1.5}\right)}^{-1} \]
    9. Applied egg-rr64.8%

      \[\leadsto \color{blue}{{\left(\frac{a}{b} \cdot -1.5\right)}^{-1}} \]
    10. Step-by-step derivation
      1. unpow-164.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{a}{b} \cdot -1.5}} \]
    11. Simplified64.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{b} \cdot -1.5}} \]

    if -4.999999999999985e-310 < b

    1. Initial program 30.2%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around inf 72.7%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative72.7%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/72.7%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    4. Simplified72.7%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 7: 67.1% accurate, 12.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\

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


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

    1. Initial program 70.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around -inf 64.8%

      \[\leadsto \frac{\color{blue}{-2 \cdot b}}{3 \cdot a} \]
    3. Step-by-step derivation
      1. *-commutative64.8%

        \[\leadsto \frac{\color{blue}{b \cdot -2}}{3 \cdot a} \]
    4. Simplified64.8%

      \[\leadsto \frac{\color{blue}{b \cdot -2}}{3 \cdot a} \]

    if -4.999999999999985e-310 < b

    1. Initial program 30.2%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around inf 72.7%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative72.7%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/72.7%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    4. Simplified72.7%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 8: 67.1% accurate, 12.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.95 \cdot 10^{-305}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{a}}{-3}\\

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


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

    1. Initial program 70.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Applied egg-rr20.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)} - 1} \]
    3. Step-by-step derivation
      1. expm1-def41.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)\right)} \]
      2. expm1-log1p70.8%

        \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}} \]
      3. *-lft-identity70.8%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}}{a \cdot -3} \]
      4. *-commutative70.8%

        \[\leadsto \frac{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}{\color{blue}{-3 \cdot a}} \]
      5. times-frac70.7%

        \[\leadsto \color{blue}{\frac{1}{-3} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
      6. metadata-eval70.7%

        \[\leadsto \color{blue}{-0.3333333333333333} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a} \]
    4. Simplified70.7%

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
    5. Step-by-step derivation
      1. *-commutative70.7%

        \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a} \cdot -0.3333333333333333} \]
      2. metadata-eval70.7%

        \[\leadsto \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a} \cdot \color{blue}{\frac{1}{-3}} \]
      3. div-inv70.8%

        \[\leadsto \color{blue}{\frac{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}}{-3}} \]
    6. Applied egg-rr70.8%

      \[\leadsto \color{blue}{\frac{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}}{-3}} \]
    7. Taylor expanded in b around -inf 64.8%

      \[\leadsto \frac{\frac{\color{blue}{2 \cdot b}}{a}}{-3} \]
    8. Step-by-step derivation
      1. *-commutative64.8%

        \[\leadsto \frac{\frac{1}{\frac{a}{\color{blue}{b \cdot 2}}}}{-3} \]
    9. Simplified64.8%

      \[\leadsto \frac{\frac{\color{blue}{b \cdot 2}}{a}}{-3} \]

    if 1.95000000000000013e-305 < b

    1. Initial program 30.2%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around inf 72.7%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative72.7%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/72.7%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    4. Simplified72.7%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.95 \cdot 10^{-305}:\\ \;\;\;\;\frac{\frac{b \cdot 2}{a}}{-3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 9: 67.0% accurate, 16.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 3 \cdot 10^{-309}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\

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


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

    1. Initial program 70.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Applied egg-rr20.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)} - 1} \]
    3. Step-by-step derivation
      1. expm1-def41.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)\right)} \]
      2. expm1-log1p70.8%

        \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}} \]
      3. *-lft-identity70.8%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}}{a \cdot -3} \]
      4. *-commutative70.8%

        \[\leadsto \frac{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}{\color{blue}{-3 \cdot a}} \]
      5. times-frac70.7%

        \[\leadsto \color{blue}{\frac{1}{-3} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
      6. metadata-eval70.7%

        \[\leadsto \color{blue}{-0.3333333333333333} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a} \]
    4. Simplified70.7%

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
    5. Taylor expanded in b around -inf 64.8%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    6. Step-by-step derivation
      1. associate-*r/64.7%

        \[\leadsto \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}} \]
      2. associate-/l*64.7%

        \[\leadsto \color{blue}{\frac{-0.6666666666666666}{\frac{a}{b}}} \]
    7. Simplified64.7%

      \[\leadsto \color{blue}{\frac{-0.6666666666666666}{\frac{a}{b}}} \]
    8. Step-by-step derivation
      1. associate-/r/64.7%

        \[\leadsto \color{blue}{\frac{-0.6666666666666666}{a} \cdot b} \]
    9. Applied egg-rr64.7%

      \[\leadsto \color{blue}{\frac{-0.6666666666666666}{a} \cdot b} \]

    if 3.000000000000001e-309 < b

    1. Initial program 30.2%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Applied egg-rr12.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)} - 1} \]
    3. Step-by-step derivation
      1. expm1-def22.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)\right)} \]
      2. expm1-log1p30.2%

        \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}} \]
      3. *-lft-identity30.2%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}}{a \cdot -3} \]
      4. *-commutative30.2%

        \[\leadsto \frac{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}{\color{blue}{-3 \cdot a}} \]
      5. times-frac30.1%

        \[\leadsto \color{blue}{\frac{1}{-3} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
      6. metadata-eval30.1%

        \[\leadsto \color{blue}{-0.3333333333333333} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a} \]
    4. Simplified30.1%

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
    5. Taylor expanded in b around inf 72.7%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    6. Step-by-step derivation
      1. metadata-eval72.7%

        \[\leadsto \color{blue}{\frac{-0.5}{1}} \cdot \frac{c}{b} \]
      2. times-frac72.7%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{1 \cdot b}} \]
      3. *-commutative72.7%

        \[\leadsto \frac{\color{blue}{c \cdot -0.5}}{1 \cdot b} \]
      4. times-frac72.4%

        \[\leadsto \color{blue}{\frac{c}{1} \cdot \frac{-0.5}{b}} \]
      5. /-rgt-identity72.4%

        \[\leadsto \color{blue}{c} \cdot \frac{-0.5}{b} \]
    7. Simplified72.4%

      \[\leadsto \color{blue}{c \cdot \frac{-0.5}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 3 \cdot 10^{-309}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{-0.5}{b}\\ \end{array} \]

Alternative 10: 67.0% accurate, 16.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\

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


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

    1. Initial program 70.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around -inf 64.8%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    3. Step-by-step derivation
      1. *-commutative64.8%

        \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
    4. Simplified64.8%

      \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]

    if -4.999999999999985e-310 < b

    1. Initial program 30.2%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Applied egg-rr12.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)} - 1} \]
    3. Step-by-step derivation
      1. expm1-def22.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)\right)} \]
      2. expm1-log1p30.2%

        \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}} \]
      3. *-lft-identity30.2%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}}{a \cdot -3} \]
      4. *-commutative30.2%

        \[\leadsto \frac{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}{\color{blue}{-3 \cdot a}} \]
      5. times-frac30.1%

        \[\leadsto \color{blue}{\frac{1}{-3} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
      6. metadata-eval30.1%

        \[\leadsto \color{blue}{-0.3333333333333333} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a} \]
    4. Simplified30.1%

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
    5. Taylor expanded in b around inf 72.7%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    6. Step-by-step derivation
      1. metadata-eval72.7%

        \[\leadsto \color{blue}{\frac{-0.5}{1}} \cdot \frac{c}{b} \]
      2. times-frac72.7%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{1 \cdot b}} \]
      3. *-commutative72.7%

        \[\leadsto \frac{\color{blue}{c \cdot -0.5}}{1 \cdot b} \]
      4. times-frac72.4%

        \[\leadsto \color{blue}{\frac{c}{1} \cdot \frac{-0.5}{b}} \]
      5. /-rgt-identity72.4%

        \[\leadsto \color{blue}{c} \cdot \frac{-0.5}{b} \]
    7. Simplified72.4%

      \[\leadsto \color{blue}{c \cdot \frac{-0.5}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{-0.5}{b}\\ \end{array} \]

Alternative 11: 67.1% accurate, 16.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\

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


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

    1. Initial program 70.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around -inf 64.8%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    3. Step-by-step derivation
      1. *-commutative64.8%

        \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
    4. Simplified64.8%

      \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]

    if -4.999999999999985e-310 < b

    1. Initial program 30.2%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around inf 72.7%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative72.7%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/72.7%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    4. Simplified72.7%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 12: 10.8% accurate, 23.2× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \frac{c}{b} \end{array} \]
(FPCore (a b c) :precision binary64 (* 0.5 (/ c b)))
double code(double a, double b, double c) {
	return 0.5 * (c / b);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = 0.5d0 * (c / b)
end function
public static double code(double a, double b, double c) {
	return 0.5 * (c / b);
}
def code(a, b, c):
	return 0.5 * (c / b)
function code(a, b, c)
	return Float64(0.5 * Float64(c / b))
end
function tmp = code(a, b, c)
	tmp = 0.5 * (c / b);
end
code[a_, b_, c_] := N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
0.5 \cdot \frac{c}{b}
\end{array}
Derivation
  1. Initial program 50.2%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Applied egg-rr16.7%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)} - 1} \]
  3. Step-by-step derivation
    1. expm1-def32.1%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)\right)} \]
    2. expm1-log1p50.2%

      \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}} \]
    3. *-lft-identity50.2%

      \[\leadsto \frac{\color{blue}{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}}{a \cdot -3} \]
    4. *-commutative50.2%

      \[\leadsto \frac{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}{\color{blue}{-3 \cdot a}} \]
    5. times-frac50.1%

      \[\leadsto \color{blue}{\frac{1}{-3} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
    6. metadata-eval50.1%

      \[\leadsto \color{blue}{-0.3333333333333333} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a} \]
  4. Simplified50.1%

    \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
  5. Taylor expanded in b around -inf 33.2%

    \[\leadsto -0.3333333333333333 \cdot \color{blue}{\left(-1.5 \cdot \frac{c}{b} + 2 \cdot \frac{b}{a}\right)} \]
  6. Taylor expanded in c around inf 10.3%

    \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b}} \]
  7. Final simplification10.3%

    \[\leadsto 0.5 \cdot \frac{c}{b} \]

Alternative 13: 34.8% accurate, 23.2× speedup?

\[\begin{array}{l} \\ c \cdot \frac{-0.5}{b} \end{array} \]
(FPCore (a b c) :precision binary64 (* c (/ -0.5 b)))
double code(double a, double b, double c) {
	return c * (-0.5 / b);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = c * ((-0.5d0) / b)
end function
public static double code(double a, double b, double c) {
	return c * (-0.5 / b);
}
def code(a, b, c):
	return c * (-0.5 / b)
function code(a, b, c)
	return Float64(c * Float64(-0.5 / b))
end
function tmp = code(a, b, c)
	tmp = c * (-0.5 / b);
end
code[a_, b_, c_] := N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
c \cdot \frac{-0.5}{b}
\end{array}
Derivation
  1. Initial program 50.2%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Applied egg-rr16.7%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)} - 1} \]
  3. Step-by-step derivation
    1. expm1-def32.1%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}\right)\right)} \]
    2. expm1-log1p50.2%

      \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a \cdot -3}} \]
    3. *-lft-identity50.2%

      \[\leadsto \frac{\color{blue}{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}}{a \cdot -3} \]
    4. *-commutative50.2%

      \[\leadsto \frac{1 \cdot \left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}\right)}{\color{blue}{-3 \cdot a}} \]
    5. times-frac50.1%

      \[\leadsto \color{blue}{\frac{1}{-3} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
    6. metadata-eval50.1%

      \[\leadsto \color{blue}{-0.3333333333333333} \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a} \]
  4. Simplified50.1%

    \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}{a}} \]
  5. Taylor expanded in b around inf 37.9%

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  6. Step-by-step derivation
    1. metadata-eval37.9%

      \[\leadsto \color{blue}{\frac{-0.5}{1}} \cdot \frac{c}{b} \]
    2. times-frac37.9%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{1 \cdot b}} \]
    3. *-commutative37.9%

      \[\leadsto \frac{\color{blue}{c \cdot -0.5}}{1 \cdot b} \]
    4. times-frac37.8%

      \[\leadsto \color{blue}{\frac{c}{1} \cdot \frac{-0.5}{b}} \]
    5. /-rgt-identity37.8%

      \[\leadsto \color{blue}{c} \cdot \frac{-0.5}{b} \]
  7. Simplified37.8%

    \[\leadsto \color{blue}{c \cdot \frac{-0.5}{b}} \]
  8. Final simplification37.8%

    \[\leadsto c \cdot \frac{-0.5}{b} \]

Reproduce

?
herbie shell --seed 2023311 
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))