Cubic critical, medium range

Percentage Accurate: 44.2% → 86.9%
Time: 19.8s
Alternatives: 7
Speedup: 23.2×

Specification

?
\[\left(\left(1.1102230246251565 \cdot 10^{-16} < a \land a < 9007199254740992\right) \land \left(1.1102230246251565 \cdot 10^{-16} < b \land b < 9007199254740992\right)\right) \land \left(1.1102230246251565 \cdot 10^{-16} < c \land c < 9007199254740992\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 7 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: 44.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: 86.9% accurate, 0.5× speedup?

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

\\
\frac{\frac{c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{a \cdot \left(c \cdot -3\right) + {b}^{2}}}}{a \cdot 3}
\end{array}
Derivation
  1. Initial program 42.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. sqr-neg42.0%

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

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

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

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{3 \cdot a}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. expm1-log1p-u42.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(3 \cdot \left(a \cdot c\right)\right)\right)}\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(e^{\mathsf{log1p}\left(3 \cdot \left(a \cdot c\right)\right)} - 1\right)}}}{3 \cdot a} \]
    6. expm1-log1p-u40.9%

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

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

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

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \left(a \cdot 3\right) \cdot c\right)}{\left(-b\right) - \sqrt{\color{blue}{{b}^{2}} - \left(e^{\mathsf{log1p}\left(3 \cdot \left(a \cdot c\right)\right)} - 1\right)}}}{3 \cdot a} \]
    10. expm1-define42.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(a, c \cdot 3, \color{blue}{{b}^{2}} - {b}^{2}\right) \cdot \frac{1}{\left(-b\right) - \sqrt{{b}^{2} - a \cdot \left(c \cdot 3\right)}}}{3 \cdot a} \]
  12. Applied egg-rr89.0%

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(a, c \cdot 3, {b}^{2} - {b}^{2}\right) \cdot \frac{1}{\left(-b\right) - \sqrt{{b}^{2} - a \cdot \left(c \cdot 3\right)}}}}{3 \cdot a} \]
  13. Step-by-step derivation
    1. associate-*r/89.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{\color{blue}{\left(-a \cdot \left(c \cdot 3\right)\right) + {b}^{2}}}}}{3 \cdot a} \]
    13. distribute-rgt-neg-in89.1%

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

      \[\leadsto \frac{\frac{c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{\color{blue}{\mathsf{fma}\left(a, -c \cdot 3, {b}^{2}\right)}}}}{3 \cdot a} \]
    15. distribute-rgt-neg-in89.1%

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

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

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

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

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

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

Alternative 2: 70.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -10:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -10.0)
   (/ (- (sqrt (fma b b (* a (* c -3.0)))) b) (* a 3.0))
   (/ (* c -0.5) b)))
double code(double a, double b, double c) {
	double tmp;
	if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -10.0) {
		tmp = (sqrt(fma(b, b, (a * (c * -3.0)))) - b) / (a * 3.0);
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) <= -10.0)
		tmp = Float64(Float64(sqrt(fma(b, b, Float64(a * Float64(c * -3.0)))) - b) / Float64(a * 3.0));
	else
		tmp = Float64(Float64(c * -0.5) / b);
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -10.0], N[(N[(N[Sqrt[N[(b * b + N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -10:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{a \cdot 3}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -10

    1. Initial program 67.7%

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

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

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

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

    if -10 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

    1. Initial program 37.2%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{3 \cdot a}} \]
    4. Add Preprocessing
    5. Taylor expanded in b around inf 73.8%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    6. Step-by-step derivation
      1. *-commutative73.8%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/73.8%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    7. Simplified73.8%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification72.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -10:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 70.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\ \mathbf{if}\;t\_0 \leq -10:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))))
   (if (<= t_0 -10.0) t_0 (/ (* c -0.5) b))))
