Cubic critical

Percentage Accurate: 62.7% → 86.4%
Time: 18.1s
Alternatives: 10
Speedup: 1.0×

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 10 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: 62.7% 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: 86.4% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{+139}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\

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

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


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

    1. Initial program 52.5%

      \[\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 99.6%

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

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

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

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

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

    if -8.9999999999999999e139 < b < 2.85000000000000007e140

    1. Initial program 80.3%

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

    if 2.85000000000000007e140 < b

    1. Initial program 8.5%

      \[\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 93.2%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{b}}{3 \cdot a} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.8%

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

Alternative 2: 76.1% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 70.2%

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

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}} + 0.5 \cdot \frac{c}{b} \]
    5. Applied egg-rr87.8%

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

    if -5.3000000000000003e-58 < b < 3.75e21

    1. Initial program 76.5%

      \[\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 66.9%

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

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

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

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

    if 3.75e21 < b

    1. Initial program 38.7%

      \[\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 83.0%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{b}}{3 \cdot a} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification78.7%

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

Alternative 3: 76.2% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 70.2%

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

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}} + 0.5 \cdot \frac{c}{b} \]
    5. Applied egg-rr87.8%

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

    if -1.05000000000000003e-56 < b < 2.7e21

    1. Initial program 76.5%

      \[\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 66.9%

      \[\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*67.1%

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

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

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

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

    if 2.7e21 < b

    1. Initial program 38.7%

      \[\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 83.0%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{b}}{3 \cdot a} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification78.8%

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

Alternative 4: 62.5% accurate, 7.2× speedup?

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

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

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


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

    1. Initial program 73.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 -inf 65.0%

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

    if -1.36e-307 < b

    1. Initial program 53.4%

      \[\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 53.5%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{b}}{3 \cdot a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.4%

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

Alternative 5: 62.5% accurate, 7.2× speedup?

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

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

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


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

    1. Initial program 73.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 -inf 65.0%

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}} + 0.5 \cdot \frac{c}{b} \]
    5. Applied egg-rr65.0%

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

    if -1.5499999999999999e-307 < b

    1. Initial program 53.4%

      \[\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 53.5%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{b}}{3 \cdot a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.4%

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

Alternative 6: 48.1% accurate, 9.7× speedup?

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

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

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


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

    1. Initial program 73.3%

      \[\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 63.9%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-0.6666666666666666 \cdot b}}{a} \]
      3. clear-num63.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{a}{-0.6666666666666666 \cdot b}}} \]
      4. *-un-lft-identity63.8%

        \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot a}}{-0.6666666666666666 \cdot b}} \]
      5. times-frac64.0%

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{-0.6666666666666666} \cdot \frac{a}{b}}} \]
      6. metadata-eval64.0%

        \[\leadsto \frac{1}{\color{blue}{-1.5} \cdot \frac{a}{b}} \]
    7. Applied egg-rr64.0%

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

    if 2.5999999999999999e-299 < b

    1. Initial program 52.7%

      \[\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 27.3%

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

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

Alternative 7: 62.3% accurate, 9.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.5 \cdot 10^{-305}:\\ \;\;\;\;\frac{1}{-1.5 \cdot \frac{a}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - b}{a \cdot 3}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -1.5e-305) (/ 1.0 (* -1.5 (/ a b))) (/ (- b b) (* a 3.0))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -1.5e-305) {
		tmp = 1.0 / (-1.5 * (a / b));
	} else {
		tmp = (b - b) / (a * 3.0);
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= (-1.5d-305)) then
        tmp = 1.0d0 / ((-1.5d0) * (a / b))
    else
        tmp = (b - b) / (a * 3.0d0)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -1.5e-305) {
		tmp = 1.0 / (-1.5 * (a / b));
	} else {
		tmp = (b - b) / (a * 3.0);
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -1.5e-305:
		tmp = 1.0 / (-1.5 * (a / b))
	else:
		tmp = (b - b) / (a * 3.0)
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -1.5e-305)
		tmp = Float64(1.0 / Float64(-1.5 * Float64(a / b)));
	else
		tmp = Float64(Float64(b - b) / Float64(a * 3.0));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -1.5e-305)
		tmp = 1.0 / (-1.5 * (a / b));
	else
		tmp = (b - b) / (a * 3.0);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -1.5e-305], N[(1.0 / N[(-1.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 73.5%

      \[\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 65.3%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-0.6666666666666666 \cdot b}}{a} \]
      3. clear-num65.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{a}{-0.6666666666666666 \cdot b}}} \]
      4. *-un-lft-identity65.2%

        \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot a}}{-0.6666666666666666 \cdot b}} \]
      5. times-frac65.4%

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

        \[\leadsto \frac{1}{\color{blue}{-1.5} \cdot \frac{a}{b}} \]
    7. Applied egg-rr65.4%

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

    if -1.5000000000000001e-305 < b

    1. Initial program 53.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 53.1%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{b}}{3 \cdot a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.3%

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

Alternative 8: 48.1% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 73.3%

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

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

        \[\leadsto \color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a} - b \cdot \frac{0.3333333333333333}{a}} \]
      2. distribute-rgt-out--62.4%

        \[\leadsto \color{blue}{\frac{0.3333333333333333}{a} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right)} \]
    5. Simplified62.4%

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

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

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

        \[\leadsto \color{blue}{\frac{b \cdot -0.6666666666666666}{a}} \]
      3. associate-*r/63.8%

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

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

    if 2.05e-299 < b

    1. Initial program 52.7%

      \[\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 27.3%

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

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

Alternative 9: 48.1% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 73.3%

      \[\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 63.9%

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

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

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

    if 2.1499999999999999e-299 < b

    1. Initial program 52.7%

      \[\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 27.3%

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

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

Alternative 10: 15.8% accurate, 23.2× speedup?

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

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

    \[\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 14.1%

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

    \[\leadsto \frac{c}{b} \cdot -0.5 \]
  5. Add Preprocessing

Reproduce

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