Cubic critical

Percentage Accurate: 52.1% → 86.0%
Time: 14.3s
Alternatives: 9
Speedup: 11.6×

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 9 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.1% 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: 86.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.9 \cdot 10^{+153}:\\
\;\;\;\;\left(b \cdot 2\right) \cdot \frac{1}{a \cdot -3}\\

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

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


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

    1. Initial program 43.8%

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

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

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

      \[\leadsto \color{blue}{\left(b - \sqrt{\mathsf{fma}\left(c, a \cdot -3, {b}^{2}\right)}\right) \cdot \frac{1}{a \cdot -3}} \]
    5. Taylor expanded in b around -inf 97.7%

      \[\leadsto \color{blue}{\left(2 \cdot b\right)} \cdot \frac{1}{a \cdot -3} \]
    6. Step-by-step derivation
      1. *-commutative97.7%

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

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

    if -5.9000000000000002e153 < b < 1.75000000000000002e-63

    1. Initial program 79.6%

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

    if 1.75000000000000002e-63 < b

    1. Initial program 9.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5.9 \cdot 10^{+153}:\\ \;\;\;\;\left(b \cdot 2\right) \cdot \frac{1}{a \cdot -3}\\ \mathbf{elif}\;b \leq 1.75 \cdot 10^{-63}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 80.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 65.4%

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

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

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

      \[\leadsto \color{blue}{\left(b - \sqrt{\mathsf{fma}\left(c, a \cdot -3, {b}^{2}\right)}\right) \cdot \frac{1}{a \cdot -3}} \]
    5. Taylor expanded in b around -inf 87.1%

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

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

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

    if -1.8499999999999999e-35 < b < 4.39999999999999998e-145

    1. Initial program 80.6%

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

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

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

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

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

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

    if 4.39999999999999998e-145 < b

    1. Initial program 14.3%

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

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

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    5. Simplified82.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.85 \cdot 10^{-35}:\\ \;\;\;\;\left(b \cdot 2\right) \cdot \frac{1}{a \cdot -3}\\ \mathbf{elif}\;b \leq 4.4 \cdot 10^{-145}:\\ \;\;\;\;\frac{\sqrt{\left(a \cdot -3\right) \cdot c} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 67.6% accurate, 8.3× speedup?

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

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

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


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

    1. Initial program 71.3%

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

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

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

      \[\leadsto \color{blue}{\left(b - \sqrt{\mathsf{fma}\left(c, a \cdot -3, {b}^{2}\right)}\right) \cdot \frac{1}{a \cdot -3}} \]
    5. Taylor expanded in b around -inf 61.8%

      \[\leadsto \color{blue}{\left(2 \cdot b\right)} \cdot \frac{1}{a \cdot -3} \]
    6. Step-by-step derivation
      1. *-commutative61.8%

        \[\leadsto \color{blue}{\left(b \cdot 2\right)} \cdot \frac{1}{a \cdot -3} \]
    7. Simplified61.8%

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

    if 2.70000000000000008e-247 < b

    1. Initial program 21.6%

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

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

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    5. Simplified74.0%

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

Alternative 4: 67.6% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 71.3%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666}{\frac{a}{b}}} \]
    7. Applied egg-rr61.8%

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

    if 2.70000000000000008e-247 < b

    1. Initial program 21.6%

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

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

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    5. Simplified74.0%

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

Alternative 5: 67.6% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 71.3%

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

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

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

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

    if 2.70000000000000008e-247 < b

    1. Initial program 21.6%

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

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

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    5. Simplified74.0%

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

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

Alternative 6: 42.3% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 58.5%

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

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

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

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

    if 3.9499999999999998e127 < b

    1. Initial program 6.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{0.3333333333333333}{a} \cdot \left(b + \sqrt{\left(-\color{blue}{c \cdot \left(3 \cdot a\right)}\right) + b \cdot b}\right) \]
      13. distribute-rgt-neg-in1.8%

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

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

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

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

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

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

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

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

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

Alternative 7: 42.2% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 58.5%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666}{\frac{a}{b}}} \]
    7. Applied egg-rr42.8%

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

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

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

    if 3.9499999999999998e127 < b

    1. Initial program 6.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{0.3333333333333333}{a} \cdot \left(b + \sqrt{\left(-\color{blue}{c \cdot \left(3 \cdot a\right)}\right) + b \cdot b}\right) \]
      13. distribute-rgt-neg-in1.8%

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

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

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

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

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

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

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

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

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

Alternative 8: 10.7% accurate, 23.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{0.3333333333333333}{a} \cdot \left(b + \sqrt{\left(-\color{blue}{c \cdot \left(3 \cdot a\right)}\right) + b \cdot b}\right) \]
    13. distribute-rgt-neg-in30.6%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b}} \]
  6. Final simplification8.8%

    \[\leadsto \frac{c}{b} \cdot 0.5 \]
  7. Add Preprocessing

Alternative 9: 3.6% accurate, 116.0× speedup?

\[\begin{array}{l} \\ -3 \end{array} \]
(FPCore (a b c) :precision binary64 -3.0)
double code(double a, double b, double c) {
	return -3.0;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = -3.0d0
end function
public static double code(double a, double b, double c) {
	return -3.0;
}
def code(a, b, c):
	return -3.0
function code(a, b, c)
	return -3.0
end
function tmp = code(a, b, c)
	tmp = -3.0;
end
code[a_, b_, c_] := -3.0
\begin{array}{l}

\\
-3
\end{array}
Derivation
  1. Initial program 49.2%

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

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

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

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

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

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

    \[\leadsto \color{blue}{-3} \]
  8. Add Preprocessing

Reproduce

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