Cubic critical

Percentage Accurate: 52.2% → 84.9%
Time: 13.5s
Alternatives: 8
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 8 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: 52.2% accurate, 1.0× speedup?

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

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

Alternative 1: 84.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -4.4 \cdot 10^{+55}:\\ \;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\ \mathbf{elif}\;b \leq 1.15 \cdot 10^{-40}:\\ \;\;\;\;\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 -4.4e+55)
   (/ (* b -2.0) (* 3.0 a))
   (if (<= b 1.15e-40)
     (/ (- (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 <= -4.4e+55) {
		tmp = (b * -2.0) / (3.0 * a);
	} else if (b <= 1.15e-40) {
		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 <= (-4.4d+55)) then
        tmp = (b * (-2.0d0)) / (3.0d0 * a)
    else if (b <= 1.15d-40) 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 <= -4.4e+55) {
		tmp = (b * -2.0) / (3.0 * a);
	} else if (b <= 1.15e-40) {
		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 <= -4.4e+55:
		tmp = (b * -2.0) / (3.0 * a)
	elif b <= 1.15e-40:
		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 <= -4.4e+55)
		tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a));
	elseif (b <= 1.15e-40)
		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 <= -4.4e+55)
		tmp = (b * -2.0) / (3.0 * a);
	elseif (b <= 1.15e-40)
		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, -4.4e+55], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.15e-40], 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 -4.4 \cdot 10^{+55}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\

