Cubic critical

Percentage Accurate: 51.5% → 84.8%
Time: 16.7s
Alternatives: 11
Speedup: 16.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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: 51.5% 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.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 48.6%

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

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

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

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

    if -5.60000000000000023e75 < b < 1.75e-105

    1. Initial program 81.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. neg-sub081.1%

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

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

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

        \[\leadsto \frac{\color{blue}{-\left(b - \sqrt{\left(-b\right) \cdot \left(-b\right) - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a} \]
      5. neg-mul-181.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b + \left(-3 \cdot a\right) \cdot c}} - b}{\frac{a}{0.3333333333333333}} \]
      7. cancel-sign-sub-inv81.1%

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

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

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

    if 1.75e-105 < b

    1. Initial program 18.3%

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    4. Applied egg-rr87.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5.6 \cdot 10^{+75}:\\ \;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\ \mathbf{elif}\;b \leq 1.75 \cdot 10^{-105}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{\frac{a}{0.3333333333333333}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 2: 79.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-143}:\\
\;\;\;\;\frac{\left(\frac{a \cdot 1.5}{\frac{b}{c}} - b\right) - b}{3 \cdot a}\\

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

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


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

    1. Initial program 66.5%

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

      \[\leadsto \frac{\left(-b\right) + \color{blue}{\left(-1 \cdot b + 1.5 \cdot \frac{a \cdot c}{b}\right)}}{3 \cdot a} \]
    3. Step-by-step derivation
      1. +-commutative78.2%

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

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

        \[\leadsto \frac{\left(-b\right) + \color{blue}{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}}{3 \cdot a} \]
      4. associate-/l*84.8%

        \[\leadsto \frac{\left(-b\right) + \left(1.5 \cdot \color{blue}{\frac{a}{\frac{b}{c}}} - b\right)}{3 \cdot a} \]
      5. associate-*r/84.8%

        \[\leadsto \frac{\left(-b\right) + \left(\color{blue}{\frac{1.5 \cdot a}{\frac{b}{c}}} - b\right)}{3 \cdot a} \]
    4. Simplified84.8%

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

    if -5.50000000000000041e-143 < b < 2.49999999999999982e-105

    1. Initial program 72.2%

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

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

    if 2.49999999999999982e-105 < b

    1. Initial program 18.3%

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    4. Applied egg-rr87.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5.5 \cdot 10^{-143}:\\ \;\;\;\;\frac{\left(\frac{a \cdot 1.5}{\frac{b}{c}} - b\right) - b}{3 \cdot a}\\ \mathbf{elif}\;b \leq 2.5 \cdot 10^{-105}:\\ \;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 3: 67.9% accurate, 6.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{\left(\frac{a \cdot 1.5}{\frac{b}{c}} - b\right) - b}{3 \cdot a}\\

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


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

    1. Initial program 66.6%

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

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

        \[\leadsto \frac{\left(-b\right) + \color{blue}{\left(1.5 \cdot \frac{a \cdot c}{b} + -1 \cdot b\right)}}{3 \cdot a} \]
      2. mul-1-neg66.6%

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

        \[\leadsto \frac{\left(-b\right) + \color{blue}{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}}{3 \cdot a} \]
      4. associate-/l*72.0%

        \[\leadsto \frac{\left(-b\right) + \left(1.5 \cdot \color{blue}{\frac{a}{\frac{b}{c}}} - b\right)}{3 \cdot a} \]
      5. associate-*r/72.0%

        \[\leadsto \frac{\left(-b\right) + \left(\color{blue}{\frac{1.5 \cdot a}{\frac{b}{c}}} - b\right)}{3 \cdot a} \]
    4. Simplified72.0%

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

    if -1.000000000000002e-309 < b

    1. Initial program 34.8%

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    4. Applied egg-rr67.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\frac{\left(\frac{a \cdot 1.5}{\frac{b}{c}} - b\right) - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 4: 67.9% accurate, 7.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\
\;\;\;\;0.3333333333333333 \cdot \left(-2 \cdot \frac{b}{a} + 1.5 \cdot \frac{c}{b}\right)\\

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


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

    1. Initial program 66.6%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-\left(b - \sqrt{\left(-b\right) \cdot \left(-b\right) - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a} \]
      5. neg-mul-166.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b + \left(-3 \cdot a\right) \cdot c}} - b}{\frac{a}{0.3333333333333333}} \]
      7. cancel-sign-sub-inv66.6%

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b - 3 \cdot \left(a \cdot c\right)}} - b}{\frac{a}{0.3333333333333333}} \]
    6. Step-by-step derivation
      1. associate-/r/66.5%

        \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a} \cdot 0.3333333333333333} \]
      2. cancel-sign-sub-inv66.5%

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

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

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

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

      \[\leadsto \color{blue}{\left(-2 \cdot \frac{b}{a} + 1.5 \cdot \frac{c}{b}\right)} \cdot 0.3333333333333333 \]

    if -1.000000000000002e-309 < b

    1. Initial program 34.8%

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    4. Applied egg-rr67.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\ \;\;\;\;0.3333333333333333 \cdot \left(-2 \cdot \frac{b}{a} + 1.5 \cdot \frac{c}{b}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 5: 68.0% accurate, 8.9× speedup?

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

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

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


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

    1. Initial program 66.6%

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

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

    if -1.000000000000002e-309 < b

    1. Initial program 34.8%

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    4. Applied egg-rr67.1%

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

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

Alternative 6: 67.8% accurate, 12.8× speedup?

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

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

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


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

    1. Initial program 66.6%

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

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

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

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

    if -1.000000000000002e-309 < b

    1. Initial program 34.8%

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    4. Applied egg-rr67.1%

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

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

Alternative 7: 67.8% accurate, 16.4× speedup?

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

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

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


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

    1. Initial program 66.6%

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

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

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666}{\frac{a}{b}}} \]
    4. Simplified71.1%

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666}{a} \cdot b} \]
    6. Applied egg-rr71.0%

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

    if -1.000000000000002e-309 < b

    1. Initial program 34.8%

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

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

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

