Cubic critical

Percentage Accurate: 51.0% → 85.8%
Time: 12.7s
Alternatives: 12
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 12 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.0% 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: 85.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 44.7%

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

      \[\leadsto \color{blue}{\left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right) \cdot \frac{1}{a \cdot -3}} \]
    3. Step-by-step derivation
      1. associate-/r*39.2%

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

      \[\leadsto \color{blue}{\left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right) \cdot \frac{\frac{1}{a}}{-3}} \]
    5. Step-by-step derivation
      1. associate-*r/39.2%

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

        \[\leadsto \color{blue}{\frac{-\left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right) \cdot \frac{1}{a}}{--3}} \]
      3. un-div-inv39.2%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{-\color{blue}{\left(\left(-\mathsf{hypot}\left(b, \sqrt{\left(c \cdot a\right) \cdot -3}\right)\right) + b\right)}}{a}}{3} \]
      4. distribute-neg-in39.2%

        \[\leadsto \frac{\frac{\color{blue}{\left(-\left(-\mathsf{hypot}\left(b, \sqrt{\left(c \cdot a\right) \cdot -3}\right)\right)\right) + \left(-b\right)}}{a}}{3} \]
      5. remove-double-neg39.2%

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{b \cdot -2}}{a}}{3} \]
    11. Simplified95.0%

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

    if -8.99999999999999987e79 < b < 4.3e-48

    1. Initial program 78.1%

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

    if 4.3e-48 < b

    1. Initial program 17.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -9 \cdot 10^{+79}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\ \mathbf{elif}\;b \leq 4.3 \cdot 10^{-48}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]

Alternative 2: 81.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 62.9%

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

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

    if -1.95000000000000011e-63 < b < 3.00000000000000012e-61

    1. Initial program 71.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 0 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.00000000000000012e-61 < b

    1. Initial program 17.0%

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

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

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

Alternative 3: 81.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 62.9%

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

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

    if -3.60000000000000008e-63 < b < 8.0000000000000002e-54

    1. Initial program 71.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 0 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.0000000000000002e-54 < b

    1. Initial program 17.0%

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

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

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

Alternative 4: 81.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 62.9%

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

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

    if -2.45000000000000008e-63 < b < 2.89999999999999986e-62

    1. Initial program 71.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 0 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.89999999999999986e-62 < b

    1. Initial program 17.0%

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

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

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

Alternative 5: 81.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 62.9%

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

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

    if -8.7999999999999998e-63 < b < 1.1e-51

    1. Initial program 71.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 0 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.1e-51 < b

    1. Initial program 17.0%

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

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

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

Alternative 6: 68.6% accurate, 12.8× speedup?

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

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

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


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

    1. Initial program 66.3%

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

      \[\leadsto \color{blue}{\left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right) \cdot \frac{1}{a \cdot -3}} \]
    3. Step-by-step derivation
      1. associate-/r*56.2%

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

      \[\leadsto \color{blue}{\left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right) \cdot \frac{\frac{1}{a}}{-3}} \]
    5. Step-by-step derivation
      1. associate-*r/56.2%

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

        \[\leadsto \color{blue}{\frac{-\left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right) \cdot \frac{1}{a}}{--3}} \]
      3. un-div-inv56.2%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{-\color{blue}{\left(\left(-\mathsf{hypot}\left(b, \sqrt{\left(c \cdot a\right) \cdot -3}\right)\right) + b\right)}}{a}}{3} \]
      4. distribute-neg-in56.2%

        \[\leadsto \frac{\frac{\color{blue}{\left(-\left(-\mathsf{hypot}\left(b, \sqrt{\left(c \cdot a\right) \cdot -3}\right)\right)\right) + \left(-b\right)}}{a}}{3} \]
      5. remove-double-neg56.2%

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

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

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

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

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

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

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

    if 1.5e-309 < b

    1. Initial program 33.0%

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

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

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

