Cubic critical, wide range

Percentage Accurate: 17.6% → 98.6%
Time: 15.5s
Alternatives: 3
Speedup: 23.2×

Specification

?
\[\left(\left(4.930380657631324 \cdot 10^{-32} < a \land a < 2.028240960365167 \cdot 10^{+31}\right) \land \left(4.930380657631324 \cdot 10^{-32} < b \land b < 2.028240960365167 \cdot 10^{+31}\right)\right) \land \left(4.930380657631324 \cdot 10^{-32} < c \land c < 2.028240960365167 \cdot 10^{+31}\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 3 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: 17.6% 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: 98.6% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(a \cdot -3\right)\\ \sqrt[3]{{\left(\frac{0.3333333333333333}{a} \cdot \frac{b \cdot \left(b \cdot 0\right) + t_0}{b + \sqrt{\mathsf{fma}\left(b, b, t_0\right)}}\right)}^{3}} \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (* c (* a -3.0))))
   (cbrt
    (pow
     (*
      (/ 0.3333333333333333 a)
      (/ (+ (* b (* b 0.0)) t_0) (+ b (sqrt (fma b b t_0)))))
     3.0))))
double code(double a, double b, double c) {
	double t_0 = c * (a * -3.0);
	return cbrt(pow(((0.3333333333333333 / a) * (((b * (b * 0.0)) + t_0) / (b + sqrt(fma(b, b, t_0))))), 3.0));
}
function code(a, b, c)
	t_0 = Float64(c * Float64(a * -3.0))
	return cbrt((Float64(Float64(0.3333333333333333 / a) * Float64(Float64(Float64(b * Float64(b * 0.0)) + t_0) / Float64(b + sqrt(fma(b, b, t_0))))) ^ 3.0))
end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]}, N[Power[N[Power[N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[(N[(b * N[(b * 0.0), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] / N[(b + N[Sqrt[N[(b * b + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot \left(a \cdot -3\right)\\
\sqrt[3]{{\left(\frac{0.3333333333333333}{a} \cdot \frac{b \cdot \left(b \cdot 0\right) + t_0}{b + \sqrt{\mathsf{fma}\left(b, b, t_0\right)}}\right)}^{3}}
\end{array}
\end{array}
Derivation
  1. Initial program 18.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. neg-sub018.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{\color{blue}{e^{\log \left(3 \cdot a\right)}}} \]
  6. Step-by-step derivation
    1. add-cbrt-cube18.3%

      \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{e^{\log \left(3 \cdot a\right)}} \cdot \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{e^{\log \left(3 \cdot a\right)}}\right) \cdot \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{e^{\log \left(3 \cdot a\right)}}}} \]
    2. add-exp-log18.3%

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

      \[\leadsto \sqrt[3]{\left(\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{\color{blue}{a \cdot 3}} \cdot \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{e^{\log \left(3 \cdot a\right)}}\right) \cdot \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{e^{\log \left(3 \cdot a\right)}}} \]
    4. add-exp-log18.3%

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

      \[\leadsto \sqrt[3]{\left(\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{a \cdot 3} \cdot \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{\color{blue}{a \cdot 3}}\right) \cdot \frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{e^{\log \left(3 \cdot a\right)}}} \]
    6. add-exp-log18.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt[3]{{\left(\frac{0.3333333333333333}{a} \cdot \left(\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b\right)\right)}^{3}}} \]
  10. Step-by-step derivation
    1. flip--18.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt[3]{{\left(\frac{0.3333333333333333}{a} \cdot \frac{\left(\color{blue}{b \cdot \left(-b\right)} + b \cdot b\right) + c \cdot \left(a \cdot -3\right)}{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)} + b}\right)}^{3}} \]
    5. distribute-lft-out98.6%

      \[\leadsto \sqrt[3]{{\left(\frac{0.3333333333333333}{a} \cdot \frac{\color{blue}{b \cdot \left(\left(-b\right) + b\right)} + c \cdot \left(a \cdot -3\right)}{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)} + b}\right)}^{3}} \]
    6. neg-mul-198.6%

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

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

      \[\leadsto \sqrt[3]{{\left(\frac{0.3333333333333333}{a} \cdot \frac{b \cdot \color{blue}{\left(b \cdot \left(-1 + 1\right)\right)} + c \cdot \left(a \cdot -3\right)}{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)} + b}\right)}^{3}} \]
    9. metadata-eval98.6%

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

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

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

