Cubic critical

Percentage Accurate: 51.9% → 83.9%
Time: 14.3s
Alternatives: 10
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 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 51.9% 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: 83.9% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -6.8 \cdot 10^{+41}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\ \mathbf{elif}\;b \leq 2.2 \cdot 10^{-94} \lor \neg \left(b \leq 3.1 \cdot 10^{-80}\right) \land b \leq 0.135:\\ \;\;\;\;\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 -6.8e+41)
   (/ (/ (* b -2.0) a) 3.0)
   (if (or (<= b 2.2e-94) (and (not (<= b 3.1e-80)) (<= b 0.135)))
     (/ (- (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 <= -6.8e+41) {
		tmp = ((b * -2.0) / a) / 3.0;
	} else if ((b <= 2.2e-94) || (!(b <= 3.1e-80) && (b <= 0.135))) {
		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 <= (-6.8d+41)) then
        tmp = ((b * (-2.0d0)) / a) / 3.0d0
    else if ((b <= 2.2d-94) .or. (.not. (b <= 3.1d-80)) .and. (b <= 0.135d0)) 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 <= -6.8e+41) {
		tmp = ((b * -2.0) / a) / 3.0;
	} else if ((b <= 2.2e-94) || (!(b <= 3.1e-80) && (b <= 0.135))) {
		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 <= -6.8e+41:
		tmp = ((b * -2.0) / a) / 3.0
	elif (b <= 2.2e-94) or (not (b <= 3.1e-80) and (b <= 0.135)):
		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 <= -6.8e+41)
		tmp = Float64(Float64(Float64(b * -2.0) / a) / 3.0);
	elseif ((b <= 2.2e-94) || (!(b <= 3.1e-80) && (b <= 0.135)))
		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 <= -6.8e+41)
		tmp = ((b * -2.0) / a) / 3.0;
	elseif ((b <= 2.2e-94) || (~((b <= 3.1e-80)) && (b <= 0.135)))
		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, -6.8e+41], N[(N[(N[(b * -2.0), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[Or[LessEqual[b, 2.2e-94], And[N[Not[LessEqual[b, 3.1e-80]], $MachinePrecision], LessEqual[b, 0.135]]], 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 -6.8 \cdot 10^{+41}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\

\mathbf{elif}\;b \leq 2.2 \cdot 10^{-94} \lor \neg \left(b \leq 3.1 \cdot 10^{-80}\right) \land b \leq 0.135:\\
\;\;\;\;\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 < -6.79999999999999996e41

    1. Initial program 58.9%

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{b \cdot -2}}{3 \cdot a} \]
    7. Step-by-step derivation
      1. expm1-log1p-u54.8%

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b \cdot -2}{3 \cdot a}\right)} - 1} \]
      3. times-frac44.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{b}{3} \cdot \frac{-2}{a}}\right)} - 1 \]
    8. Applied egg-rr44.8%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(b \cdot -2\right) \cdot \frac{1}{3 \cdot a}} \]
      8. associate-*l*97.2%

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

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

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

        \[\leadsto b \cdot \color{blue}{\frac{-2 \cdot 0.3333333333333333}{a}} \]
      12. metadata-eval97.1%

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

      \[\leadsto \color{blue}{b \cdot \frac{-0.6666666666666666}{a}} \]
    11. Step-by-step derivation
      1. clear-num97.1%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot -2}{a}}{3}} \]
    12. Applied egg-rr97.3%

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

    if -6.79999999999999996e41 < b < 2.20000000000000001e-94 or 3.10000000000000016e-80 < b < 0.13500000000000001

    1. Initial program 80.3%

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

    if 2.20000000000000001e-94 < b < 3.10000000000000016e-80 or 0.13500000000000001 < b

    1. Initial program 16.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. sqr-neg16.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6.8 \cdot 10^{+41}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\ \mathbf{elif}\;b \leq 2.2 \cdot 10^{-94} \lor \neg \left(b \leq 3.1 \cdot 10^{-80}\right) \land b \leq 0.135:\\ \;\;\;\;\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: 83.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -9.2 \cdot 10^{+38}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\ \mathbf{elif}\;b \leq 2.1 \cdot 10^{-94} \lor \neg \left(b \leq 1.04 \cdot 10^{-78}\right) \land b \leq 0.135:\\ \;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{\frac{a}{0.3333333333333333}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -9.2e+38)
   (/ (/ (* b -2.0) a) 3.0)
   (if (or (<= b 2.1e-94) (and (not (<= b 1.04e-78)) (<= b 0.135)))
     (/ (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) (/ a 0.3333333333333333))
     (* -0.5 (/ c b)))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -9.2e+38) {
		tmp = ((b * -2.0) / a) / 3.0;
	} else if ((b <= 2.1e-94) || (!(b <= 1.04e-78) && (b <= 0.135))) {
		tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333);
	} 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 <= (-9.2d+38)) then
        tmp = ((b * (-2.0d0)) / a) / 3.0d0
    else if ((b <= 2.1d-94) .or. (.not. (b <= 1.04d-78)) .and. (b <= 0.135d0)) then
        tmp = (sqrt(((b * b) - (a * (3.0d0 * c)))) - b) / (a / 0.3333333333333333d0)
    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 <= -9.2e+38) {
		tmp = ((b * -2.0) / a) / 3.0;
	} else if ((b <= 2.1e-94) || (!(b <= 1.04e-78) && (b <= 0.135))) {
		tmp = (Math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333);
	} else {
		tmp = -0.5 * (c / b);
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -9.2e+38:
		tmp = ((b * -2.0) / a) / 3.0
	elif (b <= 2.1e-94) or (not (b <= 1.04e-78) and (b <= 0.135)):
		tmp = (math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333)
	else:
		tmp = -0.5 * (c / b)
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -9.2e+38)
		tmp = Float64(Float64(Float64(b * -2.0) / a) / 3.0);
	elseif ((b <= 2.1e-94) || (!(b <= 1.04e-78) && (b <= 0.135)))
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) / Float64(a / 0.3333333333333333));
	else
		tmp = Float64(-0.5 * Float64(c / b));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -9.2e+38)
		tmp = ((b * -2.0) / a) / 3.0;
	elseif ((b <= 2.1e-94) || (~((b <= 1.04e-78)) && (b <= 0.135)))
		tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333);
	else
		tmp = -0.5 * (c / b);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -9.2e+38], N[(N[(N[(b * -2.0), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[Or[LessEqual[b, 2.1e-94], And[N[Not[LessEqual[b, 1.04e-78]], $MachinePrecision], LessEqual[b, 0.135]]], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a / 0.3333333333333333), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;b \leq 2.1 \cdot 10^{-94} \lor \neg \left(b \leq 1.04 \cdot 10^{-78}\right) \land b \leq 0.135:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{\frac{a}{0.3333333333333333}}\\

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


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

    1. Initial program 59.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b \cdot -2}{3 \cdot a}\right)} - 1} \]
      3. times-frac45.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{b}{3} \cdot \frac{-2}{a}}\right)} - 1 \]
    8. Applied egg-rr45.4%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(b \cdot -2\right) \cdot \frac{1}{3 \cdot a}} \]
      8. associate-*l*97.2%

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

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

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

        \[\leadsto b \cdot \color{blue}{\frac{-2 \cdot 0.3333333333333333}{a}} \]
      12. metadata-eval97.1%

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

      \[\leadsto \color{blue}{b \cdot \frac{-0.6666666666666666}{a}} \]
    11. Step-by-step derivation
      1. clear-num97.1%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot -2}{a}}{3}} \]
    12. Applied egg-rr97.4%

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

    if -9.2000000000000005e38 < b < 2.1000000000000001e-94 or 1.03999999999999997e-78 < b < 0.13500000000000001

    1. Initial program 80.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-sub080.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-neg80.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-80.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-neg80.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-180.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. Simplified79.9%

      \[\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. associate-*r*79.8%

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

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

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

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

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

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

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

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

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

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

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

    if 2.1000000000000001e-94 < b < 1.03999999999999997e-78 or 0.13500000000000001 < b

    1. Initial program 16.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. sqr-neg16.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -9.2 \cdot 10^{+38}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\ \mathbf{elif}\;b \leq 2.1 \cdot 10^{-94} \lor \neg \left(b \leq 1.04 \cdot 10^{-78}\right) \land b \leq 0.135:\\ \;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{\frac{a}{0.3333333333333333}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]

Alternative 3: 83.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -9.2 \cdot 10^{+38}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\ \mathbf{elif}\;b \leq 6 \cdot 10^{-95}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{\frac{a}{0.3333333333333333}}\\ \mathbf{elif}\;b \leq 3.5 \cdot 10^{-80} \lor \neg \left(b \leq 0.7\right):\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -9.2e+38)
   (/ (/ (* b -2.0) a) 3.0)
   (if (<= b 6e-95)
     (/ (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) (/ a 0.3333333333333333))
     (if (or (<= b 3.5e-80) (not (<= b 0.7)))
       (* -0.5 (/ c b))
       (/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -9.2e+38) {
		tmp = ((b * -2.0) / a) / 3.0;
	} else if (b <= 6e-95) {
		tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333);
	} else if ((b <= 3.5e-80) || !(b <= 0.7)) {
		tmp = -0.5 * (c / b);
	} else {
		tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= (-9.2d+38)) then
        tmp = ((b * (-2.0d0)) / a) / 3.0d0
    else if (b <= 6d-95) then
        tmp = (sqrt(((b * b) - (a * (3.0d0 * c)))) - b) / (a / 0.3333333333333333d0)
    else if ((b <= 3.5d-80) .or. (.not. (b <= 0.7d0))) then
        tmp = (-0.5d0) * (c / b)
    else
        tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -9.2e+38) {
		tmp = ((b * -2.0) / a) / 3.0;
	} else if (b <= 6e-95) {
		tmp = (Math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333);
	} else if ((b <= 3.5e-80) || !(b <= 0.7)) {
		tmp = -0.5 * (c / b);
	} else {
		tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -9.2e+38:
		tmp = ((b * -2.0) / a) / 3.0
	elif b <= 6e-95:
		tmp = (math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333)
	elif (b <= 3.5e-80) or not (b <= 0.7):
		tmp = -0.5 * (c / b)
	else:
		tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0)
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -9.2e+38)
		tmp = Float64(Float64(Float64(b * -2.0) / a) / 3.0);
	elseif (b <= 6e-95)
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) / Float64(a / 0.3333333333333333));
	elseif ((b <= 3.5e-80) || !(b <= 0.7))
		tmp = Float64(-0.5 * Float64(c / b));
	else
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -9.2e+38)
		tmp = ((b * -2.0) / a) / 3.0;
	elseif (b <= 6e-95)
		tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333);
	elseif ((b <= 3.5e-80) || ~((b <= 0.7)))
		tmp = -0.5 * (c / b);
	else
		tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -9.2e+38], N[(N[(N[(b * -2.0), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 6e-95], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a / 0.3333333333333333), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, 3.5e-80], N[Not[LessEqual[b, 0.7]], $MachinePrecision]], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;b \leq 3.5 \cdot 10^{-80} \lor \neg \left(b \leq 0.7\right):\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if b < -9.2000000000000005e38

    1. Initial program 59.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b \cdot -2}{3 \cdot a}\right)} - 1} \]
      3. times-frac45.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{b}{3} \cdot \frac{-2}{a}}\right)} - 1 \]
    8. Applied egg-rr45.4%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(b \cdot -2\right) \cdot \frac{1}{3 \cdot a}} \]
      8. associate-*l*97.2%

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

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

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

        \[\leadsto b \cdot \color{blue}{\frac{-2 \cdot 0.3333333333333333}{a}} \]
      12. metadata-eval97.1%

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

      \[\leadsto \color{blue}{b \cdot \frac{-0.6666666666666666}{a}} \]
    11. Step-by-step derivation
      1. clear-num97.1%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot -2}{a}}{3}} \]
    12. Applied egg-rr97.4%

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

    if -9.2000000000000005e38 < b < 6e-95

    1. Initial program 84.2%

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

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

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

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

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

        \[\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. Simplified84.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. associate-*r*84.0%

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

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

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

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

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

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

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

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

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

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

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

    if 6e-95 < b < 3.50000000000000015e-80 or 0.69999999999999996 < b

    1. Initial program 16.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. sqr-neg16.6%

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

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

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

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

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

    if 3.50000000000000015e-80 < b < 0.69999999999999996

    1. Initial program 57.7%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -9.2 \cdot 10^{+38}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\ \mathbf{elif}\;b \leq 6 \cdot 10^{-95}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{\frac{a}{0.3333333333333333}}\\ \mathbf{elif}\;b \leq 3.5 \cdot 10^{-80} \lor \neg \left(b \leq 0.7\right):\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\ \end{array} \]