double code(double a, double b, double c) {
	double t_0 = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
	double tmp;
	if (t_0 <= -10.0) {
		tmp = t_0;
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
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
    real(8) :: tmp
    t_0 = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
    if (t_0 <= (-10.0d0)) then
        tmp = t_0
    else
        tmp = (c * (-0.5d0)) / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double t_0 = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
	double tmp;
	if (t_0 <= -10.0) {
		tmp = t_0;
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
def code(a, b, c):
	t_0 = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)
	tmp = 0
	if t_0 <= -10.0:
		tmp = t_0
	else:
		tmp = (c * -0.5) / b
	return tmp
function code(a, b, c)
	t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0))
	tmp = 0.0
	if (t_0 <= -10.0)
		tmp = t_0;
	else
		tmp = Float64(Float64(c * -0.5) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	t_0 = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
	tmp = 0.0;
	if (t_0 <= -10.0)
		tmp = t_0;
	else
		tmp = (c * -0.5) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -10.0], t$95$0, N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{if}\;t\_0 \leq -10:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -10

    1. Initial program 67.7%

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

    if -10 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

    1. Initial program 37.2%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{3 \cdot a}} \]
    4. Add Preprocessing
    5. Taylor expanded in b around inf 73.8%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    6. Step-by-step derivation
      1. *-commutative73.8%

        \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
      2. associate-*l/73.8%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    7. Simplified73.8%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification72.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -10:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 78.1% accurate, 0.5× speedup?

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

\\
-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}
\end{array}
Derivation
  1. Initial program 42.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. sqr-neg42.0%

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

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

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

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{3 \cdot a}} \]
  4. Add Preprocessing
  5. Taylor expanded in b around inf 80.6%

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}} \]
  6. Final simplification80.6%

    \[\leadsto -0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} \]
  7. Add Preprocessing

Alternative 5: 68.3% accurate, 23.2× speedup?

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

\\
c \cdot \frac{-0.5}{b}
\end{array}
Derivation
  1. Initial program 42.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. sqr-neg42.0%

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

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

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

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{3 \cdot a}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. expm1-log1p-u42.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(3 \cdot \left(a \cdot c\right)\right)\right)}\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(e^{\mathsf{log1p}\left(3 \cdot \left(a \cdot c\right)\right)} - 1\right)}}}{3 \cdot a} \]
    6. expm1-log1p-u40.9%

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

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

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

      \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \left({b}^{2} - \left(a \cdot 3\right) \cdot c\right)}{\left(-b\right) - \sqrt{\color{blue}{{b}^{2}} - \left(e^{\mathsf{log1p}\left(3 \cdot \left(a \cdot c\right)\right)} - 1\right)}}}{3 \cdot a} \]
    10. expm1-define42.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(a, c \cdot 3, \color{blue}{{b}^{2}} - {b}^{2}\right) \cdot \frac{1}{\left(-b\right) - \sqrt{{b}^{2} - a \cdot \left(c \cdot 3\right)}}}{3 \cdot a} \]
  12. Applied egg-rr89.0%

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(a, c \cdot 3, {b}^{2} - {b}^{2}\right) \cdot \frac{1}{\left(-b\right) - \sqrt{{b}^{2} - a \cdot \left(c \cdot 3\right)}}}}{3 \cdot a} \]
  13. Step-by-step derivation
    1. associate-*r/89.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{\color{blue}{\left(-a \cdot \left(c \cdot 3\right)\right) + {b}^{2}}}}}{3 \cdot a} \]
    13. distribute-rgt-neg-in89.1%

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

      \[\leadsto \frac{\frac{c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{\color{blue}{\mathsf{fma}\left(a, -c \cdot 3, {b}^{2}\right)}}}}{3 \cdot a} \]
    15. distribute-rgt-neg-in89.1%

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

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

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

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  16. Step-by-step derivation
    1. *-commutative71.0%

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    2. associate-*l/71.0%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
    3. associate-*r/70.8%

      \[\leadsto \color{blue}{c \cdot \frac{-0.5}{b}} \]
  17. Simplified70.8%

    \[\leadsto \color{blue}{c \cdot \frac{-0.5}{b}} \]
  18. Final simplification70.8%

    \[\leadsto c \cdot \frac{-0.5}{b} \]
  19. Add Preprocessing

Alternative 6: 68.3% accurate, 23.2× speedup?

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

