Cubic critical

Percentage Accurate: 52.8% → 84.5%
Time: 14.5s
Alternatives: 11
Speedup: 11.6×

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 11 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.8% 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.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -3900:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 6.8 \cdot 10^{-61}:\\ \;\;\;\;\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 -3900.0)
   (/ (* b -0.6666666666666666) a)
   (if (<= b 6.8e-61)
     (/ (- (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 <= -3900.0) {
		tmp = (b * -0.6666666666666666) / a;
	} else if (b <= 6.8e-61) {
		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 <= (-3900.0d0)) then
        tmp = (b * (-0.6666666666666666d0)) / a
    else if (b <= 6.8d-61) 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 <= -3900.0) {
		tmp = (b * -0.6666666666666666) / a;
	} else if (b <= 6.8e-61) {
		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 <= -3900.0:
		tmp = (b * -0.6666666666666666) / a
	elif b <= 6.8e-61:
		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 <= -3900.0)
		tmp = Float64(Float64(b * -0.6666666666666666) / a);
	elseif (b <= 6.8e-61)
		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 <= -3900.0)
		tmp = (b * -0.6666666666666666) / a;
	elseif (b <= 6.8e-61)
		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, -3900.0], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 6.8e-61], 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 -3900:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\

\mathbf{elif}\;b \leq 6.8 \cdot 10^{-61}:\\
\;\;\;\;\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 < -3900

    1. Initial program 65.7%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. fma-neg65.7%

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{a \cdot \left(c \cdot -3\right)}\right)}}{3 \cdot a} \]
      7. *-un-lft-identity65.7%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{1 \cdot \mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{3 \cdot a} \]
      8. *-un-lft-identity65.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}} \]
      2. *-commutative94.4%

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

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

    if -3900 < b < 6.7999999999999996e-61

    1. Initial program 71.9%

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

    if 6.7999999999999996e-61 < 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. Add Preprocessing
    3. Taylor expanded in b around inf 87.2%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    4. Step-by-step derivation
      1. associate-*r/87.2%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    5. Simplified87.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -3900:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 6.8 \cdot 10^{-61}:\\ \;\;\;\;\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} \]
  5. Add Preprocessing

Alternative 2: 80.3% accurate, 1.0× speedup?

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

\mathbf{elif}\;b \leq 8.6 \cdot 10^{-61}:\\
\;\;\;\;\frac{b + \sqrt{-3 \cdot \left(a \cdot c\right)}}{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 < -9.4e-60

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{3 \cdot a} \]
      9. add-cube-cbrt70.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}} \]
      2. *-commutative91.9%

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

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

    if -9.4e-60 < b < 8.6000000000000007e-61

    1. Initial program 68.0%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{-3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. associate-*r*63.8%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(a \cdot -3\right)} \cdot c}}{3 \cdot a} \]
      3. *-commutative63.8%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{c \cdot \left(a \cdot -3\right)} + \left(-b\right)}}{3 \cdot a} \]
      2. *-un-lft-identity63.8%

        \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{c \cdot \left(a \cdot -3\right)}} + \left(-b\right)}{3 \cdot a} \]
      3. fma-def63.8%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(1, \sqrt{c \cdot \left(a \cdot -3\right)}, -b\right)}}{3 \cdot a} \]
      4. add-sqr-sqrt37.3%

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(1, \sqrt{c \cdot \left(a \cdot -3\right)}, \color{blue}{\sqrt{b} \cdot \sqrt{b}}\right)}{3 \cdot a} \]
      8. add-sqr-sqrt62.8%

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

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

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

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

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

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

    if 8.6000000000000007e-61 < 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. Add Preprocessing
    3. Taylor expanded in b around inf 87.2%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    4. Step-by-step derivation
      1. associate-*r/87.2%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    5. Simplified87.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -9.4 \cdot 10^{-60}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 8.6 \cdot 10^{-61}:\\ \;\;\;\;\frac{b + \sqrt{-3 \cdot \left(a \cdot c\right)}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.4% accurate, 1.0× speedup?

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

\mathbf{elif}\;b \leq 1.05 \cdot 10^{-60}:\\
\;\;\;\;\frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{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 < -2.8000000000000002e-60

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{3 \cdot a} \]
      9. add-cube-cbrt70.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}} \]
      2. *-commutative91.9%

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

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

    if -2.8000000000000002e-60 < b < 1.04999999999999996e-60

    1. Initial program 68.0%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{-3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. associate-*r*63.8%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(a \cdot -3\right)} \cdot c}}{3 \cdot a} \]
      3. *-commutative63.8%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{c \cdot \left(a \cdot -3\right)} + \left(-b\right)}}{3 \cdot a} \]
      2. *-un-lft-identity63.8%

        \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{c \cdot \left(a \cdot -3\right)}} + \left(-b\right)}{3 \cdot a} \]
      3. fma-def63.8%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(1, \sqrt{c \cdot \left(a \cdot -3\right)}, -b\right)}}{3 \cdot a} \]
      4. add-sqr-sqrt37.3%

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(1, \sqrt{c \cdot \left(a \cdot -3\right)}, \color{blue}{\sqrt{b} \cdot \sqrt{b}}\right)}{3 \cdot a} \]
      8. add-sqr-sqrt62.8%

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

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

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

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

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

    if 1.04999999999999996e-60 < 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. Add Preprocessing
    3. Taylor expanded in b around inf 87.2%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    4. Step-by-step derivation
      1. associate-*r/87.2%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    5. Simplified87.2%

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

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

