Cubic critical, wide range

Percentage Accurate: 18.2% → 99.7%
Time: 8.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: 18.2% 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.7% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\frac{\color{blue}{c \cdot \left(a \cdot -3\right)}}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b}}{3 \cdot a} \]
  9. Step-by-step derivation
    1. expm1-log1p-u83.2%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{c \cdot \left(a \cdot -3\right)}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b}}{3 \cdot a}\right)} - 1} \]
    3. associate-/l/22.3%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{c \cdot \left(a \cdot -3\right)}{\left(3 \cdot a\right) \cdot \left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b\right)}}\right)} - 1 \]
    4. *-commutative22.3%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{c \cdot \left(a \cdot -3\right)}{\color{blue}{\left(a \cdot 3\right)} \cdot \left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b\right)}\right)} - 1 \]
    5. +-commutative22.3%

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

      \[\leadsto e^{\mathsf{log1p}\left(\frac{c \cdot \left(a \cdot -3\right)}{\left(a \cdot 3\right) \cdot \left(b + \sqrt{b \cdot b - \color{blue}{c \cdot \left(a \cdot 3\right)}}\right)}\right)} - 1 \]
  10. Applied egg-rr22.3%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{c \cdot \left(a \cdot -3\right)}{\left(a \cdot 3\right) \cdot \left(b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}\right)}\right)} - 1} \]
  11. Step-by-step derivation
    1. expm1-def83.1%

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

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

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

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

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

Alternative 2: 99.4% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\frac{\color{blue}{c \cdot \left(a \cdot -3\right)}}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b}}{3 \cdot a} \]
  9. Step-by-step derivation
    1. expm1-log1p-u88.6%

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

      \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\frac{c \cdot \left(a \cdot -3\right)}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b}\right)} - 1}}{3 \cdot a} \]
    3. +-commutative18.7%

      \[\leadsto \frac{e^{\mathsf{log1p}\left(\frac{c \cdot \left(a \cdot -3\right)}{\color{blue}{b + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}}}\right)} - 1}{3 \cdot a} \]
    4. associate-*l*18.7%

      \[\leadsto \frac{e^{\mathsf{log1p}\left(\frac{c \cdot \left(a \cdot -3\right)}{b + \sqrt{b \cdot b - \color{blue}{c \cdot \left(a \cdot 3\right)}}}\right)} - 1}{3 \cdot a} \]
  10. Applied egg-rr18.7%

    \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\frac{c \cdot \left(a \cdot -3\right)}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}\right)} - 1}}{3 \cdot a} \]
  11. Step-by-step derivation
    1. expm1-def88.6%

      \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{c \cdot \left(a \cdot -3\right)}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}\right)\right)}}{3 \cdot a} \]
    2. expm1-log1p99.5%

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

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

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

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

Alternative 3: 95.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ -0.375 \cdot \left(a \cdot \frac{c \cdot c}{{b}^{3}}\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(Float64(c * 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[(N[(c * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 90.1% 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.5%

    \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

      \[\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.5%

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

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

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

Reproduce

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