Alternative 4: 81.1% accurate, 1.0× speedup?

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

\mathbf{elif}\;b \leq 3.9 \cdot 10^{-95}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \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 < -6.5000000000000002e-74

    1. Initial program 67.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b \cdot -2}{3 \cdot a}\right)} - 1} \]
      3. times-frac42.0%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{b}{3} \cdot \frac{-2}{a}}\right)} - 1 \]
    8. Applied egg-rr42.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b \cdot -2}{3 \cdot a}} \]
      6. *-rgt-identity93.1%

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

        \[\leadsto \color{blue}{\left(b \cdot -2\right) \cdot \frac{1}{3 \cdot a}} \]
      8. associate-*l*93.1%

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

        \[\leadsto b \cdot \left(-2 \cdot \color{blue}{\frac{\frac{1}{3}}{a}}\right) \]
      10. metadata-eval93.0%

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

        \[\leadsto b \cdot \color{blue}{\frac{-2 \cdot 0.3333333333333333}{a}} \]
      12. metadata-eval93.0%

        \[\leadsto b \cdot \frac{\color{blue}{-0.6666666666666666}}{a} \]
    10. Simplified93.0%

      \[\leadsto \color{blue}{b \cdot \frac{-0.6666666666666666}{a}} \]
    11. Step-by-step derivation
      1. clear-num93.0%

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

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

        \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
      4. metadata-eval93.0%

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

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot -2}{a}}{3}} \]
    12. Applied egg-rr93.2%

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

    if -6.5000000000000002e-74 < b < 3.9e-95

    1. Initial program 80.2%

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

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

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

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

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

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

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

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

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

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

    if 3.9e-95 < b

    1. Initial program 23.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6.5 \cdot 10^{-74}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{a}}{3}\\ \mathbf{elif}\;b \leq 3.9 \cdot 10^{-95}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]