Alternative 8: 67.8% accurate, 16.4× speedup?

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

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

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


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

    1. Initial program 66.6%

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

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

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

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

    if -1.000000000000002e-309 < b

    1. Initial program 34.8%

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

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

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

Alternative 9: 67.8% accurate, 16.4× speedup?

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

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

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


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

    1. Initial program 66.6%

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

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

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

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

    if -1.000000000000002e-309 < b

    1. Initial program 34.8%

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    4. Applied egg-rr67.1%

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

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

Alternative 10: 67.8% accurate, 16.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\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 -1e-309) (/ (* b -0.6666666666666666) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -1e-309) {
		tmp = (b * -0.6666666666666666) / a;
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= (-1d-309)) then
        tmp = (b * (-0.6666666666666666d0)) / a
    else
        tmp = (c * (-0.5d0)) / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -1e-309) {
		tmp = (b * -0.6666666666666666) / a;
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -1e-309:
		tmp = (b * -0.6666666666666666) / a
	else:
		tmp = (c * -0.5) / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -1e-309)
		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 <= -1e-309)
		tmp = (b * -0.6666666666666666) / a;
	else
		tmp = (c * -0.5) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -1e-309], 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 -1 \cdot 10^{-309}:\\
\;\;\;\;\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 < -1.000000000000002e-309

    1. Initial program 66.6%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b \cdot -0.6666666666666666}{a}} \]
    6. Applied egg-rr71.2%

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

    if -1.000000000000002e-309 < b

    1. Initial program 34.8%

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    4. Applied egg-rr67.1%

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

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

Alternative 11: 35.0% accurate, 23.2× speedup?

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

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

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

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  3. Final simplification35.0%

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

Reproduce

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