Alternative 4: 80.8% accurate, 1.0× speedup?

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

\mathbf{elif}\;b \leq 7 \cdot 10^{-61}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\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 < -1.1e-54

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{3 \cdot a} \]
      9. add-cube-cbrt70.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}} \]
      2. *-commutative91.9%

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

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

    if -1.1e-54 < b < 7.0000000000000006e-61

    1. Initial program 68.0%

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

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

    if 7.0000000000000006e-61 < 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. Add Preprocessing
    3. Taylor expanded in b around inf 87.2%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    4. Step-by-step derivation
      1. associate-*r/87.2%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    5. Simplified87.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.1 \cdot 10^{-54}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 7 \cdot 10^{-61}:\\ \;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 80.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -3.2 \cdot 10^{-54}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 5.5 \cdot 10^{-61}:\\ \;\;\;\;\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 -3.2e-54)
   (/ (* b -0.6666666666666666) a)
   (if (<= b 5.5e-61)
     (/ (- (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 <= -3.2e-54) {
		tmp = (b * -0.6666666666666666) / a;
	} else if (b <= 5.5e-61) {
		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 <= (-3.2d-54)) then
        tmp = (b * (-0.6666666666666666d0)) / a
    else if (b <= 5.5d-61) 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 <= -3.2e-54) {
		tmp = (b * -0.6666666666666666) / a;
	} else if (b <= 5.5e-61) {
		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 <= -3.2e-54:
		tmp = (b * -0.6666666666666666) / a
	elif b <= 5.5e-61:
		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 <= -3.2e-54)
		tmp = Float64(Float64(b * -0.6666666666666666) / a);
	elseif (b <= 5.5e-61)
		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 <= -3.2e-54)
		tmp = (b * -0.6666666666666666) / a;
	elseif (b <= 5.5e-61)
		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, -3.2e-54], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 5.5e-61], 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.2 \cdot 10^{-54}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\

\mathbf{elif}\;b \leq 5.5 \cdot 10^{-61}:\\
\;\;\;\;\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.19999999999999998e-54

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{3 \cdot a} \]
      9. add-cube-cbrt70.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}} \]
      2. *-commutative91.9%

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

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

    if -3.19999999999999998e-54 < b < 5.4999999999999997e-61

    1. Initial program 68.0%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{-3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. associate-*r*63.8%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(a \cdot -3\right)} \cdot c}}{3 \cdot a} \]
      3. *-commutative63.8%

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

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

    if 5.4999999999999997e-61 < 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. Add Preprocessing
    3. Taylor expanded in b around inf 87.2%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    4. Step-by-step derivation
      1. associate-*r/87.2%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    5. Simplified87.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -3.2 \cdot 10^{-54}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 5.5 \cdot 10^{-61}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 66.5% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 72.6%

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

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    4. Step-by-step derivation
      1. *-commutative66.9%

        \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
    5. Simplified66.9%

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

    if -4.999999999999985e-310 < b

    1. Initial program 31.9%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    4. Step-by-step derivation
      1. associate-*r/66.3%

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

        \[\leadsto \color{blue}{\frac{-0.5}{\frac{b}{c}}} \]
    5. Simplified65.2%

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

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

Alternative 7: 66.6% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 72.6%

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

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    4. Step-by-step derivation
      1. *-commutative66.9%

        \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
    5. Simplified66.9%

      \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
    6. Step-by-step derivation
      1. add-exp-log32.2%

        \[\leadsto \color{blue}{e^{\log \left(\frac{b}{a} \cdot -0.6666666666666666\right)}} \]
      2. associate-*l/32.2%

        \[\leadsto e^{\log \color{blue}{\left(\frac{b \cdot -0.6666666666666666}{a}\right)}} \]
    7. Applied egg-rr32.2%

      \[\leadsto \color{blue}{e^{\log \left(\frac{b \cdot -0.6666666666666666}{a}\right)}} \]
    8. Step-by-step derivation
      1. rem-exp-log66.9%

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

        \[\leadsto \color{blue}{\frac{b}{\frac{a}{-0.6666666666666666}}} \]
      3. div-inv66.9%

        \[\leadsto \frac{b}{\color{blue}{a \cdot \frac{1}{-0.6666666666666666}}} \]
      4. metadata-eval66.9%

        \[\leadsto \frac{b}{a \cdot \color{blue}{-1.5}} \]
    9. Applied egg-rr66.9%

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

    if -4.999999999999985e-310 < b

    1. Initial program 31.9%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    4. Step-by-step derivation
      1. associate-*r/66.3%

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

        \[\leadsto \color{blue}{\frac{-0.5}{\frac{b}{c}}} \]
    5. Simplified65.2%

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

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