Alternative 5: 67.9% accurate, 12.8× speedup?

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b \cdot -2}{3 \cdot a}\right)} - 1} \]
      3. times-frac34.2%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{b}{3} \cdot \frac{-2}{a}}\right)} - 1 \]
    8. Applied egg-rr34.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b \cdot -2}{3 \cdot a}} \]
      6. *-rgt-identity76.1%

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

        \[\leadsto \color{blue}{\left(b \cdot -2\right) \cdot \frac{1}{3 \cdot a}} \]
      8. associate-*l*76.0%

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

        \[\leadsto b \cdot \left(-2 \cdot \color{blue}{\frac{\frac{1}{3}}{a}}\right) \]
      10. metadata-eval76.0%

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

        \[\leadsto b \cdot \color{blue}{\frac{-2 \cdot 0.3333333333333333}{a}} \]
      12. metadata-eval76.0%

        \[\leadsto b \cdot \frac{\color{blue}{-0.6666666666666666}}{a} \]
    10. Simplified76.0%

      \[\leadsto \color{blue}{b \cdot \frac{-0.6666666666666666}{a}} \]
    11. Step-by-step derivation
      1. clear-num76.0%

        \[\leadsto b \cdot \color{blue}{\frac{1}{\frac{a}{-0.6666666666666666}}} \]
      2. div-inv76.0%

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

        \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
      4. metadata-eval76.0%

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot -2}{3}}{a}} \]
    12. Applied egg-rr76.1%

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

    if -1.999999999999994e-310 < b

    1. Initial program 36.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. sqr-neg36.3%

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

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

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

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

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

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

