Cubic critical, wide range

Percentage Accurate: 17.7% → 99.4%
Time: 7.4s
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.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(a \cdot -3\right)\\ -\frac{\frac{t_0}{\left(-b\right) - \sqrt{t_0 + b \cdot b}}}{a \cdot 3} \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (* c (* a -3.0))))
   (- (/ (/ t_0 (- (- b) (sqrt (+ t_0 (* b b))))) (* a 3.0)))))
double code(double a, double b, double c) {
	double t_0 = c * (a * -3.0);
	return -((t_0 / (-b - sqrt((t_0 + (b * b))))) / (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((t_0 + (b * b))))) / (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((t_0 + (b * b))))) / (a * 3.0));
}
def code(a, b, c):
	t_0 = c * (a * -3.0)
	return -((t_0 / (-b - math.sqrt((t_0 + (b * b))))) / (a * 3.0))
function code(a, b, c)
	t_0 = Float64(c * Float64(a * -3.0))
	return Float64(-Float64(Float64(t_0 / Float64(Float64(-b) - sqrt(Float64(t_0 + Float64(b * b))))) / Float64(a * 3.0)))
end
function tmp = code(a, b, c)
	t_0 = c * (a * -3.0);
	tmp = -((t_0 / (-b - sqrt((t_0 + (b * b))))) / (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[(t$95$0 + N[(b * b), $MachinePrecision]), $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{t_0 + b \cdot b}}}{a \cdot 3}
\end{array}
\end{array}
Derivation
  1. Initial program 17.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{0} - \left(-\left(c \cdot a\right) \cdot 3\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}}}{3 \cdot a} \]
    5. distribute-rgt-neg-in99.2%

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

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

      \[\leadsto \frac{\frac{0 - \color{blue}{c \cdot \left(a \cdot -3\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}}}{3 \cdot a} \]
    8. sub-neg99.5%

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

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

      \[\leadsto \frac{\frac{0 - c \cdot \left(a \cdot -3\right)}{\left(-b\right) - \sqrt{\left(-\left(c \cdot a\right) \cdot 3\right) + \color{blue}{\left(-b\right) \cdot \left(-b\right)}}}}{3 \cdot a} \]
    11. distribute-rgt-neg-out99.5%

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

      \[\leadsto \frac{\frac{0 - c \cdot \left(a \cdot -3\right)}{\left(-b\right) - \sqrt{\color{blue}{\left(-\left(c \cdot a\right) \cdot 3\right) - \left(-b\right) \cdot b}}}}{3 \cdot a} \]
    13. distribute-rgt-neg-in99.5%

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

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

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

      \[\leadsto \frac{\frac{0 - c \cdot \left(a \cdot -3\right)}{\left(-b\right) - \sqrt{\color{blue}{\mathsf{fma}\left(c, a \cdot -3, -\left(-b\right) \cdot b\right)}}}}{3 \cdot a} \]
    17. distribute-rgt-neg-out99.5%

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

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

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

      \[\leadsto \frac{\frac{0 - c \cdot \left(a \cdot -3\right)}{\left(-b\right) - \sqrt{\color{blue}{c \cdot \left(a \cdot -3\right) + b \cdot b}}}}{3 \cdot a} \]
  10. Applied egg-rr99.5%

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

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

Alternative 2: 99.2% accurate, 0.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{0} - \left(-\left(c \cdot a\right) \cdot 3\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}}}{3 \cdot a} \]
    5. distribute-rgt-neg-in99.2%

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

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

      \[\leadsto \frac{\frac{0 - \color{blue}{c \cdot \left(a \cdot -3\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}}}{3 \cdot a} \]
    8. sub-neg99.5%

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

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

      \[\leadsto \frac{\frac{0 - c \cdot \left(a \cdot -3\right)}{\left(-b\right) - \sqrt{\left(-\left(c \cdot a\right) \cdot 3\right) + \color{blue}{\left(-b\right) \cdot \left(-b\right)}}}}{3 \cdot a} \]
    11. distribute-rgt-neg-out99.5%

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

      \[\leadsto \frac{\frac{0 - c \cdot \left(a \cdot -3\right)}{\left(-b\right) - \sqrt{\color{blue}{\left(-\left(c \cdot a\right) \cdot 3\right) - \left(-b\right) \cdot b}}}}{3 \cdot a} \]
    13. distribute-rgt-neg-in99.5%

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

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

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

      \[\leadsto \frac{\frac{0 - c \cdot \left(a \cdot -3\right)}{\left(-b\right) - \sqrt{\color{blue}{\mathsf{fma}\left(c, a \cdot -3, -\left(-b\right) \cdot b\right)}}}}{3 \cdot a} \]
    17. distribute-rgt-neg-out99.5%

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

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

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

      \[\leadsto \frac{\frac{0 - c \cdot \left(a \cdot -3\right)}{\left(-b\right) - \sqrt{\color{blue}{c \cdot \left(a \cdot -3\right) + b \cdot b}}}}{3 \cdot a} \]
  10. Applied egg-rr99.5%

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

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

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

Alternative 3: 95.3% accurate, 1.0× speedup?

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

\\
-0.375 \cdot \left(a \cdot \frac{c \cdot c}{{b}^{3}}\right) + -0.5 \cdot \frac{c}{b}
\end{array}
Derivation
  1. Initial program 17.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{\color{blue}{-3 \cdot a}} \]
    12. distribute-rgt-neg-in17.8%

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

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

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

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

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

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

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

      \[\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*95.4%

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

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

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

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

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

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

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

Alternative 4: 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 17.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{\color{blue}{-3 \cdot a}} \]
    12. distribute-rgt-neg-in17.8%

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

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

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

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

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

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

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

Reproduce

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