Cubic critical

Percentage Accurate: 52.4% → 86.1%
Time: 16.9s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 52.4% 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.1% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.56 \cdot 10^{+152}:\\
\;\;\;\;\frac{b}{-3} \cdot \frac{\mathsf{fma}\left(-1.5 \cdot a, c \cdot {b}^{-2}, 2\right)}{a}\\

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

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


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

    1. Initial program 39.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-b}{3} \cdot \frac{\color{blue}{\left(-1.5 \cdot a\right) \cdot \frac{c}{{b}^{2}}} + 2}{a} \]
      4. fma-define94.9%

        \[\leadsto \frac{-b}{3} \cdot \frac{\color{blue}{\mathsf{fma}\left(-1.5 \cdot a, \frac{c}{{b}^{2}}, 2\right)}}{a} \]
      5. div-inv94.9%

        \[\leadsto \frac{-b}{3} \cdot \frac{\mathsf{fma}\left(-1.5 \cdot a, \color{blue}{c \cdot \frac{1}{{b}^{2}}}, 2\right)}{a} \]
      6. pow-flip94.9%

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

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

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

    if -1.5599999999999999e152 < b < 2.0200000000000001e-66

    1. Initial program 81.9%

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

    if 2.0200000000000001e-66 < b

    1. Initial program 13.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.56 \cdot 10^{+152}:\\ \;\;\;\;\frac{b}{-3} \cdot \frac{\mathsf{fma}\left(-1.5 \cdot a, c \cdot {b}^{-2}, 2\right)}{a}\\ \mathbf{elif}\;b \leq 2.02 \cdot 10^{-66}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 86.1% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 39.2%

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

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

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

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

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

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

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

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

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

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

    if -1.60000000000000008e150 < b < 7.5000000000000005e-67

    1. Initial program 81.9%

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

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

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

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

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

    if 7.5000000000000005e-67 < b

    1. Initial program 13.4%

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

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

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

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

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

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

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

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

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

Alternative 3: 86.1% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 39.2%

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

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

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

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

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

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

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

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

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

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

    if -1.26e150 < b < 2.1000000000000002e-67

    1. Initial program 81.9%

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

    if 2.1000000000000002e-67 < b

    1. Initial program 13.4%

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

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

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

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

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

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

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

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

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

Alternative 4: 78.7% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 58.1%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\right) \cdot \left(2 + -1.5 \cdot \frac{a \cdot c}{{b}^{2}}\right)}}{3 \cdot a} \]
      2. mul-1-neg78.4%

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

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

      \[\leadsto \frac{\color{blue}{\left(-b\right) \cdot \left(2 + -1.5 \cdot \left(a \cdot \frac{c}{{b}^{2}}\right)\right)}}{3 \cdot a} \]
    8. Taylor expanded in a around inf 83.0%

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

    if -1.15e8 < b < 2.04999999999999999e-66

    1. Initial program 83.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(1, \sqrt{c \cdot \left(a \cdot -3\right)}, \color{blue}{\sqrt{b} \cdot \sqrt{b}}\right)}{3 \cdot a} \]
      11. add-sqr-sqrt74.0%

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(1, \sqrt{c \cdot \left(a \cdot -3\right)}, b\right)}}{3 \cdot a} \]
    8. Step-by-step derivation
      1. fma-undefine74.0%

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

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

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

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

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

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

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

    if 2.04999999999999999e-66 < b

    1. Initial program 13.4%

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

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

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

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

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

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

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

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

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

Alternative 5: 78.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 58.1%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\right) \cdot \left(2 + -1.5 \cdot \frac{a \cdot c}{{b}^{2}}\right)}}{3 \cdot a} \]
      2. mul-1-neg78.4%

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

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

      \[\leadsto \frac{\color{blue}{\left(-b\right) \cdot \left(2 + -1.5 \cdot \left(a \cdot \frac{c}{{b}^{2}}\right)\right)}}{3 \cdot a} \]
    8. Taylor expanded in a around inf 83.0%

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

    if -8.2e7 < b < 2.2000000000000001e-66

    1. Initial program 83.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(1, \sqrt{c \cdot \left(a \cdot -3\right)}, \color{blue}{\sqrt{b} \cdot \sqrt{b}}\right)}{3 \cdot a} \]
      11. add-sqr-sqrt74.0%

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(1, \sqrt{c \cdot \left(a \cdot -3\right)}, b\right)}}{3 \cdot a} \]
    8. Step-by-step derivation
      1. fma-undefine74.0%

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

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

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

    if 2.2000000000000001e-66 < b

    1. Initial program 13.4%

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

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

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

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

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

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

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

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

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