\\
\frac{-0.5}{\frac{b}{c}}
\end{array}
Derivation
  1. Initial program 42.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. sqr-neg42.0%

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

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

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

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{3 \cdot a}} \]
  4. Add Preprocessing
  5. Taylor expanded in b around inf 70.6%

    \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a} \]
  6. Step-by-step derivation
    1. associate-*r/70.7%

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

      \[\leadsto \color{blue}{-1.5 \cdot \frac{a \cdot \frac{c}{b}}{3 \cdot a}} \]
    3. *-commutative70.7%

      \[\leadsto -1.5 \cdot \frac{a \cdot \frac{c}{b}}{\color{blue}{a \cdot 3}} \]
  7. Applied egg-rr70.7%

    \[\leadsto \color{blue}{-1.5 \cdot \frac{a \cdot \frac{c}{b}}{a \cdot 3}} \]
  8. Step-by-step derivation
    1. times-frac70.8%

      \[\leadsto -1.5 \cdot \color{blue}{\left(\frac{a}{a} \cdot \frac{\frac{c}{b}}{3}\right)} \]
    2. *-inverses70.8%

      \[\leadsto -1.5 \cdot \left(\color{blue}{1} \cdot \frac{\frac{c}{b}}{3}\right) \]
    3. associate-*r*70.8%

      \[\leadsto \color{blue}{\left(-1.5 \cdot 1\right) \cdot \frac{\frac{c}{b}}{3}} \]
    4. metadata-eval70.8%

      \[\leadsto \color{blue}{-1.5} \cdot \frac{\frac{c}{b}}{3} \]
    5. associate-/l/70.7%

      \[\leadsto -1.5 \cdot \color{blue}{\frac{c}{3 \cdot b}} \]
  9. Simplified70.7%

    \[\leadsto \color{blue}{-1.5 \cdot \frac{c}{3 \cdot b}} \]
  10. Step-by-step derivation
    1. associate-*r/70.7%

      \[\leadsto \color{blue}{\frac{-1.5 \cdot c}{3 \cdot b}} \]
    2. *-commutative70.7%

      \[\leadsto \frac{-1.5 \cdot c}{\color{blue}{b \cdot 3}} \]
  11. Applied egg-rr70.7%

    \[\leadsto \color{blue}{\frac{-1.5 \cdot c}{b \cdot 3}} \]
  12. Step-by-step derivation
    1. clear-num70.7%

      \[\leadsto \color{blue}{\frac{1}{\frac{b \cdot 3}{-1.5 \cdot c}}} \]
    2. inv-pow70.7%

      \[\leadsto \color{blue}{{\left(\frac{b \cdot 3}{-1.5 \cdot c}\right)}^{-1}} \]
    3. *-commutative70.7%

      \[\leadsto {\left(\frac{b \cdot 3}{\color{blue}{c \cdot -1.5}}\right)}^{-1} \]
    4. times-frac70.8%

      \[\leadsto {\color{blue}{\left(\frac{b}{c} \cdot \frac{3}{-1.5}\right)}}^{-1} \]
    5. metadata-eval70.8%

      \[\leadsto {\left(\frac{b}{c} \cdot \color{blue}{-2}\right)}^{-1} \]
  13. Applied egg-rr70.8%

    \[\leadsto \color{blue}{{\left(\frac{b}{c} \cdot -2\right)}^{-1}} \]
  14. Step-by-step derivation
    1. unpow-170.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{b}{c} \cdot -2}} \]
    2. *-commutative70.8%

      \[\leadsto \frac{1}{\color{blue}{-2 \cdot \frac{b}{c}}} \]
    3. associate-/r*70.8%

      \[\leadsto \color{blue}{\frac{\frac{1}{-2}}{\frac{b}{c}}} \]
    4. metadata-eval70.8%

      \[\leadsto \frac{\color{blue}{-0.5}}{\frac{b}{c}} \]
  15. Simplified70.8%

    \[\leadsto \color{blue}{\frac{-0.5}{\frac{b}{c}}} \]
  16. Final simplification70.8%

    \[\leadsto \frac{-0.5}{\frac{b}{c}} \]
  17. Add Preprocessing

Alternative 7: 68.5% accurate, 23.2× speedup?

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

\\
\frac{c \cdot -0.5}{b}
\end{array}
Derivation
  1. Initial program 42.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. sqr-neg42.0%

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

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

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

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{3 \cdot a}} \]
  4. Add Preprocessing
  5. Taylor expanded in b around inf 71.0%

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  6. Step-by-step derivation
    1. *-commutative71.0%

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    2. associate-*l/71.0%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  7. Simplified71.0%

    \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  8. Final simplification71.0%

    \[\leadsto \frac{c \cdot -0.5}{b} \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2024052 
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :precision binary64
  :pre (and (and (and (< 1.1102230246251565e-16 a) (< a 9007199254740992.0)) (and (< 1.1102230246251565e-16 b) (< b 9007199254740992.0))) (and (< 1.1102230246251565e-16 c) (< c 9007199254740992.0)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))