Alternative 6: 67.8% accurate, 12.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\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 -2e-310) (/ (/ (* b -2.0) a) 3.0) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -2e-310) {
		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 <= (-2d-310)) 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 <= -2e-310) {
		tmp = ((b * -2.0) / a) / 3.0;
	} else {
		tmp = -0.5 * (c / b);
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -2e-310:
		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 <= -2e-310)
		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 <= -2e-310)
		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, -2e-310], 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 -2 \cdot 10^{-310}:\\
\;\;\;\;\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.999999999999994e-310

    1. Initial program 72.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b \cdot -2}{3 \cdot a}\right)} - 1} \]
      3. times-frac34.2%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{b}{3} \cdot \frac{-2}{a}}\right)} - 1 \]
    8. Applied egg-rr34.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b \cdot -2}{3 \cdot a}} \]
      6. *-rgt-identity76.1%

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

        \[\leadsto \color{blue}{\left(b \cdot -2\right) \cdot \frac{1}{3 \cdot a}} \]
      8. associate-*l*76.0%

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

        \[\leadsto b \cdot \left(-2 \cdot \color{blue}{\frac{\frac{1}{3}}{a}}\right) \]
      10. metadata-eval76.0%

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

        \[\leadsto b \cdot \color{blue}{\frac{-2 \cdot 0.3333333333333333}{a}} \]
      12. metadata-eval76.0%

        \[\leadsto b \cdot \frac{\color{blue}{-0.6666666666666666}}{a} \]
    10. Simplified76.0%

      \[\leadsto \color{blue}{b \cdot \frac{-0.6666666666666666}{a}} \]
    11. Step-by-step derivation
      1. clear-num76.0%

        \[\leadsto b \cdot \color{blue}{\frac{1}{\frac{a}{-0.6666666666666666}}} \]
      2. div-inv76.0%

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

        \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
      4. metadata-eval76.0%

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

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot -2}{a}}{3}} \]
    12. Applied egg-rr76.2%

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

    if -1.999999999999994e-310 < b

    1. Initial program 36.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. sqr-neg36.3%

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

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

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

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

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

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

