Cubic critical, narrow range

Percentage Accurate: 55.3% → 99.3%
Time: 16.7s
Alternatives: 8
Speedup: 23.2×

Specification

?
\[\left(\left(1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156\right) \land \left(1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156\right)\right) \land \left(1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\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 8 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: 55.3% 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.3% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) + \color{blue}{a \cdot \left(c \cdot 3\right)}}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot 3\right)}}}{3 \cdot a} \]
    5. associate-*r*99.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}{\left(c \cdot a\right) \cdot 3}}}}{3 \cdot a} \]
    6. *-commutative99.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}{\left(a \cdot c\right)} \cdot 3}}}{3 \cdot a} \]
    7. associate-*r*99.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(c \cdot 3\right)}}}}{3 \cdot a} \]
  10. Simplified99.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. add-exp-log97.3%

      \[\leadsto \frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) + \color{blue}{e^{\log \left(a \cdot \left(c \cdot 3\right)\right)}}}{\left(-b\right) - \sqrt{{b}^{2} - a \cdot \left(c \cdot 3\right)}}}{3 \cdot a} \]
  12. Applied egg-rr97.3%

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

    \[\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} \]
  14. Step-by-step derivation
    1. associate-*r*99.3%

      \[\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} \]
    2. *-commutative99.3%

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

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

Alternative 2: 85.1% accurate, 0.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \frac{2}{c}\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 0.496

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.496 < b

    1. Initial program 46.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - 2 \cdot \frac{1}{c}\right)}} \]
    10. Step-by-step derivation
      1. associate-*r/88.6%

        \[\leadsto \frac{1}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \color{blue}{\frac{2 \cdot 1}{c}}\right)} \]
      2. metadata-eval88.6%

        \[\leadsto \frac{1}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \frac{\color{blue}{2}}{c}\right)} \]
    11. Simplified88.6%

      \[\leadsto \frac{1}{\color{blue}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \frac{2}{c}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.8%

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

Alternative 3: 99.1% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) + \color{blue}{a \cdot \left(c \cdot 3\right)}}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot 3\right)}}}{3 \cdot a} \]
    5. associate-*r*99.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}{\left(c \cdot a\right) \cdot 3}}}}{3 \cdot a} \]
    6. *-commutative99.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}{\left(a \cdot c\right)} \cdot 3}}}{3 \cdot a} \]
    7. associate-*r*99.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(c \cdot 3\right)}}}}{3 \cdot a} \]
  10. Simplified99.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. Taylor expanded in b around 0 99.1%

    \[\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} \]
  12. Step-by-step derivation
    1. pow299.1%

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

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

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

Alternative 4: 85.1% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \frac{2}{c}\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 0.496

    1. Initial program 84.0%

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

    if 0.496 < b

    1. Initial program 46.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - 2 \cdot \frac{1}{c}\right)}} \]
    10. Step-by-step derivation
      1. associate-*r/88.6%

        \[\leadsto \frac{1}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \color{blue}{\frac{2 \cdot 1}{c}}\right)} \]
      2. metadata-eval88.6%

        \[\leadsto \frac{1}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \frac{\color{blue}{2}}{c}\right)} \]
    11. Simplified88.6%

      \[\leadsto \frac{1}{\color{blue}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \frac{2}{c}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.8%

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

Alternative 5: 82.2% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - 2 \cdot \frac{1}{c}\right)}} \]
  10. Step-by-step derivation
    1. associate-*r/83.9%

      \[\leadsto \frac{1}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \color{blue}{\frac{2 \cdot 1}{c}}\right)} \]
    2. metadata-eval83.9%

      \[\leadsto \frac{1}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \frac{\color{blue}{2}}{c}\right)} \]
  11. Simplified83.9%

    \[\leadsto \frac{1}{\color{blue}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \frac{2}{c}\right)}} \]
  12. Add Preprocessing

Alternative 6: 82.1% accurate, 5.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) + \color{blue}{a \cdot \left(c \cdot 3\right)}}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot 3\right)}}}{3 \cdot a} \]
    5. associate-*r*99.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}{\left(c \cdot a\right) \cdot 3}}}}{3 \cdot a} \]
    6. *-commutative99.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}{\left(a \cdot c\right)} \cdot 3}}}{3 \cdot a} \]
    7. associate-*r*99.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(c \cdot 3\right)}}}}{3 \cdot a} \]
  10. Simplified99.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. Taylor expanded in b around 0 99.1%

    \[\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} \]
  12. Taylor expanded in a around 0 83.7%

    \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{\color{blue}{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}}{3 \cdot a} \]
  13. Step-by-step derivation
    1. cancel-sign-sub-inv83.7%

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

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

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

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

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

    \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{\color{blue}{\left(a \cdot \frac{c}{b}\right) \cdot 1.5 + b \cdot -2}}}{3 \cdot a} \]
  15. Final simplification83.7%

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

Alternative 7: 64.5% accurate, 23.2× speedup?

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

\\
\frac{c}{b} \cdot -0.5
\end{array}
Derivation
  1. Initial program 52.3%

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

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

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

    \[\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
  5. Taylor expanded in b around inf 66.9%

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  6. Final simplification66.9%

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

Alternative 8: 3.2% accurate, 38.7× speedup?

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

\\
\frac{0}{a}
\end{array}
Derivation
  1. Initial program 52.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{b + -1 \cdot b}{a}} \]
  8. Step-by-step derivation
    1. associate-*r/3.2%

      \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(b + -1 \cdot b\right)}{a}} \]
    2. distribute-rgt1-in3.2%

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

      \[\leadsto \frac{0.3333333333333333 \cdot \left(\color{blue}{0} \cdot b\right)}{a} \]
    4. mul0-lft3.2%

      \[\leadsto \frac{0.3333333333333333 \cdot \color{blue}{0}}{a} \]
    5. metadata-eval3.2%

      \[\leadsto \frac{\color{blue}{0}}{a} \]
  9. Simplified3.2%

    \[\leadsto \color{blue}{\frac{0}{a}} \]
  10. Add Preprocessing

Reproduce

?
herbie shell --seed 2024139 
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))