Alternative 7: 48.8% accurate, 16.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.12 \cdot 10^{-307}:\\
\;\;\;\;b \cdot \frac{-1.3333333333333333}{a}\\

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


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

    1. Initial program 66.3%

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

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

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

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

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

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

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

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

      \[\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} \]
    5. Step-by-step derivation
      1. +-commutative23.0%

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

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

        \[\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. *-commutative22.9%

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

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

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

        \[\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} \]
    6. Simplified22.9%

      \[\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} \]
    7. Taylor expanded in b around inf 1.4%

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

        \[\leadsto \frac{\color{blue}{b \cdot 4}}{3 \cdot a} \]
    9. Simplified1.4%

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

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

        \[\leadsto \color{blue}{\left(-b \cdot 4\right) \cdot \frac{1}{-3 \cdot a}} \]
      3. distribute-rgt-neg-in1.4%

        \[\leadsto \color{blue}{\left(b \cdot \left(-4\right)\right)} \cdot \frac{1}{-3 \cdot a} \]
      4. metadata-eval1.4%

        \[\leadsto \left(b \cdot \color{blue}{-4}\right) \cdot \frac{1}{-3 \cdot a} \]
      5. distribute-lft-neg-in1.4%

        \[\leadsto \left(b \cdot -4\right) \cdot \frac{1}{\color{blue}{\left(-3\right) \cdot a}} \]
      6. metadata-eval1.4%

        \[\leadsto \left(b \cdot -4\right) \cdot \frac{1}{\color{blue}{-3} \cdot a} \]
      7. *-commutative1.4%

        \[\leadsto \left(b \cdot -4\right) \cdot \frac{1}{\color{blue}{a \cdot -3}} \]
      8. add-sqr-sqrt0.7%

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

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

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

        \[\leadsto \left(b \cdot -4\right) \cdot \frac{1}{\sqrt{\left(a \cdot a\right) \cdot \color{blue}{9}}} \]
      12. metadata-eval10.0%

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

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

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

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

        \[\leadsto \left(b \cdot -4\right) \cdot \frac{1}{\color{blue}{\sqrt{3 \cdot a} \cdot \sqrt{3 \cdot a}}} \]
      17. add-sqr-sqrt25.7%

        \[\leadsto \left(b \cdot -4\right) \cdot \frac{1}{\color{blue}{3 \cdot a}} \]
      18. associate-/r*25.7%

        \[\leadsto \left(b \cdot -4\right) \cdot \color{blue}{\frac{\frac{1}{3}}{a}} \]
      19. metadata-eval25.7%

        \[\leadsto \left(b \cdot -4\right) \cdot \frac{\color{blue}{0.3333333333333333}}{a} \]
    11. Applied egg-rr25.7%

      \[\leadsto \color{blue}{\left(b \cdot -4\right) \cdot \frac{0.3333333333333333}{a}} \]
    12. Step-by-step derivation
      1. associate-*l*25.7%

        \[\leadsto \color{blue}{b \cdot \left(-4 \cdot \frac{0.3333333333333333}{a}\right)} \]
      2. associate-*r/25.7%

        \[\leadsto b \cdot \color{blue}{\frac{-4 \cdot 0.3333333333333333}{a}} \]
      3. metadata-eval25.7%

        \[\leadsto b \cdot \frac{\color{blue}{-1.3333333333333333}}{a} \]
    13. Simplified25.7%

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

    if 1.11999999999999994e-307 < b

    1. Initial program 33.0%

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

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

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

Alternative 8: 68.6% accurate, 16.4× speedup?

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

    1. Initial program 66.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 68.2%

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

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

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

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

        \[\leadsto -0.6666666666666666 \cdot \color{blue}{\frac{1}{\frac{a}{b}}} \]
      3. un-div-inv68.1%

        \[\leadsto \color{blue}{\frac{-0.6666666666666666}{\frac{a}{b}}} \]
    6. Applied egg-rr68.1%

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

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

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

    if -1.999999999999994e-310 < b

    1. Initial program 33.0%

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

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

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

Alternative 9: 68.6% accurate, 16.4× speedup?

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

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

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


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

    1. Initial program 66.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 68.2%

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

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

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

    if -1.999999999999994e-310 < b

    1. Initial program 33.0%

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

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

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

Alternative 10: 68.6% accurate, 16.4× speedup?

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

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

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


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

    1. Initial program 66.3%

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

      \[\leadsto \color{blue}{\left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right) \cdot \frac{1}{a \cdot -3}} \]
    3. Step-by-step derivation
      1. associate-/r*56.2%

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

      \[\leadsto \color{blue}{\left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right) \cdot \frac{\frac{1}{a}}{-3}} \]
    5. Step-by-step derivation
      1. associate-*r/56.2%

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

        \[\leadsto \color{blue}{\frac{-\left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right) \cdot \frac{1}{a}}{--3}} \]
      3. un-div-inv56.2%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{-\color{blue}{\left(\left(-\mathsf{hypot}\left(b, \sqrt{\left(c \cdot a\right) \cdot -3}\right)\right) + b\right)}}{a}}{3} \]
      4. distribute-neg-in56.2%

        \[\leadsto \frac{\frac{\color{blue}{\left(-\left(-\mathsf{hypot}\left(b, \sqrt{\left(c \cdot a\right) \cdot -3}\right)\right)\right) + \left(-b\right)}}{a}}{3} \]
      5. remove-double-neg56.2%

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{b \cdot -2}}{a}}{3} \]
    12. Taylor expanded in b around 0 68.2%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    13. Step-by-step derivation
      1. metadata-eval68.2%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{b}{\frac{3}{-2}}}}{a} \]
      6. metadata-eval68.3%

        \[\leadsto \frac{\frac{b}{\color{blue}{-1.5}}}{a} \]
      7. associate-/l/68.2%

        \[\leadsto \color{blue}{\frac{b}{a \cdot -1.5}} \]
    14. Simplified68.2%

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

    if -1.999999999999994e-310 < b

    1. Initial program 33.0%

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

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

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

Alternative 11: 68.6% accurate, 16.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -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.999999999999994e-310

    1. Initial program 66.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 68.2%

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

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

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

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

    if -1.999999999999994e-310 < b

    1. Initial program 33.0%

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

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

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

Alternative 12: 36.4% 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.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 33.3%

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

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

Reproduce

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