Alternative 7: 67.9% accurate, 16.4× speedup?

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

    1. Initial program 72.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. sqr-neg72.6%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b \cdot -2}{3 \cdot a}\right)} - 1} \]
      3. times-frac34.2%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{b}{3} \cdot \frac{-2}{a}}\right)} - 1 \]
    8. Applied egg-rr34.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b \cdot -2}{3 \cdot a}} \]
      6. *-rgt-identity76.1%

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

        \[\leadsto \color{blue}{\left(b \cdot -2\right) \cdot \frac{1}{3 \cdot a}} \]
      8. associate-*l*76.0%

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

        \[\leadsto b \cdot \left(-2 \cdot \color{blue}{\frac{\frac{1}{3}}{a}}\right) \]
      10. metadata-eval76.0%

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

        \[\leadsto b \cdot \color{blue}{\frac{-2 \cdot 0.3333333333333333}{a}} \]
      12. metadata-eval76.0%

        \[\leadsto b \cdot \frac{\color{blue}{-0.6666666666666666}}{a} \]
    10. Simplified76.0%

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

    if 3.00000000000000022e-308 < b

    1. Initial program 36.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. sqr-neg36.3%

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

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

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

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

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

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

Alternative 8: 67.9% accurate, 16.4× speedup?

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

    1. Initial program 72.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. sqr-neg72.6%

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

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

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

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

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

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

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

    if 4.99999999999999955e-308 < b

    1. Initial program 36.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. sqr-neg36.3%

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

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

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

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

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

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

Alternative 9: 67.9% 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 72.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. sqr-neg72.6%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b \cdot -2}{3 \cdot a}\right)} - 1} \]
      3. times-frac34.2%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{b}{3} \cdot \frac{-2}{a}}\right)} - 1 \]
    8. Applied egg-rr34.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b \cdot -2}{3 \cdot a}} \]
      6. *-rgt-identity76.1%

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

        \[\leadsto \color{blue}{\left(b \cdot -2\right) \cdot \frac{1}{3 \cdot a}} \]
      8. associate-*l*76.0%

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

        \[\leadsto b \cdot \left(-2 \cdot \color{blue}{\frac{\frac{1}{3}}{a}}\right) \]
      10. metadata-eval76.0%

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

        \[\leadsto b \cdot \color{blue}{\frac{-2 \cdot 0.3333333333333333}{a}} \]
      12. metadata-eval76.0%

        \[\leadsto b \cdot \frac{\color{blue}{-0.6666666666666666}}{a} \]
    10. Simplified76.0%

      \[\leadsto \color{blue}{b \cdot \frac{-0.6666666666666666}{a}} \]
    11. Step-by-step derivation
      1. clear-num76.0%

        \[\leadsto b \cdot \color{blue}{\frac{1}{\frac{a}{-0.6666666666666666}}} \]
      2. div-inv76.0%

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

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

        \[\leadsto \frac{b}{a \cdot \color{blue}{-1.5}} \]
    12. Applied egg-rr76.1%

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

    if -1.999999999999994e-310 < b

    1. Initial program 36.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. sqr-neg36.3%

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

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

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

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

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

    \[\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 10: 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 54.4%

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

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

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

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

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

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

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

Reproduce

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