\mathbf{elif}\;b \leq 1.15 \cdot 10^{-40}:\\
\;\;\;\;\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 < -4.40000000000000021e55

    1. Initial program 65.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 95.8%

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

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

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

    if -4.40000000000000021e55 < b < 1.15e-40

    1. Initial program 77.8%

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

    if 1.15e-40 < b

    1. Initial program 15.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 90.0%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative90.0%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/90.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.4 \cdot 10^{+55}:\\ \;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\ \mathbf{elif}\;b \leq 1.15 \cdot 10^{-40}:\\ \;\;\;\;\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.7% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;b \leq 1.4 \cdot 10^{-40}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left({\left(c \cdot \frac{a}{-0.3333333333333333}\right)}^{0.5} - b\right)\\

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


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

    1. Initial program 70.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 88.6%

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

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

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

    if -5.29999999999999999e-71 < b < 1.4e-40

    1. Initial program 75.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. add-sqr-sqrt75.3%

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + {\left({\color{blue}{\left(\left(-\left(3 \cdot a\right) \cdot c\right) + b \cdot b\right)}}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{3 \cdot a} \]
      7. distribute-lft-neg-in75.3%

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

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

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\color{blue}{\left(a \cdot \left(-3\right)\right)} \cdot c + b \cdot b\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{3 \cdot a} \]
      10. metadata-eval75.3%

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

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\color{blue}{a \cdot \left(-3 \cdot c\right)} + b \cdot b\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{3 \cdot a} \]
      12. *-commutative75.2%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(a \cdot \color{blue}{\left(c \cdot -3\right)} + b \cdot b\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{3 \cdot a} \]
      13. fma-udef75.2%

        \[\leadsto \frac{\left(-b\right) + {\left({\color{blue}{\left(\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{3 \cdot a} \]
      14. pow275.2%

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

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)\right)}^{\color{blue}{0.25}}\right)}^{2}}{3 \cdot a} \]
    3. Applied egg-rr75.2%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{{\left({\left(\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)\right)}^{0.25}\right)}^{2}}}{3 \cdot a} \]
    4. Taylor expanded in c around -inf 40.1%

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{{\left(e^{0.25 \cdot \left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)}\right)}^{2} - b}{a}} \]
    5. Step-by-step derivation
      1. unpow240.1%

        \[\leadsto 0.3333333333333333 \cdot \frac{\color{blue}{e^{0.25 \cdot \left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)} \cdot e^{0.25 \cdot \left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)}} - b}{a} \]
      2. exp-prod39.3%

        \[\leadsto 0.3333333333333333 \cdot \frac{\color{blue}{{\left(e^{0.25}\right)}^{\left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)}} \cdot e^{0.25 \cdot \left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)} - b}{a} \]
      3. exp-prod38.6%

        \[\leadsto 0.3333333333333333 \cdot \frac{{\left(e^{0.25}\right)}^{\left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)} \cdot \color{blue}{{\left(e^{0.25}\right)}^{\left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)}} - b}{a} \]
      4. pow-sqr38.6%

        \[\leadsto 0.3333333333333333 \cdot \frac{\color{blue}{{\left(e^{0.25}\right)}^{\left(2 \cdot \left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)\right)}} - b}{a} \]
      5. mul-1-neg38.6%

        \[\leadsto 0.3333333333333333 \cdot \frac{{\left(e^{0.25}\right)}^{\left(2 \cdot \left(\log \left(3 \cdot a\right) + \color{blue}{\left(-\log \left(\frac{-1}{c}\right)\right)}\right)\right)} - b}{a} \]
      6. unsub-neg38.6%

        \[\leadsto 0.3333333333333333 \cdot \frac{{\left(e^{0.25}\right)}^{\left(2 \cdot \color{blue}{\left(\log \left(3 \cdot a\right) - \log \left(\frac{-1}{c}\right)\right)}\right)} - b}{a} \]
      7. *-commutative38.6%

        \[\leadsto 0.3333333333333333 \cdot \frac{{\left(e^{0.25}\right)}^{\left(2 \cdot \left(\log \color{blue}{\left(a \cdot 3\right)} - \log \left(\frac{-1}{c}\right)\right)\right)} - b}{a} \]
    6. Simplified38.6%

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{{\left(e^{0.25}\right)}^{\left(2 \cdot \left(\log \left(a \cdot 3\right) - \log \left(\frac{-1}{c}\right)\right)\right)} - b}{a}} \]
    7. Taylor expanded in a around 0 39.8%

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{e^{0.5 \cdot \left(\left(\log 3 + \log a\right) - \log \left(\frac{-1}{c}\right)\right)} - b}{a}} \]
    8. Simplified66.3%

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

    if 1.4e-40 < b

    1. Initial program 15.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 90.0%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative90.0%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/90.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5.3 \cdot 10^{-71}:\\ \;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\ \mathbf{elif}\;b \leq 1.4 \cdot 10^{-40}:\\ \;\;\;\;\frac{0.3333333333333333}{a} \cdot \left({\left(c \cdot \frac{a}{-0.3333333333333333}\right)}^{0.5} - b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternative 3: 80.7% accurate, 1.0× speedup?

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

\mathbf{elif}\;b \leq 1.35 \cdot 10^{-40}:\\
\;\;\;\;\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 < -1.14999999999999998e-68

    1. Initial program 70.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 88.6%

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

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

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

    if -1.14999999999999998e-68 < b < 1.35e-40

    1. Initial program 75.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 66.2%

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

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

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

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

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

    if 1.35e-40 < b

    1. Initial program 15.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 90.0%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative90.0%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/90.1%

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

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

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

Alternative 4: 80.0% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;b \leq 1.5 \cdot 10^{-40}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{{\left(c \cdot \frac{a}{-0.3333333333333333}\right)}^{0.5}}{a}\\

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


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

    1. Initial program 72.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 84.6%

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

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

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

    if -9.60000000000000034e-119 < b < 1.5000000000000001e-40

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + {\left({\left(a \cdot \color{blue}{\left(c \cdot -3\right)} + b \cdot b\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{3 \cdot a} \]
      13. fma-udef72.5%

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

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

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)\right)}^{\color{blue}{0.25}}\right)}^{2}}{3 \cdot a} \]
    3. Applied egg-rr72.5%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{{\left({\left(\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)\right)}^{0.25}\right)}^{2}}}{3 \cdot a} \]
    4. Taylor expanded in c around -inf 44.1%

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{{\left(e^{0.25 \cdot \left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)}\right)}^{2} - b}{a}} \]
    5. Step-by-step derivation
      1. unpow244.1%

        \[\leadsto 0.3333333333333333 \cdot \frac{\color{blue}{e^{0.25 \cdot \left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)} \cdot e^{0.25 \cdot \left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)}} - b}{a} \]
      2. exp-prod43.3%

        \[\leadsto 0.3333333333333333 \cdot \frac{\color{blue}{{\left(e^{0.25}\right)}^{\left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)}} \cdot e^{0.25 \cdot \left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)} - b}{a} \]
      3. exp-prod42.5%

        \[\leadsto 0.3333333333333333 \cdot \frac{{\left(e^{0.25}\right)}^{\left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)} \cdot \color{blue}{{\left(e^{0.25}\right)}^{\left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)}} - b}{a} \]
      4. pow-sqr42.5%

        \[\leadsto 0.3333333333333333 \cdot \frac{\color{blue}{{\left(e^{0.25}\right)}^{\left(2 \cdot \left(\log \left(3 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{c}\right)\right)\right)}} - b}{a} \]
      5. mul-1-neg42.5%

        \[\leadsto 0.3333333333333333 \cdot \frac{{\left(e^{0.25}\right)}^{\left(2 \cdot \left(\log \left(3 \cdot a\right) + \color{blue}{\left(-\log \left(\frac{-1}{c}\right)\right)}\right)\right)} - b}{a} \]
      6. unsub-neg42.5%

        \[\leadsto 0.3333333333333333 \cdot \frac{{\left(e^{0.25}\right)}^{\left(2 \cdot \color{blue}{\left(\log \left(3 \cdot a\right) - \log \left(\frac{-1}{c}\right)\right)}\right)} - b}{a} \]
      7. *-commutative42.5%

        \[\leadsto 0.3333333333333333 \cdot \frac{{\left(e^{0.25}\right)}^{\left(2 \cdot \left(\log \color{blue}{\left(a \cdot 3\right)} - \log \left(\frac{-1}{c}\right)\right)\right)} - b}{a} \]
    6. Simplified42.5%

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{{\left(e^{0.25}\right)}^{\left(2 \cdot \left(\log \left(a \cdot 3\right) - \log \left(\frac{-1}{c}\right)\right)\right)} - b}{a}} \]
    7. Taylor expanded in b around 0 43.8%

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{e^{0.5 \cdot \left(\log \left(3 \cdot a\right) - \log \left(\frac{-1}{c}\right)\right)}}{a}} \]
    8. Step-by-step derivation
      1. *-commutative43.8%

        \[\leadsto 0.3333333333333333 \cdot \frac{e^{\color{blue}{\left(\log \left(3 \cdot a\right) - \log \left(\frac{-1}{c}\right)\right) \cdot 0.5}}}{a} \]
      2. log-prod43.5%

        \[\leadsto 0.3333333333333333 \cdot \frac{e^{\left(\color{blue}{\left(\log 3 + \log a\right)} - \log \left(\frac{-1}{c}\right)\right) \cdot 0.5}}{a} \]
      3. +-commutative43.5%

        \[\leadsto 0.3333333333333333 \cdot \frac{e^{\left(\color{blue}{\left(\log a + \log 3\right)} - \log \left(\frac{-1}{c}\right)\right) \cdot 0.5}}{a} \]
      4. log-prod43.8%

        \[\leadsto 0.3333333333333333 \cdot \frac{e^{\left(\color{blue}{\log \left(a \cdot 3\right)} - \log \left(\frac{-1}{c}\right)\right) \cdot 0.5}}{a} \]
      5. log-div63.5%

        \[\leadsto 0.3333333333333333 \cdot \frac{e^{\color{blue}{\log \left(\frac{a \cdot 3}{\frac{-1}{c}}\right)} \cdot 0.5}}{a} \]
      6. exp-to-pow67.8%

        \[\leadsto 0.3333333333333333 \cdot \frac{\color{blue}{{\left(\frac{a \cdot 3}{\frac{-1}{c}}\right)}^{0.5}}}{a} \]
      7. associate-/r/67.8%

        \[\leadsto 0.3333333333333333 \cdot \frac{{\color{blue}{\left(\frac{a \cdot 3}{-1} \cdot c\right)}}^{0.5}}{a} \]
      8. *-commutative67.8%

        \[\leadsto 0.3333333333333333 \cdot \frac{{\color{blue}{\left(c \cdot \frac{a \cdot 3}{-1}\right)}}^{0.5}}{a} \]
      9. associate-/l*67.9%

        \[\leadsto 0.3333333333333333 \cdot \frac{{\left(c \cdot \color{blue}{\frac{a}{\frac{-1}{3}}}\right)}^{0.5}}{a} \]
      10. metadata-eval67.9%

        \[\leadsto 0.3333333333333333 \cdot \frac{{\left(c \cdot \frac{a}{\color{blue}{-0.3333333333333333}}\right)}^{0.5}}{a} \]
    9. Simplified67.9%

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

    if 1.5000000000000001e-40 < b

    1. Initial program 15.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 90.0%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative90.0%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/90.1%

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

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

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

