Cubic critical, narrow range

Percentage Accurate: 55.8% → 99.1%
Time: 21.9s
Alternatives: 8
Speedup: 23.2×

Specification

?
\[\left(\left(1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156\right) \land \left(1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156\right)\right) \land \left(1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\right)\]
\[\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 8 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: 55.8% 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: 99.1% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \frac{\frac{\mathsf{fma}\left(-3, c \cdot a, \frac{27 \cdot \left(\frac{{b}^{4}}{a} \cdot 0\right)}{c}\right)}{b + \sqrt{\frac{{b}^{6} + {\left(c \cdot a\right)}^{3} \cdot -27}{{b}^{4} + \left(c \cdot a\right) \cdot \left(3 \cdot \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 3\right)\right)\right)}}}}{a \cdot 3} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/
  (/
   (fma -3.0 (* c a) (/ (* 27.0 (* (/ (pow b 4.0) a) 0.0)) c))
   (+
    b
    (sqrt
     (/
      (+ (pow b 6.0) (* (pow (* c a) 3.0) -27.0))
      (+ (pow b 4.0) (* (* c a) (* 3.0 (fma b b (* c (* a 3.0))))))))))
  (* a 3.0)))
double code(double a, double b, double c) {
	return (fma(-3.0, (c * a), ((27.0 * ((pow(b, 4.0) / a) * 0.0)) / c)) / (b + sqrt(((pow(b, 6.0) + (pow((c * a), 3.0) * -27.0)) / (pow(b, 4.0) + ((c * a) * (3.0 * fma(b, b, (c * (a * 3.0)))))))))) / (a * 3.0);
}
function code(a, b, c)
	return Float64(Float64(fma(-3.0, Float64(c * a), Float64(Float64(27.0 * Float64(Float64((b ^ 4.0) / a) * 0.0)) / c)) / Float64(b + sqrt(Float64(Float64((b ^ 6.0) + Float64((Float64(c * a) ^ 3.0) * -27.0)) / Float64((b ^ 4.0) + Float64(Float64(c * a) * Float64(3.0 * fma(b, b, Float64(c * Float64(a * 3.0)))))))))) / Float64(a * 3.0))
