Cubic critical, wide range

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 95.3% accurate, 6.8× speedup?

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

\\
\frac{\frac{c \cdot a}{a}}{1.5 \cdot \frac{c \cdot a}{b} + b \cdot -2}
\end{array}
Derivation
  1. Initial program 15.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1 \cdot \frac{c \cdot a}{a}}{\color{blue}{1.5 \cdot \frac{c \cdot a}{b} + -2 \cdot b}} \]
  12. Final simplification96.7%

    \[\leadsto \frac{\frac{c \cdot a}{a}}{1.5 \cdot \frac{c \cdot a}{b} + b \cdot -2} \]

Alternative 3: 90.3% 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 15.0%

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

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

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

      \[\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/15.0%

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

      \[\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/15.0%

      \[\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/15.0%

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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