Alternative 5: 67.5% accurate, 12.8× speedup?

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

    1. Initial program 75.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 70.3%

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

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

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

    if 3.99999999999999975e-278 < b

    1. Initial program 29.1%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative70.7%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/70.7%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    4. Simplified70.7%

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

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

Alternative 6: 43.2% accurate, 16.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 7.9999999999999999e46

    1. Initial program 67.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 52.6%

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

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

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

    if 7.9999999999999999e46 < b

    1. Initial program 15.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 2.0%

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

        \[\leadsto \frac{\color{blue}{b \cdot -2} + 1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a} \]
      2. fma-def2.0%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(b, -2, 1.5 \cdot \frac{a \cdot c}{b}\right)}}{3 \cdot a} \]
      3. *-commutative2.0%

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

        \[\leadsto \frac{\mathsf{fma}\left(b, -2, \color{blue}{\frac{a}{\frac{b}{c}}} \cdot 1.5\right)}{3 \cdot a} \]
      5. associate-/r/2.2%

        \[\leadsto \frac{\mathsf{fma}\left(b, -2, \color{blue}{\left(\frac{a}{b} \cdot c\right)} \cdot 1.5\right)}{3 \cdot a} \]
    4. Simplified2.2%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(b, -2, \left(\frac{a}{b} \cdot c\right) \cdot 1.5\right)}}{3 \cdot a} \]
    5. Taylor expanded in b around 0 29.5%

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot c}{b}} \]
    7. Simplified29.5%

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

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

Alternative 7: 67.5% accurate, 16.4× speedup?

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

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

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


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

    1. Initial program 75.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 70.2%

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

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

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

    if 3.59999999999999996e-278 < b

    1. Initial program 29.1%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. *-commutative70.7%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/70.7%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    4. Simplified70.7%

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

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

Alternative 8: 35.4% accurate, 23.2× speedup?

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

\\
\frac{b}{a} \cdot -0.6666666666666666
\end{array}
Derivation
  1. Initial program 54.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 40.2%

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

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

    \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
  5. Final simplification40.2%

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

Reproduce

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