end
code[a_, b_, c_] := N[(N[(N[(-3.0 * N[(c * a), $MachinePrecision] + N[(N[(27.0 * N[(N[(N[Power[b, 4.0], $MachinePrecision] / a), $MachinePrecision] * 0.0), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / N[(b + N[Sqrt[N[(N[(N[Power[b, 6.0], $MachinePrecision] + N[(N[Power[N[(c * a), $MachinePrecision], 3.0], $MachinePrecision] * -27.0), $MachinePrecision]), $MachinePrecision] / N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(c * a), $MachinePrecision] * N[(3.0 * N[(b * b + N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{\mathsf{fma}\left(-3, c \cdot a, \frac{27 \cdot \left(\frac{{b}^{4}}{a} \cdot 0\right)}{c}\right)}{b + \sqrt{\frac{{b}^{6} + {\left(c \cdot a\right)}^{3} \cdot -27}{{b}^{4} + \left(c \cdot a\right) \cdot \left(3 \cdot \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 3\right)\right)\right)}}}}{a \cdot 3}
\end{array}
Derivation
  1. Initial program 53.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. Simplified53.1%

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

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

        \[\leadsto \frac{\color{blue}{\frac{\sqrt{{b}^{6} - 27 \cdot {\left(a \cdot c\right)}^{3}}}{\sqrt{{b}^{4} + \left(3 \cdot \left(a \cdot c\right)\right) \cdot \mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot c\right)\right)}} + \left(-b\right)}}{3 \cdot a} \]
      2. flip-+52.5%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\mathsf{fma}\left(-3, a \cdot c, 27 \cdot \frac{-0.012345679012345678 \cdot \frac{{b}^{4}}{a} + 0.012345679012345678 \cdot \frac{{b}^{4}}{a}}{c}\right)}}{\sqrt{\frac{{b}^{6} + {\left(a \cdot c\right)}^{3} \cdot -27}{{b}^{4} + \left(a \cdot c\right) \cdot \left(3 \cdot \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 3\right)\right)\right)}} - \left(-b\right)}}{3 \cdot a} \]
      2. *-commutative99.1%

        \[\leadsto \frac{\frac{\mathsf{fma}\left(-3, \color{blue}{c \cdot a}, 27 \cdot \frac{-0.012345679012345678 \cdot \frac{{b}^{4}}{a} + 0.012345679012345678 \cdot \frac{{b}^{4}}{a}}{c}\right)}{\sqrt{\frac{{b}^{6} + {\left(a \cdot c\right)}^{3} \cdot -27}{{b}^{4} + \left(a \cdot c\right) \cdot \left(3 \cdot \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 3\right)\right)\right)}} - \left(-b\right)}}{3 \cdot a} \]
      3. associate-*r/99.1%

        \[\leadsto \frac{\frac{\mathsf{fma}\left(-3, c \cdot a, \color{blue}{\frac{27 \cdot \left(-0.012345679012345678 \cdot \frac{{b}^{4}}{a} + 0.012345679012345678 \cdot \frac{{b}^{4}}{a}\right)}{c}}\right)}{\sqrt{\frac{{b}^{6} + {\left(a \cdot c\right)}^{3} \cdot -27}{{b}^{4} + \left(a \cdot c\right) \cdot \left(3 \cdot \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 3\right)\right)\right)}} - \left(-b\right)}}{3 \cdot a} \]
      4. distribute-rgt-out99.1%

        \[\leadsto \frac{\frac{\mathsf{fma}\left(-3, c \cdot a, \frac{27 \cdot \color{blue}{\left(\frac{{b}^{4}}{a} \cdot \left(-0.012345679012345678 + 0.012345679012345678\right)\right)}}{c}\right)}{\sqrt{\frac{{b}^{6} + {\left(a \cdot c\right)}^{3} \cdot -27}{{b}^{4} + \left(a \cdot c\right) \cdot \left(3 \cdot \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 3\right)\right)\right)}} - \left(-b\right)}}{3 \cdot a} \]
      5. metadata-eval99.1%

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

      \[\leadsto \frac{\frac{\color{blue}{\mathsf{fma}\left(-3, c \cdot a, \frac{27 \cdot \left(\frac{{b}^{4}}{a} \cdot 0\right)}{c}\right)}}{\sqrt{\frac{{b}^{6} + {\left(a \cdot c\right)}^{3} \cdot -27}{{b}^{4} + \left(a \cdot c\right) \cdot \left(3 \cdot \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 3\right)\right)\right)}} - \left(-b\right)}}{3 \cdot a} \]
    8. Final simplification99.1%

      \[\leadsto \frac{\frac{\mathsf{fma}\left(-3, c \cdot a, \frac{27 \cdot \left(\frac{{b}^{4}}{a} \cdot 0\right)}{c}\right)}{b + \sqrt{\frac{{b}^{6} + {\left(c \cdot a\right)}^{3} \cdot -27}{{b}^{4} + \left(c \cdot a\right) \cdot \left(3 \cdot \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 3\right)\right)\right)}}}}{a \cdot 3} \]

    Alternative 2: 89.4% accurate, 0.2× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -0.4:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.5, \frac{c}{b}, -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\ \end{array} \end{array} \]
    (FPCore (a b c)
     :precision binary64
     (if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -0.4)
       (/ (- (sqrt (fma b b (* c (* -3.0 a)))) b) (* a 3.0))
       (fma
        -0.5
        (/ c b)
        (+
         (* -0.5625 (/ (* (pow a 2.0) (pow c 3.0)) (pow b 5.0)))
         (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0)))))))
    double code(double a, double b, double c) {
    	double tmp;
    	if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -0.4) {
    		tmp = (sqrt(fma(b, b, (c * (-3.0 * a)))) - b) / (a * 3.0);
    	} else {
    		tmp = fma(-0.5, (c / b), ((-0.5625 * ((pow(a, 2.0) * pow(c, 3.0)) / pow(b, 5.0))) + (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0)))));
    	}
    	return tmp;
    }
    
    function code(a, b, c)
    	tmp = 0.0
    	if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) <= -0.4)
    		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(-3.0 * a)))) - b) / Float64(a * 3.0));
    	else
    		tmp = fma(-0.5, Float64(c / b), Float64(Float64(-0.5625 * Float64(Float64((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0)))));
    	end
    	return tmp
    end
    
    code[a_, b_, c_] := If[LessEqual[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], -0.4], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(-3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision] + N[(N[(-0.5625 * N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -0.4:\\
    \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(-0.5, \frac{c}{b}, -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.40000000000000002

      1. Initial program 85.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. Simplified85.7%

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

        if -0.40000000000000002 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

        1. Initial program 48.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. Simplified48.4%

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, \frac{c}{b}, \mathsf{fma}\left(-0.16666666666666666, \frac{{c}^{2}}{a \cdot b} \cdot \left({\left(\frac{a \cdot -1.5}{b}\right)}^{2} + {\left(\frac{a}{b}\right)}^{2} \cdot 0\right), -0.16666666666666666 \cdot \left(\frac{{c}^{3}}{a \cdot b} \cdot \mathsf{fma}\left(-3, \frac{a}{{b}^{2}} \cdot \left({\left(\frac{a}{b}\right)}^{2} \cdot 0\right), \frac{1.5 \cdot a}{\frac{{b}^{2}}{{\left(\frac{a \cdot -1.5}{b}\right)}^{2} + {\left(\frac{a}{b}\right)}^{2} \cdot 0}}\right) + \frac{{c}^{4}}{a} \cdot \frac{\mathsf{fma}\left(-9, \frac{{a}^{2}}{{b}^{4}} \cdot \left({\left(\frac{a}{b}\right)}^{2} \cdot 0\right), \mathsf{fma}\left(1.5, \frac{a}{{b}^{2}} \cdot \mathsf{fma}\left(-3, \frac{a}{{b}^{2}} \cdot \left({\left(\frac{a}{b}\right)}^{2} \cdot 0\right), \frac{1.5 \cdot a}{\frac{{b}^{2}}{{\left(\frac{a \cdot -1.5}{b}\right)}^{2} + {\left(\frac{a}{b}\right)}^{2} \cdot 0}}\right), \mathsf{fma}\left(9, \frac{{a}^{2}}{{b}^{4}} \cdot \left({\left(\frac{a}{b}\right)}^{2} \cdot 0\right), {\left(\frac{-0.5 \cdot \left({\left(\frac{a \cdot -1.5}{b}\right)}^{2} + {\left(\frac{a}{b}\right)}^{2} \cdot 0\right)}{b}\right)}^{2}\right)\right)\right)}{b}\right)\right)\right)} \]
          5. Taylor expanded in c around 0 92.7%

            \[\leadsto \mathsf{fma}\left(-0.5, \frac{c}{b}, \color{blue}{-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}}\right) \]
        3. Recombined 2 regimes into one program.
        4. Final simplification91.8%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -0.4:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.5, \frac{c}{b}, -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\ \end{array} \]

        Alternative 3: 89.3% accurate, 0.2× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -0.4:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.5 \cdot \frac{c}{b}\right)\\ \end{array} \end{array} \]
        (FPCore (a b c)
         :precision binary64
         (if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -0.4)
           (/ (- (sqrt (fma b b (* c (* -3.0 a)))) b) (* a 3.0))
           (+
            (* -0.5625 (/ (* (pow a 2.0) (pow c 3.0)) (pow b 5.0)))
            (+ (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0))) (* -0.5 (/ c b))))))
        double code(double a, double b, double c) {
        	double tmp;
        	if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -0.4) {
        		tmp = (sqrt(fma(b, b, (c * (-3.0 * a)))) - b) / (a * 3.0);
        	} else {
        		tmp = (-0.5625 * ((pow(a, 2.0) * pow(c, 3.0)) / pow(b, 5.0))) + ((-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0))) + (-0.5 * (c / b)));
        	}
        	return tmp;
        }
        
        function code(a, b, c)
        	tmp = 0.0
        	if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) <= -0.4)
        		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(-3.0 * a)))) - b) / Float64(a * 3.0));
        	else
        		tmp = Float64(Float64(-0.5625 * Float64(Float64((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + Float64(Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0))) + Float64(-0.5 * Float64(c / b))));
        	end
        	return tmp
        end
        
        code[a_, b_, c_] := If[LessEqual[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], -0.4], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(-3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5625 * N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -0.4:\\
        \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\
        
        \mathbf{else}:\\
        \;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.5 \cdot \frac{c}{b}\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.40000000000000002

          1. Initial program 85.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. Simplified85.7%

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

            if -0.40000000000000002 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

            1. Initial program 48.4%

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

              \[\leadsto \color{blue}{-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)} \]
          3. Recombined 2 regimes into one program.
          4. Final simplification91.8%

            \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -0.4:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.5 \cdot \frac{c}{b}\right)\\ \end{array} \]

          Alternative 4: 85.6% accurate, 0.3× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -0.00225:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.5 \cdot \frac{c}{b}\\ \end{array} \end{array} \]
          (FPCore (a b c)
           :precision binary64
           (if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -0.00225)
             (/ (- (sqrt (fma b b (* c (* -3.0 a)))) b) (* a 3.0))
             (+ (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0))) (* -0.5 (/ c b)))))
          double code(double a, double b, double c) {
          	double tmp;
          	if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -0.00225) {
          		tmp = (sqrt(fma(b, b, (c * (-3.0 * a)))) - b) / (a * 3.0);
          	} else {
          		tmp = (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0))) + (-0.5 * (c / b));
          	}
          	return tmp;
          }
          
          function code(a, b, c)
          	tmp = 0.0
          	if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) <= -0.00225)
          		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(-3.0 * a)))) - b) / Float64(a * 3.0));
          	else
          		tmp = Float64(Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0))) + Float64(-0.5 * Float64(c / b)));
          	end
          	return tmp
          end
          
          code[a_, b_, c_] := If[LessEqual[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], -0.00225], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(-3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -0.00225:\\
          \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\
          
          \mathbf{else}:\\
          \;\;\;\;-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.5 \cdot \frac{c}{b}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.00224999999999999983

            1. Initial program 78.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. Simplified79.0%

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

              if -0.00224999999999999983 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

              1. Initial program 43.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 91.3%

                \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}} \]
            3. Recombined 2 regimes into one program.
            4. Final simplification88.0%

              \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -0.00225:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.5 \cdot \frac{c}{b}\\ \end{array} \]

            Alternative 5: 76.4% accurate, 0.3× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -5 \cdot 10^{-7}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
            (FPCore (a b c)
             :precision binary64
             (if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -5e-7)
               (/ (- (sqrt (fma b b (* c (* -3.0 a)))) b) (* a 3.0))
               (/ (* c -0.5) b)))
            double code(double a, double b, double c) {
            	double tmp;
            	if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -5e-7) {
            		tmp = (sqrt(fma(b, b, (c * (-3.0 * a)))) - b) / (a * 3.0);
            	} else {
            		tmp = (c * -0.5) / b;
            	}
            	return tmp;
            }
            
            function code(a, b, c)
            	tmp = 0.0
            	if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) <= -5e-7)
            		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(-3.0 * a)))) - b) / Float64(a * 3.0));
            	else
            		tmp = Float64(Float64(c * -0.5) / b);
            	end
            	return tmp
            end
            
            code[a_, b_, c_] := If[LessEqual[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], -5e-7], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(-3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -5 \cdot 10^{-7}:\\
            \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{c \cdot -0.5}{b}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -4.99999999999999977e-7

              1. Initial program 70.6%

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

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

                if -4.99999999999999977e-7 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

                1. Initial program 30.6%

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

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

                    \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
                  2. *-commutative85.0%

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

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

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

              Alternative 6: 76.3% accurate, 0.5× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
              (FPCore (a b c)
               :precision binary64
               (let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))))
                 (if (<= t_0 -5e-7) t_0 (/ (* c -0.5) b))))
              double code(double a, double b, double c) {
              	double t_0 = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
              	double tmp;
              	if (t_0 <= -5e-7) {
              		tmp = t_0;
              	} else {
              		tmp = (c * -0.5) / b;
              	}
              	return tmp;
              }
              
              real(8) function code(a, b, c)
                  real(8), intent (in) :: a
                  real(8), intent (in) :: b
                  real(8), intent (in) :: c
                  real(8) :: t_0
                  real(8) :: tmp
                  t_0 = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
                  if (t_0 <= (-5d-7)) then
                      tmp = t_0
                  else
                      tmp = (c * (-0.5d0)) / b
                  end if
                  code = tmp
              end function
              
              public static double code(double a, double b, double c) {
              	double t_0 = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
              	double tmp;
              	if (t_0 <= -5e-7) {
              		tmp = t_0;
              	} else {
              		tmp = (c * -0.5) / b;
              	}
              	return tmp;
              }
              
              def code(a, b, c):
              	t_0 = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)
              	tmp = 0
              	if t_0 <= -5e-7:
              		tmp = t_0
              	else:
              		tmp = (c * -0.5) / b
              	return tmp
              
              function code(a, b, c)
              	t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0))
              	tmp = 0.0
              	if (t_0 <= -5e-7)
              		tmp = t_0;
              	else
              		tmp = Float64(Float64(c * -0.5) / b);
              	end
              	return tmp
              end
              
              function tmp_2 = code(a, b, c)
              	t_0 = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
              	tmp = 0.0;
              	if (t_0 <= -5e-7)
              		tmp = t_0;
              	else
              		tmp = (c * -0.5) / b;
              	end
              	tmp_2 = tmp;
              end
              
              code[a_, b_, c_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, -5e-7], t$95$0, N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
              \mathbf{if}\;t_0 \leq -5 \cdot 10^{-7}:\\
              \;\;\;\;t_0\\
              
              \mathbf{else}:\\
              \;\;\;\;\frac{c \cdot -0.5}{b}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -4.99999999999999977e-7

                1. Initial program 70.6%

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

                if -4.99999999999999977e-7 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

                1. Initial program 30.6%

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

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

                    \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
                  2. *-commutative85.0%

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

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

                \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -5 \cdot 10^{-7}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

              Alternative 7: 64.1% accurate, 23.2× speedup?

              \[\begin{array}{l} \\ c \cdot \frac{-0.5}{b} \end{array} \]
              (FPCore (a b c) :precision binary64 (* c (/ -0.5 b)))
              double code(double a, double b, double c) {
              	return c * (-0.5 / b);
              }
              
              real(8) function code(a, b, c)
                  real(8), intent (in) :: a
                  real(8), intent (in) :: b
                  real(8), intent (in) :: c
                  code = c * ((-0.5d0) / b)
              end function
              
              public static double code(double a, double b, double c) {
              	return c * (-0.5 / b);
              }
              
              def code(a, b, c):
              	return c * (-0.5 / b)
              
              function code(a, b, c)
              	return Float64(c * Float64(-0.5 / b))
              end
              
              function tmp = code(a, b, c)
              	tmp = c * (-0.5 / b);
              end
              
              code[a_, b_, c_] := N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              c \cdot \frac{-0.5}{b}
              \end{array}
              
              Derivation
              1. Initial program 53.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. Simplified53.1%

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

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

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

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

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

                  \[\leadsto \color{blue}{\frac{-0.5}{\frac{b}{c}}} \]
                6. Step-by-step derivation
                  1. associate-/r/66.6%

                    \[\leadsto \color{blue}{\frac{-0.5}{b} \cdot c} \]
                7. Applied egg-rr66.6%

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

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

                Alternative 8: 64.1% accurate, 23.2× speedup?

                \[\begin{array}{l} \\ \frac{c \cdot -0.5}{b} \end{array} \]
                (FPCore (a b c) :precision binary64 (/ (* c -0.5) b))
                double code(double a, double b, double c) {
                	return (c * -0.5) / b;
                }
                
                real(8) function code(a, b, c)
                    real(8), intent (in) :: a
                    real(8), intent (in) :: b
                    real(8), intent (in) :: c
                    code = (c * (-0.5d0)) / b
                end function
                
                public static double code(double a, double b, double c) {
                	return (c * -0.5) / b;
                }
                
                def code(a, b, c):
                	return (c * -0.5) / b
                
                function code(a, b, c)
                	return Float64(Float64(c * -0.5) / b)
                end
                
                function tmp = code(a, b, c)
                	tmp = (c * -0.5) / b;
                end
                
                code[a_, b_, c_] := N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]
                
                \begin{array}{l}
                
                \\
                \frac{c \cdot -0.5}{b}
                \end{array}
                
                Derivation
                1. Initial program 53.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 66.7%

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

                    \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
                  2. *-commutative66.7%

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

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

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

                Reproduce

                ?
                herbie shell --seed 2023336 
                (FPCore (a b c)
                  :name "Cubic critical, narrow range"
                  :precision binary64
                  :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
                  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))