Cubic critical

Percentage Accurate: 51.5% → 85.3%
Time: 12.9s
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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 85.3% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 44.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 99.9%

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

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

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

    if -9.9999999999999999e144 < b < 3.25000000000000003e-105

    1. Initial program 81.9%

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

    if 3.25000000000000003e-105 < b

    1. Initial program 16.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 89.3%

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

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

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

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

Alternative 2: 80.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -6.5 \cdot 10^{-76}:\\ \;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\ \mathbf{elif}\;b \leq 2.8 \cdot 10^{-108}:\\ \;\;\;\;\frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -6.5e-76)
   (fma -0.6666666666666666 (/ b a) (* 0.5 (/ c b)))
   (if (<= b 2.8e-108)
     (/ (+ b (sqrt (* c (* a -3.0)))) (* 3.0 a))
     (/ (* c -0.5) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -6.5e-76) {
		tmp = fma(-0.6666666666666666, (b / a), (0.5 * (c / b)));
	} else if (b <= 2.8e-108) {
		tmp = (b + sqrt((c * (a * -3.0)))) / (3.0 * a);
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= -6.5e-76)
		tmp = fma(-0.6666666666666666, Float64(b / a), Float64(0.5 * Float64(c / b)));
	elseif (b <= 2.8e-108)
		tmp = Float64(Float64(b + sqrt(Float64(c * Float64(a * -3.0)))) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(c * -0.5) / b);
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-76], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.8e-108], N[(N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-76}:\\
\;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\

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

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


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

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

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. fma-def81.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)} \]
    4. Simplified81.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)} \]

    if -6.5e-76 < b < 2.8e-108

    1. Initial program 73.2%

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

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

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

        \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\left(-b\right) + \sqrt{-3 \cdot \left(a \cdot c\right)}\right)} - 1}}{3 \cdot a} \]
      3. add-sqr-sqrt16.9%

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

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

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

        \[\leadsto \frac{e^{\mathsf{log1p}\left(\color{blue}{\sqrt{b} \cdot \sqrt{b}} + \sqrt{-3 \cdot \left(a \cdot c\right)}\right)} - 1}{3 \cdot a} \]
      7. add-sqr-sqrt29.3%

        \[\leadsto \frac{e^{\mathsf{log1p}\left(\color{blue}{b} + \sqrt{-3 \cdot \left(a \cdot c\right)}\right)} - 1}{3 \cdot a} \]
      8. associate-*r*29.3%

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

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

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

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

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

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

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

    if 2.8e-108 < b

    1. Initial program 16.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 89.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6.5 \cdot 10^{-76}:\\ \;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\ \mathbf{elif}\;b \leq 2.8 \cdot 10^{-108}:\\ \;\;\;\;\frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 3: 80.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2.05 \cdot 10^{-76}:\\ \;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\ \mathbf{elif}\;b \leq 1.05 \cdot 10^{-106}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -2.05e-76)
   (fma -0.6666666666666666 (/ b a) (* 0.5 (/ c b)))
   (if (<= b 1.05e-106)
     (/ (- (sqrt (* a (* c -3.0))) b) (* 3.0 a))
     (/ (* c -0.5) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.05e-76) {
		tmp = fma(-0.6666666666666666, (b / a), (0.5 * (c / b)));
	} else if (b <= 1.05e-106) {
		tmp = (sqrt((a * (c * -3.0))) - b) / (3.0 * a);
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= -2.05e-76)
		tmp = fma(-0.6666666666666666, Float64(b / a), Float64(0.5 * Float64(c / b)));
	elseif (b <= 1.05e-106)
		tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(c * -0.5) / b);
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, -2.05e-76], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e-106], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.05 \cdot 10^{-76}:\\
\;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\

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

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


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

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

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. fma-def81.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)} \]
    4. Simplified81.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)} \]

    if -2.0499999999999999e-76 < b < 1.05000000000000002e-106

    1. Initial program 73.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. prod-diff72.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \color{blue}{\left(\left(-c\right) \cdot \left(3 \cdot a\right) + \left(3 \cdot a\right) \cdot c\right)}\right)}}{3 \cdot a} \]
      13. distribute-lft-neg-in72.9%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(\color{blue}{\left(-c \cdot \left(3 \cdot a\right)\right)} + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      14. distribute-rgt-neg-in72.9%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(-\color{blue}{a \cdot 3}\right) + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      16. distribute-rgt-neg-in72.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(-3 \cdot \left(a \cdot c\right) + \color{blue}{-3 \cdot \left(a \cdot c\right)}\right) + \left(a \cdot \left(3 \cdot c\right) + {b}^{2}\right)}}{3 \cdot a} \]
      12. distribute-rgt-out72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(a \cdot c\right)} \cdot -3} - b}{3 \cdot a} \]
      9. rem-square-sqrt0.0%

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

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

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

        \[\leadsto \frac{\sqrt{a \cdot \left(c \cdot \color{blue}{\left(\sqrt{-3} \cdot \sqrt{-3}\right)}\right)} - b}{3 \cdot a} \]
      13. rem-square-sqrt70.4%

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

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

    if 1.05000000000000002e-106 < b

    1. Initial program 16.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 89.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2.05 \cdot 10^{-76}:\\ \;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\ \mathbf{elif}\;b \leq 1.05 \cdot 10^{-106}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 4: 80.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -4.6 \cdot 10^{-74}:\\ \;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\ \mathbf{elif}\;b \leq 1.45 \cdot 10^{-104}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -4.6e-74)
   (fma -0.6666666666666666 (/ b a) (* 0.5 (/ c b)))
   (if (<= b 1.45e-104)
     (/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
     (/ (* c -0.5) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -4.6e-74) {
		tmp = fma(-0.6666666666666666, (b / a), (0.5 * (c / b)));
	} else if (b <= 1.45e-104) {
		tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a);
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= -4.6e-74)
		tmp = fma(-0.6666666666666666, Float64(b / a), Float64(0.5 * Float64(c / b)));
	elseif (b <= 1.45e-104)
		tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(c * -0.5) / b);
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, -4.6e-74], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.45e-104], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{-74}:\\
\;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\

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

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


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

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

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. fma-def81.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)} \]
    4. Simplified81.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)} \]

    if -4.59999999999999961e-74 < b < 1.4500000000000001e-104

    1. Initial program 73.2%

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

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

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

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

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

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

    if 1.4500000000000001e-104 < b

    1. Initial program 16.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 89.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.6 \cdot 10^{-74}:\\ \;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\ \mathbf{elif}\;b \leq 1.45 \cdot 10^{-104}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 5: 80.2% accurate, 1.0× speedup?

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

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

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

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


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

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

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

    if -1.4999999999999999e-75 < b < 9.99999999999999927e-105

    1. Initial program 73.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. prod-diff72.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \color{blue}{\left(\left(-c\right) \cdot \left(3 \cdot a\right) + \left(3 \cdot a\right) \cdot c\right)}\right)}}{3 \cdot a} \]
      13. distribute-lft-neg-in72.9%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(\color{blue}{\left(-c \cdot \left(3 \cdot a\right)\right)} + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      14. distribute-rgt-neg-in72.9%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(-\color{blue}{a \cdot 3}\right) + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      16. distribute-rgt-neg-in72.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(-3 \cdot \left(a \cdot c\right) + \color{blue}{-3 \cdot \left(a \cdot c\right)}\right) + \left(a \cdot \left(3 \cdot c\right) + {b}^{2}\right)}}{3 \cdot a} \]
      12. distribute-rgt-out72.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.3333333333333333 \cdot \color{blue}{\frac{1 \cdot \sqrt{-6 \cdot \left(a \cdot c\right) + 3 \cdot \left(a \cdot c\right)}}{a}} \]
      2. distribute-rgt-out69.4%

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

        \[\leadsto 0.3333333333333333 \cdot \frac{1 \cdot \sqrt{\color{blue}{\left(c \cdot a\right)} \cdot \left(-6 + 3\right)}}{a} \]
      4. metadata-eval69.4%

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

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

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

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

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{\color{blue}{\left(a \cdot c\right)} \cdot -3}}{a} \]
      9. rem-square-sqrt0.0%

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

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{\left(a \cdot c\right) \cdot \color{blue}{{\left(\sqrt{-3}\right)}^{2}}}}{a} \]
      11. associate-*r*0.0%

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{\color{blue}{a \cdot \left(c \cdot {\left(\sqrt{-3}\right)}^{2}\right)}}}{a} \]
      12. unpow20.0%

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot \color{blue}{\left(\sqrt{-3} \cdot \sqrt{-3}\right)}\right)}}{a} \]
      13. rem-square-sqrt69.5%

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

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

    if 9.99999999999999927e-105 < b

    1. Initial program 16.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 89.3%

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

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

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

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