Alternative 2: 95.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ -0.375 \cdot \left(a \cdot \left(c \cdot \frac{c}{{b}^{3}}\right)\right) + \frac{c \cdot -0.5}{b} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (+ (* -0.375 (* a (* c (/ c (pow b 3.0))))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
	return (-0.375 * (a * (c * (c / pow(b, 3.0))))) + ((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 = ((-0.375d0) * (a * (c * (c / (b ** 3.0d0))))) + ((c * (-0.5d0)) / b)
end function
public static double code(double a, double b, double c) {
	return (-0.375 * (a * (c * (c / Math.pow(b, 3.0))))) + ((c * -0.5) / b);
}
def code(a, b, c):
	return (-0.375 * (a * (c * (c / math.pow(b, 3.0))))) + ((c * -0.5) / b)
function code(a, b, c)
	return Float64(Float64(-0.375 * Float64(a * Float64(c * Float64(c / (b ^ 3.0))))) + Float64(Float64(c * -0.5) / b))
end
function tmp = code(a, b, c)
	tmp = (-0.375 * (a * (c * (c / (b ^ 3.0))))) + ((c * -0.5) / b);
end
code[a_, b_, c_] := N[(N[(-0.375 * N[(a * N[(c * N[(c / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
-0.375 \cdot \left(a \cdot \left(c \cdot \frac{c}{{b}^{3}}\right)\right) + \frac{c \cdot -0.5}{b}
\end{array}
Derivation
  1. Initial program 18.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 94.8%

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}} \]
  3. Step-by-step derivation
    1. +-commutative94.8%

      \[\leadsto \color{blue}{-0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + -0.5 \cdot \frac{c}{b}} \]
    2. fma-def94.8%

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

      \[\leadsto \mathsf{fma}\left(-0.375, \color{blue}{\frac{{c}^{2}}{\frac{{b}^{3}}{a}}}, -0.5 \cdot \frac{c}{b}\right) \]
    4. associate-/r/94.8%

      \[\leadsto \mathsf{fma}\left(-0.375, \color{blue}{\frac{{c}^{2}}{{b}^{3}} \cdot a}, -0.5 \cdot \frac{c}{b}\right) \]
    5. unpow294.8%

      \[\leadsto \mathsf{fma}\left(-0.375, \frac{\color{blue}{c \cdot c}}{{b}^{3}} \cdot a, -0.5 \cdot \frac{c}{b}\right) \]
    6. associate-/l*94.8%

      \[\leadsto \mathsf{fma}\left(-0.375, \color{blue}{\frac{c}{\frac{{b}^{3}}{c}}} \cdot a, -0.5 \cdot \frac{c}{b}\right) \]
  4. Simplified94.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.375, \frac{c}{\frac{{b}^{3}}{c}} \cdot a, -0.5 \cdot \frac{c}{b}\right)} \]
  5. Step-by-step derivation
    1. fma-udef94.8%

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

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

      \[\leadsto -0.375 \cdot \left(\left(\frac{c}{{b}^{3}} \cdot c\right) \cdot a\right) + \color{blue}{\frac{-0.5 \cdot c}{b}} \]
  6. Applied egg-rr94.8%

    \[\leadsto \color{blue}{-0.375 \cdot \left(\left(\frac{c}{{b}^{3}} \cdot c\right) \cdot a\right) + \frac{-0.5 \cdot c}{b}} \]
  7. Final simplification94.8%

    \[\leadsto -0.375 \cdot \left(a \cdot \left(c \cdot \frac{c}{{b}^{3}}\right)\right) + \frac{c \cdot -0.5}{b} \]

Alternative 3: 90.5% 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 18.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 90.3%

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

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

Reproduce

?
herbie shell --seed 2023274 
(FPCore (a b c)
  :name "Cubic critical, wide range"
  :precision binary64
  :pre (and (and (and (< 4.930380657631324e-32 a) (< a 2.028240960365167e+31)) (and (< 4.930380657631324e-32 b) (< b 2.028240960365167e+31))) (and (< 4.930380657631324e-32 c) (< c 2.028240960365167e+31)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))