Cubic critical

Percentage Accurate: 51.9% → 84.1%
Time: 13.7s
Alternatives: 9
Speedup: 16.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 51.9% accurate, 1.0× speedup?

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

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

Alternative 1: 84.1% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 46.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(0.5, \frac{c}{\frac{b}{a}}, b \cdot -0.6666666666666666\right)}}{a} \]
    7. Step-by-step derivation
      1. div-inv93.5%

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

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

        \[\leadsto \mathsf{fma}\left(0.5, c \cdot \color{blue}{\frac{a}{b}}, b \cdot -0.6666666666666666\right) \cdot \frac{1}{a} \]
    8. Applied egg-rr93.5%

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

    if -7.19999999999999972e124 < b < 1.08000000000000002e-10

    1. Initial program 81.7%

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

    if 1.08000000000000002e-10 < b

    1. Initial program 18.9%

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

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

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

Alternative 2: 84.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 46.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(0.5, \frac{c}{\frac{b}{a}}, b \cdot -0.6666666666666666\right)}}{a} \]
    7. Step-by-step derivation
      1. div-inv93.5%

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

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

        \[\leadsto \mathsf{fma}\left(0.5, c \cdot \color{blue}{\frac{a}{b}}, b \cdot -0.6666666666666666\right) \cdot \frac{1}{a} \]
    8. Applied egg-rr93.5%

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

    if -4.99999999999999977e126 < b < 1.25000000000000008e-10

    1. Initial program 81.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{--1}}{-1} \cdot \frac{b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
      8. times-frac81.7%

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

        \[\leadsto \frac{\left(--1\right) \cdot \left(b - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{\color{blue}{\left(3 \cdot a\right) \cdot -1}} \]
      10. times-frac81.6%

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

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

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

    if 1.25000000000000008e-10 < b

    1. Initial program 18.9%

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

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

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

Alternative 3: 67.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-3}{\frac{b}{c}}, -0.16666666666666666, \frac{b}{\frac{a}{-0.6666666666666666}}\right)\\

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


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

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(-0.3333333333333333 \cdot \left(b - \sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -3\right)}\right)\right)\right)}}{a} \]
      2. expm1-udef51.9%

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

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

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

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

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

        \[\leadsto \frac{e^{\mathsf{log1p}\left(\left(b - \color{blue}{\mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -3\right)}\right)}\right) \cdot -0.3333333333333333\right)} - 1}{a} \]
    5. Applied egg-rr40.9%

      \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -3\right)}\right)\right) \cdot -0.3333333333333333\right)} - 1}}{a} \]
    6. Step-by-step derivation
      1. expm1-def56.4%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -3\right)}\right)\right) \cdot -0.3333333333333333\right)\right)}}{a} \]
      2. expm1-log1p59.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{c \cdot {\left(\sqrt{-3}\right)}^{2}}{b} \cdot -0.16666666666666666} + -0.6666666666666666 \cdot \frac{b}{a} \]
      3. fma-def0.0%

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\sqrt{-3} \cdot \sqrt{-3}}}{\frac{b}{c}}, -0.16666666666666666, -0.6666666666666666 \cdot \frac{b}{a}\right) \]
      7. rem-square-sqrt65.9%

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

        \[\leadsto \mathsf{fma}\left(\frac{-3}{\frac{b}{c}}, -0.16666666666666666, \color{blue}{\frac{-0.6666666666666666 \cdot b}{a}}\right) \]
      9. *-commutative65.9%

        \[\leadsto \mathsf{fma}\left(\frac{-3}{\frac{b}{c}}, -0.16666666666666666, \frac{\color{blue}{b \cdot -0.6666666666666666}}{a}\right) \]
      10. associate-/l*65.9%

        \[\leadsto \mathsf{fma}\left(\frac{-3}{\frac{b}{c}}, -0.16666666666666666, \color{blue}{\frac{b}{\frac{a}{-0.6666666666666666}}}\right) \]
    10. Simplified65.9%

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

    if -1.000000000000002e-309 < b

    1. Initial program 41.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\mathsf{fma}\left(\frac{-3}{\frac{b}{c}}, -0.16666666666666666, \frac{b}{\frac{a}{-0.6666666666666666}}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]

Alternative 4: 67.6% accurate, 8.9× speedup?

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

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

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


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

    1. Initial program 73.3%

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

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

    if -1.000000000000002e-309 < b

    1. Initial program 41.8%

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

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

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

Alternative 5: 67.5% accurate, 12.8× speedup?

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

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

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


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

    1. Initial program 73.7%

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

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

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

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

    if 2.6e-286 < b

    1. Initial program 40.8%

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

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

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

Alternative 6: 67.4% accurate, 16.4× speedup?

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

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

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


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

    1. Initial program 73.7%

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

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

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

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

    if 6.29999999999999989e-285 < b

    1. Initial program 40.8%

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

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

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

Alternative 7: 67.4% accurate, 16.4× speedup?

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

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

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


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

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.3333333333333333 \cdot \left(b - \sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -3\right)}\right)}{a}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u71.1%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(-0.3333333333333333 \cdot \left(b - \sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -3\right)}\right)\right)\right)}}{a} \]
      2. expm1-udef52.6%

        \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(-0.3333333333333333 \cdot \left(b - \sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -3\right)}\right)\right)} - 1}}{a} \]
      3. *-commutative52.6%

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

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

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

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

        \[\leadsto \frac{e^{\mathsf{log1p}\left(\left(b - \color{blue}{\mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -3\right)}\right)}\right) \cdot -0.3333333333333333\right)} - 1}{a} \]
    5. Applied egg-rr41.7%

      \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -3\right)}\right)\right) \cdot -0.3333333333333333\right)} - 1}}{a} \]
    6. Step-by-step derivation
      1. expm1-def57.0%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -3\right)}\right)\right) \cdot -0.3333333333333333\right)\right)}}{a} \]
      2. expm1-log1p59.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{\frac{a}{-0.6666666666666666}}} \]
    10. Simplified64.5%

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

    if 2.6e-286 < b

    1. Initial program 40.8%

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

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

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

Alternative 8: 67.5% accurate, 16.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.2 \cdot 10^{-285}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\

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


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

    1. Initial program 73.7%

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

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

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

      \[\leadsto \frac{\color{blue}{b \cdot -2}}{3 \cdot a} \]
    5. Step-by-step derivation
      1. expm1-log1p-u37.3%

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{b \cdot -2}{3 \cdot a}\right)} - 1} \]
      3. times-frac25.1%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{b}{3} \cdot \frac{-2}{a}}\right)} - 1 \]
    6. Applied egg-rr25.1%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{b}{\frac{3}{-2}}}}{a} \]
      6. metadata-eval64.6%

        \[\leadsto \frac{\frac{b}{\color{blue}{-1.5}}}{a} \]
    8. Simplified64.6%

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

    if 6.2000000000000002e-285 < b

    1. Initial program 40.8%

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

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

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

Alternative 9: 35.1% accurate, 23.2× speedup?

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

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

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

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

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

Reproduce

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