Alternative 8: 67.0% accurate, 11.6× speedup?

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

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

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    4. Step-by-step derivation
      1. *-commutative66.9%

        \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
    5. Simplified66.9%

      \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
    6. Step-by-step derivation
      1. add-exp-log32.2%

        \[\leadsto \color{blue}{e^{\log \left(\frac{b}{a} \cdot -0.6666666666666666\right)}} \]
      2. associate-*l/32.2%

        \[\leadsto e^{\log \color{blue}{\left(\frac{b \cdot -0.6666666666666666}{a}\right)}} \]
    7. Applied egg-rr32.2%

      \[\leadsto \color{blue}{e^{\log \left(\frac{b \cdot -0.6666666666666666}{a}\right)}} \]
    8. Step-by-step derivation
      1. rem-exp-log66.9%

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

        \[\leadsto \color{blue}{\frac{b}{\frac{a}{-0.6666666666666666}}} \]
      3. div-inv66.9%

        \[\leadsto \frac{b}{\color{blue}{a \cdot \frac{1}{-0.6666666666666666}}} \]
      4. metadata-eval66.9%

        \[\leadsto \frac{b}{a \cdot \color{blue}{-1.5}} \]
    9. Applied egg-rr66.9%

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

    if -4.999999999999985e-310 < b

    1. Initial program 31.9%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    4. Step-by-step derivation
      1. associate-*r/66.3%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    5. Simplified66.3%

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

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

Alternative 9: 66.9% accurate, 11.6× speedup?

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

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. fma-neg72.6%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, -\color{blue}{3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a} \]
      3. distribute-lft-neg-in72.6%

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}}{3 \cdot a} \]
      9. add-cube-cbrt72.1%

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}} \]
      2. *-commutative66.9%

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

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

    if -4.999999999999985e-310 < b

    1. Initial program 31.9%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    4. Step-by-step derivation
      1. associate-*r/66.3%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    5. Simplified66.3%

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

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

Alternative 10: 2.5% accurate, 23.2× speedup?

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

\\
\frac{b}{a} \cdot 1.3333333333333333
\end{array}
Derivation
  1. Initial program 52.1%

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

      \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}}{3 \cdot a} \]
    2. sqr-neg52.1%

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

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

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

      \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right) - \left(3 \cdot a\right) \cdot c} - 0}}{3 \cdot a} - \frac{b}{3 \cdot a} \]
    6. div-sub52.1%

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

    \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{3 \cdot a}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. *-un-lft-identity52.1%

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

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

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

    \[\leadsto \frac{\color{blue}{\left(b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right) + \mathsf{fma}\left(b, 1, b\right)}}{3 \cdot a} \]
  7. Step-by-step derivation
    1. +-commutative23.3%

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

      \[\leadsto \frac{\color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) + \left(b + \mathsf{fma}\left(b, 1, b\right)\right)}}{3 \cdot a} \]
    3. associate-*r*23.3%

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

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

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

      \[\leadsto \frac{\mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -3\right)}\right) + \left(b + \color{blue}{\left(b \cdot 1 + b\right)}\right)}{3 \cdot a} \]
    7. *-rgt-identity23.3%

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

    \[\leadsto \frac{\color{blue}{\mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -3\right)}\right) + \left(b + \left(b + b\right)\right)}}{3 \cdot a} \]
  9. Taylor expanded in b around inf 2.7%

    \[\leadsto \color{blue}{1.3333333333333333 \cdot \frac{b}{a}} \]
  10. Final simplification2.7%

    \[\leadsto \frac{b}{a} \cdot 1.3333333333333333 \]
  11. Add Preprocessing

Alternative 11: 35.0% accurate, 23.2× speedup?

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

\\
-0.6666666666666666 \cdot \frac{b}{a}
\end{array}
Derivation
  1. Initial program 52.1%

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

    \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
  4. Step-by-step derivation
    1. *-commutative34.7%

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

    \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
  6. Final simplification34.7%

    \[\leadsto -0.6666666666666666 \cdot \frac{b}{a} \]
  7. Add Preprocessing

Reproduce

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