Alternative 6: 78.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -82000000:\\
\;\;\;\;b \cdot \left(\frac{c \cdot 0.5}{{b}^{2}} - \frac{0.6666666666666666}{a}\right)\\

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

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


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

    1. Initial program 58.1%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\right) \cdot \left(2 + -1.5 \cdot \frac{a \cdot c}{{b}^{2}}\right)}}{3 \cdot a} \]
      2. mul-1-neg78.4%

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

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

      \[\leadsto \frac{\color{blue}{\left(-b\right) \cdot \left(2 + -1.5 \cdot \left(a \cdot \frac{c}{{b}^{2}}\right)\right)}}{3 \cdot a} \]
    8. Taylor expanded in b around inf 83.0%

      \[\leadsto \color{blue}{b \cdot \left(0.5 \cdot \frac{c}{{b}^{2}} - 0.6666666666666666 \cdot \frac{1}{a}\right)} \]
    9. Step-by-step derivation
      1. associate-*r/83.0%

        \[\leadsto b \cdot \left(\color{blue}{\frac{0.5 \cdot c}{{b}^{2}}} - 0.6666666666666666 \cdot \frac{1}{a}\right) \]
      2. *-commutative83.0%

        \[\leadsto b \cdot \left(\frac{\color{blue}{c \cdot 0.5}}{{b}^{2}} - 0.6666666666666666 \cdot \frac{1}{a}\right) \]
      3. associate-*r/83.1%

        \[\leadsto b \cdot \left(\frac{c \cdot 0.5}{{b}^{2}} - \color{blue}{\frac{0.6666666666666666 \cdot 1}{a}}\right) \]
      4. metadata-eval83.1%

        \[\leadsto b \cdot \left(\frac{c \cdot 0.5}{{b}^{2}} - \frac{\color{blue}{0.6666666666666666}}{a}\right) \]
    10. Simplified83.1%

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

    if -8.2e7 < b < 5.29999999999999971e-67

    1. Initial program 83.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(1, \sqrt{c \cdot \left(a \cdot -3\right)}, \color{blue}{\sqrt{b} \cdot \sqrt{b}}\right)}{3 \cdot a} \]
      11. add-sqr-sqrt74.0%

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(1, \sqrt{c \cdot \left(a \cdot -3\right)}, b\right)}}{3 \cdot a} \]
    8. Step-by-step derivation
      1. fma-undefine74.0%

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

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

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

    if 5.29999999999999971e-67 < b

    1. Initial program 13.4%

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

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

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

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

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

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

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

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

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

Alternative 7: 79.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1050000000:\\
\;\;\;\;b \cdot \left(\frac{c \cdot 0.5}{{b}^{2}} - \frac{0.6666666666666666}{a}\right)\\

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

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


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

    1. Initial program 58.1%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\right) \cdot \left(2 + -1.5 \cdot \frac{a \cdot c}{{b}^{2}}\right)}}{3 \cdot a} \]
      2. mul-1-neg78.4%

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

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

      \[\leadsto \frac{\color{blue}{\left(-b\right) \cdot \left(2 + -1.5 \cdot \left(a \cdot \frac{c}{{b}^{2}}\right)\right)}}{3 \cdot a} \]
    8. Taylor expanded in b around inf 83.0%

      \[\leadsto \color{blue}{b \cdot \left(0.5 \cdot \frac{c}{{b}^{2}} - 0.6666666666666666 \cdot \frac{1}{a}\right)} \]
    9. Step-by-step derivation
      1. associate-*r/83.0%

        \[\leadsto b \cdot \left(\color{blue}{\frac{0.5 \cdot c}{{b}^{2}}} - 0.6666666666666666 \cdot \frac{1}{a}\right) \]
      2. *-commutative83.0%

        \[\leadsto b \cdot \left(\frac{\color{blue}{c \cdot 0.5}}{{b}^{2}} - 0.6666666666666666 \cdot \frac{1}{a}\right) \]
      3. associate-*r/83.1%

        \[\leadsto b \cdot \left(\frac{c \cdot 0.5}{{b}^{2}} - \color{blue}{\frac{0.6666666666666666 \cdot 1}{a}}\right) \]
      4. metadata-eval83.1%

        \[\leadsto b \cdot \left(\frac{c \cdot 0.5}{{b}^{2}} - \frac{\color{blue}{0.6666666666666666}}{a}\right) \]
    10. Simplified83.1%

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

    if -1.05e9 < b < 3.20000000000000021e-67

    1. Initial program 83.4%

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

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

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

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

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

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

    if 3.20000000000000021e-67 < b

    1. Initial program 13.4%

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

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

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

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

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

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

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

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

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

