Cubic critical

Percentage Accurate: 52.1% → 85.7%
Time: 10.6s
Alternatives: 12
Speedup: 2.2×

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.1% accurate, 1.0× speedup?

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

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

Alternative 1: 85.7% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;b \leq 5.1 \cdot 10^{-62}:\\
\;\;\;\;\frac{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}{a}}{-3}\\

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


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

    1. Initial program 55.2%

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

      \[\leadsto \color{blue}{-1 \cdot \left(b \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(b \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right)\right)} \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \cdot b}\right) \]
      3. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right)} \]
      5. associate-*r/N/A

        \[\leadsto \left(\color{blue}{\frac{\frac{-1}{2} \cdot c}{{b}^{2}}} + \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \left(\frac{\color{blue}{c \cdot \frac{-1}{2}}}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
      7. associate-/l*N/A

        \[\leadsto \left(\color{blue}{c \cdot \frac{\frac{-1}{2}}{{b}^{2}}} + \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
      8. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(c, \frac{\frac{-1}{2}}{{b}^{2}}, \frac{2}{3} \cdot \frac{1}{a}\right)} \cdot \left(\mathsf{neg}\left(b\right)\right) \]
      9. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(c, \color{blue}{\frac{\frac{-1}{2}}{{b}^{2}}}, \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{fma}\left(c, \frac{\frac{-1}{2}}{\color{blue}{b \cdot b}}, \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(c, \frac{\frac{-1}{2}}{\color{blue}{b \cdot b}}, \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
      12. associate-*r/N/A

        \[\leadsto \mathsf{fma}\left(c, \frac{\frac{-1}{2}}{b \cdot b}, \color{blue}{\frac{\frac{2}{3} \cdot 1}{a}}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(c, \frac{\frac{-1}{2}}{b \cdot b}, \frac{\color{blue}{\frac{2}{3}}}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
      14. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(c, \frac{\frac{-1}{2}}{b \cdot b}, \color{blue}{\frac{\frac{2}{3}}{a}}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
      15. lower-neg.f6496.4

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

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

      \[\leadsto \frac{-2}{3} \cdot \frac{b}{a} + \color{blue}{\frac{1}{2} \cdot \frac{c}{b}} \]
    7. Step-by-step derivation
      1. Applied rewrites96.8%

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

      if -9.79999999999999958e98 < b < 5.1e-62

      1. Initial program 79.0%

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

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

      if 5.1e-62 < b

      1. Initial program 11.1%

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

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

          \[\leadsto \color{blue}{\frac{\frac{-1}{2} \cdot c}{b}} \]
        2. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{\frac{-1}{2} \cdot c}{b}} \]
        3. *-commutativeN/A

          \[\leadsto \frac{\color{blue}{c \cdot \frac{-1}{2}}}{b} \]
        4. lower-*.f6487.1

          \[\leadsto \frac{\color{blue}{c \cdot -0.5}}{b} \]
      5. Applied rewrites87.1%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -9.8 \cdot 10^{+98}:\\ \;\;\;\;\mathsf{fma}\left(c, \frac{0.5}{b}, \frac{b \cdot -0.6666666666666666}{a}\right)\\ \mathbf{elif}\;b \leq 5.1 \cdot 10^{-62}:\\ \;\;\;\;\frac{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}{a}}{-3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
    10. Add Preprocessing

    Alternative 2: 84.6% accurate, 0.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1900:\\ \;\;\;\;\mathsf{fma}\left(c, \frac{0.5}{b}, \frac{b \cdot -0.6666666666666666}{a}\right)\\ \mathbf{elif}\;b \leq 5.1 \cdot 10^{-62}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}, 0.3333333333333333, b \cdot -0.3333333333333333\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
    (FPCore (a b c)
     :precision binary64
     (if (<= b -1900.0)
       (fma c (/ 0.5 b) (/ (* b -0.6666666666666666) a))
       (if (<= b 5.1e-62)
         (/
          (fma
           (sqrt (fma b b (* -3.0 (* a c))))
           0.3333333333333333
           (* b -0.3333333333333333))
          a)
         (/ (* c -0.5) b))))
    double code(double a, double b, double c) {
    	double tmp;
    	if (b <= -1900.0) {
    		tmp = fma(c, (0.5 / b), ((b * -0.6666666666666666) / a));
    	} else if (b <= 5.1e-62) {
    		tmp = fma(sqrt(fma(b, b, (-3.0 * (a * c)))), 0.3333333333333333, (b * -0.3333333333333333)) / a;
    	} else {
    		tmp = (c * -0.5) / b;
    	}
    	return tmp;
    }
    
    function code(a, b, c)
    	tmp = 0.0
    	if (b <= -1900.0)
    		tmp = fma(c, Float64(0.5 / b), Float64(Float64(b * -0.6666666666666666) / a));
    	elseif (b <= 5.1e-62)
    		tmp = Float64(fma(sqrt(fma(b, b, Float64(-3.0 * Float64(a * c)))), 0.3333333333333333, Float64(b * -0.3333333333333333)) / a);
    	else
    		tmp = Float64(Float64(c * -0.5) / b);
    	end
    	return tmp
    end
    
    code[a_, b_, c_] := If[LessEqual[b, -1900.0], N[(c * N[(0.5 / b), $MachinePrecision] + N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.1e-62], N[(N[(N[Sqrt[N[(b * b + N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333 + N[(b * -0.3333333333333333), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;b \leq -1900:\\
    \;\;\;\;\mathsf{fma}\left(c, \frac{0.5}{b}, \frac{b \cdot -0.6666666666666666}{a}\right)\\
    
    \mathbf{elif}\;b \leq 5.1 \cdot 10^{-62}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}, 0.3333333333333333, b \cdot -0.3333333333333333\right)}{a}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{c \cdot -0.5}{b}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if b < -1900

      1. Initial program 63.8%

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

        \[\leadsto \color{blue}{-1 \cdot \left(b \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right)\right)} \]
      4. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \color{blue}{\mathsf{neg}\left(b \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right)\right)} \]
        2. *-commutativeN/A

          \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \cdot b}\right) \]
        3. distribute-rgt-neg-inN/A

          \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right)} \]
        4. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right)} \]
        5. associate-*r/N/A

          \[\leadsto \left(\color{blue}{\frac{\frac{-1}{2} \cdot c}{{b}^{2}}} + \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
        6. *-commutativeN/A

          \[\leadsto \left(\frac{\color{blue}{c \cdot \frac{-1}{2}}}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
        7. associate-/l*N/A

          \[\leadsto \left(\color{blue}{c \cdot \frac{\frac{-1}{2}}{{b}^{2}}} + \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
        8. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(c, \frac{\frac{-1}{2}}{{b}^{2}}, \frac{2}{3} \cdot \frac{1}{a}\right)} \cdot \left(\mathsf{neg}\left(b\right)\right) \]
        9. lower-/.f64N/A

          \[\leadsto \mathsf{fma}\left(c, \color{blue}{\frac{\frac{-1}{2}}{{b}^{2}}}, \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
        10. unpow2N/A

          \[\leadsto \mathsf{fma}\left(c, \frac{\frac{-1}{2}}{\color{blue}{b \cdot b}}, \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
        11. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(c, \frac{\frac{-1}{2}}{\color{blue}{b \cdot b}}, \frac{2}{3} \cdot \frac{1}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
        12. associate-*r/N/A

          \[\leadsto \mathsf{fma}\left(c, \frac{\frac{-1}{2}}{b \cdot b}, \color{blue}{\frac{\frac{2}{3} \cdot 1}{a}}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
        13. metadata-evalN/A

          \[\leadsto \mathsf{fma}\left(c, \frac{\frac{-1}{2}}{b \cdot b}, \frac{\color{blue}{\frac{2}{3}}}{a}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
        14. lower-/.f64N/A

          \[\leadsto \mathsf{fma}\left(c, \frac{\frac{-1}{2}}{b \cdot b}, \color{blue}{\frac{\frac{2}{3}}{a}}\right) \cdot \left(\mathsf{neg}\left(b\right)\right) \]
        15. lower-neg.f6490.9

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

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

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

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

        if -1900 < b < 5.1e-62

        1. Initial program 77.1%

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

          \[\leadsto \color{blue}{\frac{\frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{a}}{-3}} \]
        4. Step-by-step derivation
          1. lift-/.f64N/A

            \[\leadsto \color{blue}{\frac{\frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{a}}{-3}} \]
          2. lift-/.f64N/A

            \[\leadsto \frac{\color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{a}}}{-3} \]
          3. associate-/l/N/A

            \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{-3 \cdot a}} \]
          4. associate-/r*N/A

            \[\leadsto \color{blue}{\frac{\frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{-3}}{a}} \]
          5. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{\frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{-3}}{a}} \]
          6. lower-/.f6477.0

            \[\leadsto \frac{\color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{-3}}}{a} \]
          7. lift-fma.f64N/A

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

            \[\leadsto \frac{\frac{b - \sqrt{\color{blue}{b \cdot b + a \cdot \left(-3 \cdot c\right)}}}{-3}}{a} \]
          9. lift-*.f64N/A

            \[\leadsto \frac{\frac{b - \sqrt{\color{blue}{b \cdot b} + a \cdot \left(-3 \cdot c\right)}}{-3}}{a} \]
          10. lower-fma.f64N/A

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

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

          \[\leadsto \color{blue}{\frac{\frac{b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)}}{-3}}{a}} \]
        6. Step-by-step derivation
          1. lift-/.f64N/A

            \[\leadsto \frac{\color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)}}{-3}}}{a} \]
          2. lift--.f64N/A

            \[\leadsto \frac{\frac{\color{blue}{b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)}}}{-3}}{a} \]
          3. div-subN/A

            \[\leadsto \frac{\color{blue}{\frac{b}{-3} - \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)}}{-3}}}{a} \]
          4. lower--.f64N/A

            \[\leadsto \frac{\color{blue}{\frac{b}{-3} - \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)}}{-3}}}{a} \]
          5. div-invN/A

            \[\leadsto \frac{\color{blue}{b \cdot \frac{1}{-3}} - \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)}}{-3}}{a} \]
          6. lower-*.f64N/A

            \[\leadsto \frac{\color{blue}{b \cdot \frac{1}{-3}} - \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)}}{-3}}{a} \]
          7. metadata-evalN/A

            \[\leadsto \frac{b \cdot \color{blue}{\frac{-1}{3}} - \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)}}{-3}}{a} \]
          8. div-invN/A

            \[\leadsto \frac{b \cdot \frac{-1}{3} - \color{blue}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)} \cdot \frac{1}{-3}}}{a} \]
          9. lower-*.f64N/A

            \[\leadsto \frac{b \cdot \frac{-1}{3} - \color{blue}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)} \cdot \frac{1}{-3}}}{a} \]
          10. lift-fma.f64N/A

            \[\leadsto \frac{b \cdot \frac{-1}{3} - \sqrt{\color{blue}{b \cdot b + a \cdot \left(-3 \cdot c\right)}} \cdot \frac{1}{-3}}{a} \]
          11. +-commutativeN/A

            \[\leadsto \frac{b \cdot \frac{-1}{3} - \sqrt{\color{blue}{a \cdot \left(-3 \cdot c\right) + b \cdot b}} \cdot \frac{1}{-3}}{a} \]
          12. lift-*.f64N/A

            \[\leadsto \frac{b \cdot \frac{-1}{3} - \sqrt{\color{blue}{a \cdot \left(-3 \cdot c\right)} + b \cdot b} \cdot \frac{1}{-3}}{a} \]
          13. lift-*.f64N/A

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

            \[\leadsto \frac{b \cdot \frac{-1}{3} - \sqrt{\color{blue}{\left(a \cdot -3\right) \cdot c} + b \cdot b} \cdot \frac{1}{-3}}{a} \]
          15. *-commutativeN/A

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

            \[\leadsto \frac{b \cdot \frac{-1}{3} - \sqrt{\color{blue}{-3 \cdot \left(a \cdot c\right)} + b \cdot b} \cdot \frac{1}{-3}}{a} \]
          17. lower-fma.f64N/A

            \[\leadsto \frac{b \cdot \frac{-1}{3} - \sqrt{\color{blue}{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)}} \cdot \frac{1}{-3}}{a} \]
          18. lower-*.f64N/A

            \[\leadsto \frac{b \cdot \frac{-1}{3} - \sqrt{\mathsf{fma}\left(-3, \color{blue}{a \cdot c}, b \cdot b\right)} \cdot \frac{1}{-3}}{a} \]
          19. lower-*.f64N/A

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

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

          \[\leadsto \frac{\color{blue}{b \cdot -0.3333333333333333 - \sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)} \cdot -0.3333333333333333}}{a} \]
        8. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \frac{\color{blue}{b \cdot \frac{-1}{3} - \sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)} \cdot \frac{-1}{3}}}{a} \]
          2. sub-negN/A

            \[\leadsto \frac{\color{blue}{b \cdot \frac{-1}{3} + \left(\mathsf{neg}\left(\sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)} \cdot \frac{-1}{3}\right)\right)}}{a} \]
          3. +-commutativeN/A

            \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(\sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)} \cdot \frac{-1}{3}\right)\right) + b \cdot \frac{-1}{3}}}{a} \]
          4. lift-*.f64N/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)} \cdot \frac{-1}{3}}\right)\right) + b \cdot \frac{-1}{3}}{a} \]
          5. distribute-rgt-neg-inN/A

            \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)} \cdot \left(\mathsf{neg}\left(\frac{-1}{3}\right)\right)} + b \cdot \frac{-1}{3}}{a} \]
          6. metadata-evalN/A

            \[\leadsto \frac{\sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)} \cdot \color{blue}{\frac{1}{3}} + b \cdot \frac{-1}{3}}{a} \]
          7. metadata-evalN/A

            \[\leadsto \frac{\sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)} \cdot \color{blue}{\frac{1}{3}} + b \cdot \frac{-1}{3}}{a} \]
          8. lower-fma.f64N/A

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)}, \frac{1}{3}, b \cdot \frac{-1}{3}\right)}}{a} \]
          9. lift-fma.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(\sqrt{\color{blue}{-3 \cdot \left(a \cdot c\right) + b \cdot b}}, \frac{1}{3}, b \cdot \frac{-1}{3}\right)}{a} \]
          10. +-commutativeN/A

            \[\leadsto \frac{\mathsf{fma}\left(\sqrt{\color{blue}{b \cdot b + -3 \cdot \left(a \cdot c\right)}}, \frac{1}{3}, b \cdot \frac{-1}{3}\right)}{a} \]
          11. lift-*.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(\sqrt{\color{blue}{b \cdot b} + -3 \cdot \left(a \cdot c\right)}, \frac{1}{3}, b \cdot \frac{-1}{3}\right)}{a} \]
          12. lower-fma.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}, \frac{1}{3}, b \cdot \frac{-1}{3}\right)}{a} \]
          13. lower-*.f64N/A

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

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

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

        if 5.1e-62 < b

        1. Initial program 17.2%

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

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

            \[\leadsto \color{blue}{\frac{\frac{-1}{2} \cdot c}{b}} \]
          2. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{\frac{-1}{2} \cdot c}{b}} \]
          3. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{c \cdot \frac{-1}{2}}}{b} \]
          4. lower-*.f6486.8

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

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

      Reproduce

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