Cubic critical, wide range

Percentage Accurate: 17.7% → 99.4%
Time: 13.7s
Alternatives: 4
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 4 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.7% 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.4% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := c \cdot \left(a \cdot 3\right)\\
\frac{\frac{t\_0}{\left(-b\right) - \sqrt{{b}^{2} - t\_0}}}{a \cdot 3}
\end{array}
\end{array}
Derivation
  1. Initial program 17.4%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-cbrt-cube17.4%

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{{\left({\color{blue}{\left({b}^{2}\right)}}^{3}\right)}^{0.3333333333333333} - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    5. pow-pow18.8%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{{\left({b}^{\color{blue}{6}}\right)}^{0.3333333333333333} - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  4. Applied egg-rr18.8%

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

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

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

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

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

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \color{blue}{\left(\sqrt[3]{{b}^{6}} - \left(3 \cdot a\right) \cdot c\right)}}{\left(-b\right) - \sqrt{\sqrt[3]{{b}^{6}} - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
    4. pow1/318.9%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left(\color{blue}{{\left({b}^{6}\right)}^{0.3333333333333333}} - \left(3 \cdot a\right) \cdot c\right)}{\left(-b\right) - \sqrt{\sqrt[3]{{b}^{6}} - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
    5. pow-pow18.0%

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

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

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \color{blue}{c \cdot \left(3 \cdot a\right)}\right)}{\left(-b\right) - \sqrt{\sqrt[3]{{b}^{6}} - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
    8. pow1/317.9%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - c \cdot \left(3 \cdot a\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{{\left({b}^{6}\right)}^{0.3333333333333333}} - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
    9. pow-pow18.0%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - c \cdot \left(3 \cdot a\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{{b}^{\left(6 \cdot 0.3333333333333333\right)}} - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
    10. metadata-eval18.0%

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

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - c \cdot \left(3 \cdot a\right)\right)}{\left(-b\right) - \sqrt{{b}^{2} - \color{blue}{c \cdot \left(3 \cdot a\right)}}}}{3 \cdot a} \]
  8. Applied egg-rr18.0%

    \[\leadsto \frac{\color{blue}{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - c \cdot \left(3 \cdot a\right)\right)}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(3 \cdot a\right)}}}}{3 \cdot a} \]
  9. Step-by-step derivation
    1. associate--r-99.5%

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

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

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

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

    \[\leadsto \frac{\frac{\color{blue}{0} + c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot 3\right)}}}{3 \cdot a} \]
  12. Final simplification99.5%

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

Alternative 2: 99.2% accurate, 0.5× speedup?

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

\\
\frac{\frac{3 \cdot \left(c \cdot a\right)}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot 3\right)}}}{a \cdot 3}
\end{array}
Derivation
  1. Initial program 17.4%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-cbrt-cube17.4%

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{{\left({\color{blue}{\left({b}^{2}\right)}}^{3}\right)}^{0.3333333333333333} - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    5. pow-pow18.8%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{{\left({b}^{\color{blue}{6}}\right)}^{0.3333333333333333} - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  4. Applied egg-rr18.8%

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

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

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

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

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

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \color{blue}{\left(\sqrt[3]{{b}^{6}} - \left(3 \cdot a\right) \cdot c\right)}}{\left(-b\right) - \sqrt{\sqrt[3]{{b}^{6}} - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
    4. pow1/318.9%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left(\color{blue}{{\left({b}^{6}\right)}^{0.3333333333333333}} - \left(3 \cdot a\right) \cdot c\right)}{\left(-b\right) - \sqrt{\sqrt[3]{{b}^{6}} - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
    5. pow-pow18.0%

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

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

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \color{blue}{c \cdot \left(3 \cdot a\right)}\right)}{\left(-b\right) - \sqrt{\sqrt[3]{{b}^{6}} - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
    8. pow1/317.9%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - c \cdot \left(3 \cdot a\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{{\left({b}^{6}\right)}^{0.3333333333333333}} - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
    9. pow-pow18.0%

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - c \cdot \left(3 \cdot a\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{{b}^{\left(6 \cdot 0.3333333333333333\right)}} - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
    10. metadata-eval18.0%

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

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - c \cdot \left(3 \cdot a\right)\right)}{\left(-b\right) - \sqrt{{b}^{2} - \color{blue}{c \cdot \left(3 \cdot a\right)}}}}{3 \cdot a} \]
  8. Applied egg-rr18.0%

    \[\leadsto \frac{\color{blue}{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - c \cdot \left(3 \cdot a\right)\right)}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(3 \cdot a\right)}}}}{3 \cdot a} \]
  9. Step-by-step derivation
    1. associate--r-99.5%

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

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

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

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

    \[\leadsto \frac{\frac{\color{blue}{3 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot 3\right)}}}{3 \cdot a} \]
  12. Final simplification99.2%

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

Alternative 3: 95.4% accurate, 6.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-0.5, c, -0.375 \cdot \left(a \cdot \left(\color{blue}{{\left(\frac{c}{b}\right)}^{1}} \cdot \frac{c}{b}\right)\right)\right)}{b} \]
      7. pow-plus95.3%

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-0.5 \cdot c + \left(-0.375 \cdot a\right) \cdot {\left(\frac{c}{b}\right)}^{2}}}{b} \]
    11. Step-by-step derivation
      1. unpow295.3%

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

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

      \[\leadsto \frac{c \cdot -0.5 + \left(a \cdot -0.375\right) \cdot \left(\frac{c}{b} \cdot \frac{c}{b}\right)}{b} \]
    14. Add Preprocessing

    Alternative 4: 90.4% 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 17.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. Simplified17.5%

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

        \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
      4. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2024177 
      (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)))