Alternative 8: 79.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -82000000:\\
\;\;\;\;b \cdot \left(\frac{c \cdot 0.5}{{b}^{2}} - \frac{0.6666666666666666}{a}\right)\\

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

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


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

    1. Initial program 58.1%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\right) \cdot \left(2 + -1.5 \cdot \frac{a \cdot c}{{b}^{2}}\right)}}{3 \cdot a} \]
      2. mul-1-neg78.4%

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

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

      \[\leadsto \frac{\color{blue}{\left(-b\right) \cdot \left(2 + -1.5 \cdot \left(a \cdot \frac{c}{{b}^{2}}\right)\right)}}{3 \cdot a} \]
    8. Taylor expanded in b around inf 83.0%

      \[\leadsto \color{blue}{b \cdot \left(0.5 \cdot \frac{c}{{b}^{2}} - 0.6666666666666666 \cdot \frac{1}{a}\right)} \]
    9. Step-by-step derivation
      1. associate-*r/83.0%

        \[\leadsto b \cdot \left(\color{blue}{\frac{0.5 \cdot c}{{b}^{2}}} - 0.6666666666666666 \cdot \frac{1}{a}\right) \]
      2. *-commutative83.0%

        \[\leadsto b \cdot \left(\frac{\color{blue}{c \cdot 0.5}}{{b}^{2}} - 0.6666666666666666 \cdot \frac{1}{a}\right) \]
      3. associate-*r/83.1%

        \[\leadsto b \cdot \left(\frac{c \cdot 0.5}{{b}^{2}} - \color{blue}{\frac{0.6666666666666666 \cdot 1}{a}}\right) \]
      4. metadata-eval83.1%

        \[\leadsto b \cdot \left(\frac{c \cdot 0.5}{{b}^{2}} - \frac{\color{blue}{0.6666666666666666}}{a}\right) \]
    10. Simplified83.1%

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

    if -8.2e7 < b < 2.15000000000000007e-66

    1. Initial program 83.4%

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

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

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

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

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

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

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

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

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

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

    if 2.15000000000000007e-66 < b

    1. Initial program 13.4%

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

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

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

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

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

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

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

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

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

Alternative 9: 68.0% accurate, 7.2× speedup?

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

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

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


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

    1. Initial program 70.4%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(-b\right) \cdot \left(2 + -1.5 \cdot \left(a \cdot \frac{c}{{b}^{2}}\right)\right)}}{3 \cdot a} \]
    8. Taylor expanded in a around inf 58.7%

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

    if -3.999999999999988e-310 < b

    1. Initial program 34.2%

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

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

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

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

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

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

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

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

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

Alternative 10: 67.7% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 70.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}} \]
      2. *-commutative57.9%

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

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

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

    if -3.999999999999988e-310 < b

    1. Initial program 34.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(a \cdot c\right) \cdot -3}}\right) - b}{3 \cdot a} \]
      2. *-commutative38.6%

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right) \cdot \frac{1}{3 \cdot a}} \]
      2. *-commutative38.6%

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

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

      \[\leadsto \color{blue}{0.16666666666666666 \cdot \frac{c \cdot {\left(\sqrt{-3}\right)}^{2}}{b}} \]
    12. Step-by-step derivation
      1. *-commutative0.0%

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

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

        \[\leadsto \color{blue}{c \cdot \left(\frac{{\left(\sqrt{-3}\right)}^{2}}{b} \cdot 0.16666666666666666\right)} \]
      4. *-commutative0.0%

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

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

        \[\leadsto c \cdot \frac{0.16666666666666666 \cdot \color{blue}{\left(\sqrt{-3} \cdot \sqrt{-3}\right)}}{b} \]
      7. rem-square-sqrt64.2%

        \[\leadsto c \cdot \frac{0.16666666666666666 \cdot \color{blue}{-3}}{b} \]
      8. metadata-eval64.2%

        \[\leadsto c \cdot \frac{\color{blue}{-0.5}}{b} \]
    13. Simplified64.2%

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

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

Alternative 11: 67.8% accurate, 11.6× speedup?

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

    1. Initial program 70.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}} \]
      2. *-commutative57.9%

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

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

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

    if 4.999999999999985e-310 < b

    1. Initial program 34.2%

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

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

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

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

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

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

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

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

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

Alternative 12: 35.7% accurate, 23.2× speedup?

\[\begin{array}{l} \\ b \cdot \frac{-0.6666666666666666}{a} \end{array} \]
(FPCore (a b c) :precision binary64 (* b (/ -0.6666666666666666 a)))
double code(double a, double b, double c) {
	return b * (-0.6666666666666666 / 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 * ((-0.6666666666666666d0) / a)
end function
public static double code(double a, double b, double c) {
	return b * (-0.6666666666666666 / a);
}
def code(a, b, c):
	return b * (-0.6666666666666666 / a)
function code(a, b, c)
	return Float64(b * Float64(-0.6666666666666666 / a))
end
function tmp = code(a, b, c)
	tmp = b * (-0.6666666666666666 / a);
end
code[a_, b_, c_] := N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
b \cdot \frac{-0.6666666666666666}{a}
\end{array}
Derivation
  1. Initial program 51.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(a \cdot c\right) \cdot -3}}\right) - b}{3 \cdot a} \]
    2. *-commutative48.6%

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

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

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

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

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

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

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

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

    \[\leadsto b \cdot \frac{-0.6666666666666666}{a} \]
  13. Add Preprocessing

Reproduce

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