Alternative 6: 80.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -3.7 \cdot 10^{-75}:\\ \;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\ \mathbf{elif}\;b \leq 2 \cdot 10^{-106}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -3.7e-75)
   (fma -0.6666666666666666 (/ b a) (* 0.5 (/ c b)))
   (if (<= b 2e-106)
     (* 0.3333333333333333 (/ (sqrt (* a (* c -3.0))) a))
     (/ (* c -0.5) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -3.7e-75) {
		tmp = fma(-0.6666666666666666, (b / a), (0.5 * (c / b)));
	} else if (b <= 2e-106) {
		tmp = 0.3333333333333333 * (sqrt((a * (c * -3.0))) / a);
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= -3.7e-75)
		tmp = fma(-0.6666666666666666, Float64(b / a), Float64(0.5 * Float64(c / b)));
	elseif (b <= 2e-106)
		tmp = Float64(0.3333333333333333 * Float64(sqrt(Float64(a * Float64(c * -3.0))) / a));
	else
		tmp = Float64(Float64(c * -0.5) / b);
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, -3.7e-75], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-106], N[(0.3333333333333333 * N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.7 \cdot 10^{-75}:\\
\;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\

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

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


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

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

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. fma-def81.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)} \]
    4. Simplified81.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)} \]

    if -3.70000000000000024e-75 < b < 1.99999999999999988e-106

    1. Initial program 73.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. prod-diff72.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \color{blue}{\left(\left(-c\right) \cdot \left(3 \cdot a\right) + \left(3 \cdot a\right) \cdot c\right)}\right)}}{3 \cdot a} \]
      13. distribute-lft-neg-in72.9%

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(\color{blue}{\left(-c \cdot \left(3 \cdot a\right)\right)} + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      14. distribute-rgt-neg-in72.9%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -3\right) + \left(c \cdot \left(-\color{blue}{a \cdot 3}\right) + \left(3 \cdot a\right) \cdot c\right)\right)}}{3 \cdot a} \]
      16. distribute-rgt-neg-in72.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(-3 \cdot \left(a \cdot c\right) + \color{blue}{-3 \cdot \left(a \cdot c\right)}\right) + \left(a \cdot \left(3 \cdot c\right) + {b}^{2}\right)}}{3 \cdot a} \]
      12. distribute-rgt-out72.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.3333333333333333 \cdot \color{blue}{\frac{1 \cdot \sqrt{-6 \cdot \left(a \cdot c\right) + 3 \cdot \left(a \cdot c\right)}}{a}} \]
      2. distribute-rgt-out69.4%

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

        \[\leadsto 0.3333333333333333 \cdot \frac{1 \cdot \sqrt{\color{blue}{\left(c \cdot a\right)} \cdot \left(-6 + 3\right)}}{a} \]
      4. metadata-eval69.4%

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

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

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

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

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{\color{blue}{\left(a \cdot c\right)} \cdot -3}}{a} \]
      9. rem-square-sqrt0.0%

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

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{\left(a \cdot c\right) \cdot \color{blue}{{\left(\sqrt{-3}\right)}^{2}}}}{a} \]
      11. associate-*r*0.0%

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{\color{blue}{a \cdot \left(c \cdot {\left(\sqrt{-3}\right)}^{2}\right)}}}{a} \]
      12. unpow20.0%

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot \color{blue}{\left(\sqrt{-3} \cdot \sqrt{-3}\right)}\right)}}{a} \]
      13. rem-square-sqrt69.5%

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

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

    if 1.99999999999999988e-106 < b

    1. Initial program 16.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 89.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -3.7 \cdot 10^{-75}:\\ \;\;\;\;\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)\\ \mathbf{elif}\;b \leq 2 \cdot 10^{-106}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 7: 68.1% accurate, 8.9× speedup?

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

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

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


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

    1. Initial program 74.2%

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

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

    if -4.999999999999985e-310 < b

    1. Initial program 27.6%

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

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

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

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

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

Alternative 8: 67.9% accurate, 12.8× speedup?

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

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

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


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

    1. Initial program 73.5%

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

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

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

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

    if 3.10000000000000004e-283 < b

    1. Initial program 26.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 74.8%

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

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

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

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

Alternative 9: 48.7% accurate, 16.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.1 \cdot 10^{-283}:\\
\;\;\;\;\frac{b}{a} \cdot -0.3333333333333333\\

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


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

    1. Initial program 73.5%

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

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

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

    if 3.10000000000000004e-283 < b

    1. Initial program 26.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 74.8%

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

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

Alternative 10: 67.9% accurate, 16.4× speedup?

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

    1. Initial program 73.5%

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

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

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

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

    if 3.10000000000000004e-283 < b

    1. Initial program 26.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 74.8%

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

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

Alternative 11: 67.9% accurate, 16.4× speedup?

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

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

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


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

    1. Initial program 73.5%

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

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

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

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

    if 3.10000000000000004e-283 < b

    1. Initial program 26.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 74.8%

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

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

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

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

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

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

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

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

Reproduce

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