Cubic critical

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

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

Initial Program: 51.9% accurate, 1.0× speedup?

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

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

Alternative 1: 85.8% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 48.7%

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

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

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

      \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
    6. Step-by-step derivation
      1. associate-*l/98.1%

        \[\leadsto \color{blue}{\frac{b \cdot -0.6666666666666666}{a}} \]
    7. Applied egg-rr98.1%

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

    if -1.25e103 < b < 3.90000000000000022e-63

    1. Initial program 78.4%

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

    if 3.90000000000000022e-63 < b

    1. Initial program 11.4%

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

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

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

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

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

Alternative 2: 80.6% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 64.9%

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

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

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

      \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
    6. Step-by-step derivation
      1. associate-*l/94.2%

        \[\leadsto \color{blue}{\frac{b \cdot -0.6666666666666666}{a}} \]
    7. Applied egg-rr94.2%

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

    if -3.59999999999999988e-52 < b < 5.2e-64

    1. Initial program 72.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. prod-diff71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.2e-64 < b

    1. Initial program 11.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -3.6 \cdot 10^{-52}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 5.2 \cdot 10^{-64}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.3% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 67.9%

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

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

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

      \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
    6. Step-by-step derivation
      1. associate-*l/90.7%

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

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

    if -6.5000000000000003e-79 < b < 1.2600000000000001e-70

    1. Initial program 69.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot -3\right)}}{a}} \]
    8. Taylor expanded in a around 0 63.9%

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

    if 1.2600000000000001e-70 < b

    1. Initial program 11.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6.5 \cdot 10^{-79}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 1.26 \cdot 10^{-70}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{-3 \cdot \left(a \cdot c\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 80.2% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 67.9%

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

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

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

      \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
    6. Step-by-step derivation
      1. associate-*l/90.7%

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

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

    if -8.80000000000000041e-80 < b < 2.54999999999999992e-64

    1. Initial program 69.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.54999999999999992e-64 < b

    1. Initial program 11.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -8.8 \cdot 10^{-80}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 2.55 \cdot 10^{-64}:\\ \;\;\;\;\frac{0.3333333333333333 \cdot \sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 23.4% accurate, 11.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.08 \cdot 10^{+22}:\\
\;\;\;\;b \cdot \frac{-1.3333333333333333}{a}\\

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


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

    1. Initial program 64.2%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{3 \cdot a}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. *-un-lft-identity64.1%

        \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}} - b}{3 \cdot a} \]
      2. *-un-lft-identity64.1%

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

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

      \[\leadsto \frac{\color{blue}{\left(b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right) + \mathsf{fma}\left(b, 1, b\right)}}{3 \cdot a} \]
    7. Step-by-step derivation
      1. +-commutative31.6%

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

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

        \[\leadsto \frac{\mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(c \cdot a\right) \cdot -3}}\right) + \left(b + \mathsf{fma}\left(b, 1, b\right)\right)}{3 \cdot a} \]
      4. *-commutative31.5%

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

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

        \[\leadsto \frac{\mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -3\right)}\right) + \left(b + \color{blue}{\left(b \cdot 1 + b\right)}\right)}{3 \cdot a} \]
      7. *-rgt-identity31.5%

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

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

      \[\leadsto \color{blue}{1.3333333333333333 \cdot \frac{b}{a}} \]
    10. Step-by-step derivation
      1. *-commutative2.5%

        \[\leadsto \color{blue}{\frac{b}{a} \cdot 1.3333333333333333} \]
    11. Simplified2.5%

      \[\leadsto \color{blue}{\frac{b}{a} \cdot 1.3333333333333333} \]
    12. Step-by-step derivation
      1. *-commutative2.5%

        \[\leadsto \color{blue}{1.3333333333333333 \cdot \frac{b}{a}} \]
      2. metadata-eval2.5%

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

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

        \[\leadsto \color{blue}{\frac{4}{\frac{3 \cdot a}{b}}} \]
      5. add-sqr-sqrt1.3%

        \[\leadsto \frac{4}{\frac{\color{blue}{\sqrt{3 \cdot a} \cdot \sqrt{3 \cdot a}}}{b}} \]
      6. sqrt-unprod10.0%

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

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

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

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

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

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

        \[\leadsto \frac{4}{\frac{\sqrt{\color{blue}{\left(a \cdot -3\right) \cdot \left(a \cdot -3\right)}}}{b}} \]
      13. sqrt-unprod9.7%

        \[\leadsto \frac{4}{\frac{\color{blue}{\sqrt{a \cdot -3} \cdot \sqrt{a \cdot -3}}}{b}} \]
      14. add-sqr-sqrt20.4%

        \[\leadsto \frac{4}{\frac{\color{blue}{a \cdot -3}}{b}} \]
    13. Applied egg-rr20.4%

      \[\leadsto \color{blue}{\frac{4}{\frac{a \cdot -3}{b}}} \]
    14. Step-by-step derivation
      1. associate-/r/20.4%

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

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

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

        \[\leadsto \color{blue}{\frac{b}{a} \cdot \frac{4}{-3}} \]
      5. metadata-eval20.4%

        \[\leadsto \frac{b}{a} \cdot \color{blue}{-1.3333333333333333} \]
      6. metadata-eval20.4%

        \[\leadsto \frac{b}{a} \cdot \color{blue}{\left(-1.3333333333333333\right)} \]
      7. distribute-rgt-neg-in20.4%

        \[\leadsto \color{blue}{-\frac{b}{a} \cdot 1.3333333333333333} \]
      8. associate-*l/20.4%

        \[\leadsto -\color{blue}{\frac{b \cdot 1.3333333333333333}{a}} \]
      9. distribute-neg-frac20.4%

        \[\leadsto \color{blue}{\frac{-b \cdot 1.3333333333333333}{a}} \]
      10. distribute-rgt-neg-in20.4%

        \[\leadsto \frac{\color{blue}{b \cdot \left(-1.3333333333333333\right)}}{a} \]
      11. metadata-eval20.4%

        \[\leadsto \frac{b \cdot \color{blue}{-1.3333333333333333}}{a} \]
      12. metadata-eval20.4%

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

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

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

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

        \[\leadsto b \cdot \color{blue}{\frac{-4 \cdot 0.3333333333333333}{a}} \]
      17. metadata-eval20.4%

        \[\leadsto b \cdot \frac{\color{blue}{-1.3333333333333333}}{a} \]
    15. Simplified20.4%

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

    if 1.08e22 < b

    1. Initial program 11.4%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)} \]
      2. associate-*r/2.4%

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

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

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

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

Alternative 6: 42.6% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 64.2%

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

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

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

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

    if 3.2499999999999999e22 < b

    1. Initial program 11.4%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)} \]
      2. associate-*r/2.4%

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

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

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

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

Alternative 7: 66.8% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 70.0%

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

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

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

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

    if 6.4000000000000003e-291 < b

    1. Initial program 24.9%

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5}{\frac{b}{c}}} \]
    5. Simplified72.8%

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

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

Alternative 8: 67.3% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 70.0%

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

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

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

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

    if 6.4000000000000003e-291 < b

    1. Initial program 24.9%

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

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

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

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

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

Alternative 9: 67.3% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 70.0%

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

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

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

      \[\leadsto \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]
    6. Step-by-step derivation
      1. associate-*l/65.6%

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

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

    if 6.4000000000000003e-291 < b

    1. Initial program 24.9%

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

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

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

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

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

Alternative 10: 11.0% accurate, 23.2× speedup?

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)} \]
    2. associate-*r/36.6%

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

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

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

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

Reproduce

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