Quadratic roots, narrow range

Percentage Accurate: 55.7% → 99.3%
Time: 15.9s
Alternatives: 8
Speedup: 29.0×

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

\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \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.7% accurate, 1.0× speedup?

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

\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}

Alternative 1: 99.3% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \frac{\frac{-a}{\frac{\left(-b\right) - \sqrt{\frac{\mathsf{fma}\left({\left(a \cdot c\right)}^{3}, -64, {b}^{6}\right)}{\mathsf{fma}\left(a \cdot -4, c \cdot \left(c \cdot \left(a \cdot -4\right) - {b}^{2}\right), {b}^{4}\right)}}}{c \cdot -4}}}{a \cdot 2} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/
  (/
   (- a)
   (/
    (-
     (- b)
     (sqrt
      (/
       (fma (pow (* a c) 3.0) -64.0 (pow b 6.0))
       (fma (* a -4.0) (* c (- (* c (* a -4.0)) (pow b 2.0))) (pow b 4.0)))))
    (* c -4.0)))
  (* a 2.0)))
double code(double a, double b, double c) {
	return (-a / ((-b - sqrt((fma(pow((a * c), 3.0), -64.0, pow(b, 6.0)) / fma((a * -4.0), (c * ((c * (a * -4.0)) - pow(b, 2.0))), pow(b, 4.0))))) / (c * -4.0))) / (a * 2.0);
}
function code(a, b, c)
	return Float64(Float64(Float64(-a) / Float64(Float64(Float64(-b) - sqrt(Float64(fma((Float64(a * c) ^ 3.0), -64.0, (b ^ 6.0)) / fma(Float64(a * -4.0), Float64(c * Float64(Float64(c * Float64(a * -4.0)) - (b ^ 2.0))), (b ^ 4.0))))) / Float64(c * -4.0))) / Float64(a * 2.0))
end
code[a_, b_, c_] := N[(N[((-a) / N[(N[((-b) - N[Sqrt[N[(N[(N[Power[N[(a * c), $MachinePrecision], 3.0], $MachinePrecision] * -64.0 + N[Power[b, 6.0], $MachinePrecision]), $MachinePrecision] / N[(N[(a * -4.0), $MachinePrecision] * N[(c * N[(N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision] - N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(c * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{-a}{\frac{\left(-b\right) - \sqrt{\frac{\mathsf{fma}\left({\left(a \cdot c\right)}^{3}, -64, {b}^{6}\right)}{\mathsf{fma}\left(a \cdot -4, c \cdot \left(c \cdot \left(a \cdot -4\right) - {b}^{2}\right), {b}^{4}\right)}}}{c \cdot -4}}}{a \cdot 2}
\end{array}
Derivation
  1. Initial program 54.5%

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

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

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. add-cube-cbrt52.4%

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\sqrt[3]{b \cdot b} \cdot \sqrt[3]{b \cdot b}, \sqrt[3]{b \cdot b}, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)}}{a \cdot 2} \]
    5. distribute-lft-neg-in52.6%

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\sqrt[3]{{b}^{2} \cdot \color{blue}{{b}^{2}}}, \sqrt[3]{b \cdot b}, c \cdot \left(a \cdot -4\right)\right)}}{a \cdot 2} \]
    11. pow-prod-up53.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) - a \cdot \left(c \cdot -4\right)}{\left(-b\right) - \sqrt{\color{blue}{\frac{{b}^{6} + {\left(a \cdot \left(c \cdot -4\right)\right)}^{3}}{{b}^{4} + \left({\left(a \cdot \left(c \cdot -4\right)\right)}^{2} - {b}^{2} \cdot \left(a \cdot \left(c \cdot -4\right)\right)\right)}}}}}{a \cdot 2} \]
  13. Step-by-step derivation
    1. associate-*r*99.2%

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

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

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

      \[\leadsto \frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) - a \cdot \left(c \cdot -4\right)}{\left(-b\right) - \sqrt{\frac{{b}^{6} + {\left(a \cdot c\right)}^{3} \cdot -64}{{b}^{4} + \left(\color{blue}{\left(a \cdot \left(c \cdot -4\right)\right) \cdot \left(a \cdot \left(c \cdot -4\right)\right)} - {b}^{2} \cdot \left(a \cdot \left(c \cdot -4\right)\right)\right)}}}}{a \cdot 2} \]
    5. distribute-rgt-out--99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{-a}{\frac{\left(-b\right) - \sqrt{\frac{\mathsf{fma}\left({\left(a \cdot c\right)}^{3}, -64, {b}^{6}\right)}{\mathsf{fma}\left(a \cdot -4, c \cdot \left(\left(a \cdot -4\right) \cdot c - {b}^{2}\right), {b}^{4}\right)}}}{c \cdot -4}}}}{a \cdot 2} \]
  18. Final simplification99.3%

    \[\leadsto \frac{\frac{-a}{\frac{\left(-b\right) - \sqrt{\frac{\mathsf{fma}\left({\left(a \cdot c\right)}^{3}, -64, {b}^{6}\right)}{\mathsf{fma}\left(a \cdot -4, c \cdot \left(c \cdot \left(a \cdot -4\right) - {b}^{2}\right), {b}^{4}\right)}}}{c \cdot -4}}}{a \cdot 2} \]
  19. Add Preprocessing

Alternative 2: 89.4% accurate, 0.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot \left(a \cdot \left(--4\right)\right)}{\mathsf{fma}\left(-2, b, 2 \cdot \mathsf{fma}\left(c, \frac{a}{b}, {\left(a \cdot c\right)}^{2} \cdot {b}^{-3}\right)\right)}}{a \cdot 2}\\


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

    1. Initial program 84.0%

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

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b} - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a} \]
      5. fma-neg84.2%

        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b}{2 \cdot a} \]
      6. distribute-lft-neg-in84.2%

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

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

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-\color{blue}{a \cdot 4}\right)\right)} - b}{2 \cdot a} \]
      9. distribute-rgt-neg-in84.2%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \color{blue}{\left(a \cdot \left(-4\right)\right)}\right)} - b}{2 \cdot a} \]
      10. metadata-eval84.2%

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

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

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

    if 16 < b

    1. Initial program 46.5%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt44.4%

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\sqrt[3]{b \cdot b} \cdot \sqrt[3]{b \cdot b}, \sqrt[3]{b \cdot b}, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)}}{a \cdot 2} \]
      5. distribute-lft-neg-in44.6%

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\sqrt[3]{{b}^{2} \cdot \color{blue}{{b}^{2}}}, \sqrt[3]{b \cdot b}, c \cdot \left(a \cdot -4\right)\right)}}{a \cdot 2} \]
      11. pow-prod-up45.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\sqrt[3]{\color{blue}{{b}^{\left(2 + 2\right)}}}, \sqrt[3]{b \cdot b}, c \cdot \left(a \cdot -4\right)\right)}}{a \cdot 2} \]
      12. metadata-eval45.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) - a \cdot \left(c \cdot -4\right)}{\left(-b\right) - \sqrt{{b}^{2} + a \cdot \left(c \cdot -4\right)}}}}{a \cdot 2} \]
    11. Taylor expanded in b around inf 90.5%

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

        \[\leadsto \frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) - a \cdot \left(c \cdot -4\right)}{\color{blue}{\mathsf{fma}\left(-2, b, 2 \cdot \frac{a \cdot c}{b} + 2 \cdot \frac{{a}^{2} \cdot {c}^{2}}{{b}^{3}}\right)}}}{a \cdot 2} \]
      2. distribute-lft-out90.5%

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

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

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

        \[\leadsto \frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) - a \cdot \left(c \cdot -4\right)}{\mathsf{fma}\left(-2, b, 2 \cdot \left(c \cdot \frac{a}{b} + \frac{\color{blue}{\left(a \cdot a\right)} \cdot {c}^{2}}{{b}^{3}}\right)\right)}}{a \cdot 2} \]
      6. unpow290.5%

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

        \[\leadsto \frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) - a \cdot \left(c \cdot -4\right)}{\mathsf{fma}\left(-2, b, 2 \cdot \left(c \cdot \frac{a}{b} + \frac{\color{blue}{\left(a \cdot c\right) \cdot \left(a \cdot c\right)}}{{b}^{3}}\right)\right)}}{a \cdot 2} \]
      8. unpow290.5%

        \[\leadsto \frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) - a \cdot \left(c \cdot -4\right)}{\mathsf{fma}\left(-2, b, 2 \cdot \left(c \cdot \frac{a}{b} + \frac{\color{blue}{{\left(a \cdot c\right)}^{2}}}{{b}^{3}}\right)\right)}}{a \cdot 2} \]
    13. Simplified90.5%

      \[\leadsto \frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) - a \cdot \left(c \cdot -4\right)}{\color{blue}{\mathsf{fma}\left(-2, b, 2 \cdot \left(c \cdot \frac{a}{b} + \frac{{\left(a \cdot c\right)}^{2}}{{b}^{3}}\right)\right)}}}{a \cdot 2} \]
    14. Step-by-step derivation
      1. div-sub90.5%

        \[\leadsto \frac{\color{blue}{\frac{{\left(-b\right)}^{2} - {b}^{2}}{\mathsf{fma}\left(-2, b, 2 \cdot \left(c \cdot \frac{a}{b} + \frac{{\left(a \cdot c\right)}^{2}}{{b}^{3}}\right)\right)} - \frac{a \cdot \left(c \cdot -4\right)}{\mathsf{fma}\left(-2, b, 2 \cdot \left(c \cdot \frac{a}{b} + \frac{{\left(a \cdot c\right)}^{2}}{{b}^{3}}\right)\right)}}}{a \cdot 2} \]
    15. Applied egg-rr90.5%

      \[\leadsto \frac{\color{blue}{\frac{{b}^{2} - {b}^{2}}{\mathsf{fma}\left(-2, b, 2 \cdot \mathsf{fma}\left(c, \frac{a}{b}, {\left(a \cdot c\right)}^{2} \cdot {b}^{-3}\right)\right)} - \frac{a \cdot \left(c \cdot -4\right)}{\mathsf{fma}\left(-2, b, 2 \cdot \mathsf{fma}\left(c, \frac{a}{b}, {\left(a \cdot c\right)}^{2} \cdot {b}^{-3}\right)\right)}}}{a \cdot 2} \]
    16. Step-by-step derivation
      1. div-sub90.5%

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

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

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

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

        \[\leadsto \frac{-\frac{\color{blue}{-4 \cdot \left(a \cdot c\right)}}{\mathsf{fma}\left(-2, b, 2 \cdot \mathsf{fma}\left(c, \frac{a}{b}, {\left(a \cdot c\right)}^{2} \cdot {b}^{-3}\right)\right)}}{a \cdot 2} \]
      6. distribute-neg-frac90.5%

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

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

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

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

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

Alternative 3: 99.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := a \cdot \left(c \cdot -4\right)\\ \frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) - t_0}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, t_0\right)}}}{a \cdot 2} \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (* a (* c -4.0))))
   (/
    (/ (- (- (pow (- b) 2.0) (pow b 2.0)) t_0) (- (- b) (sqrt (fma b b t_0))))
    (* a 2.0))))
double code(double a, double b, double c) {
	double t_0 = a * (c * -4.0);
	return (((pow(-b, 2.0) - pow(b, 2.0)) - t_0) / (-b - sqrt(fma(b, b, t_0)))) / (a * 2.0);
}
function code(a, b, c)
	t_0 = Float64(a * Float64(c * -4.0))
	return Float64(Float64(Float64(Float64((Float64(-b) ^ 2.0) - (b ^ 2.0)) - t_0) / Float64(Float64(-b) - sqrt(fma(b, b, t_0)))) / Float64(a * 2.0))
end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[Power[(-b), 2.0], $MachinePrecision] - N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / N[((-b) - N[Sqrt[N[(b * b + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := a \cdot \left(c \cdot -4\right)\\
\frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) - t_0}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, t_0\right)}}}{a \cdot 2}
\end{array}
\end{array}
Derivation
  1. Initial program 54.5%

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

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

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. add-cube-cbrt52.4%

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\sqrt[3]{b \cdot b} \cdot \sqrt[3]{b \cdot b}, \sqrt[3]{b \cdot b}, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)}}{a \cdot 2} \]
    5. distribute-lft-neg-in52.6%

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\sqrt[3]{{b}^{2} \cdot \color{blue}{{b}^{2}}}, \sqrt[3]{b \cdot b}, c \cdot \left(a \cdot -4\right)\right)}}{a \cdot 2} \]
    11. pow-prod-up53.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) - a \cdot \left(c \cdot -4\right)}{\left(-b\right) - \sqrt{\color{blue}{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)}}}}{a \cdot 2} \]
  13. Final simplification99.2%

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

Alternative 4: 76.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \mathbf{if}\;t_0 \leq -6 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))))
   (if (<= t_0 -6e-7) t_0 (/ (- c) b))))
double code(double a, double b, double c) {
	double t_0 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
	double tmp;
	if (t_0 <= -6e-7) {
		tmp = t_0;
	} else {
		tmp = -c / 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 * 4.0d0)))) - b) / (a * 2.0d0)
    if (t_0 <= (-6d-7)) then
        tmp = t_0
    else
        tmp = -c / 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 * 4.0)))) - b) / (a * 2.0);
	double tmp;
	if (t_0 <= -6e-7) {
		tmp = t_0;
	} else {
		tmp = -c / b;
	}
	return tmp;
}
def code(a, b, c):
	t_0 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0)
	tmp = 0
	if t_0 <= -6e-7:
		tmp = t_0
	else:
		tmp = -c / b
	return tmp
function code(a, b, c)
	t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0))
	tmp = 0.0
	if (t_0 <= -6e-7)
		tmp = t_0;
	else
		tmp = Float64(Float64(-c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	t_0 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
	tmp = 0.0;
	if (t_0 <= -6e-7)
		tmp = t_0;
	else
		tmp = -c / 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 * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -6e-7], t$95$0, N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{if}\;t_0 \leq -6 \cdot 10^{-7}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{-c}{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 4 a) c)))) (*.f64 2 a)) < -5.9999999999999997e-7

    1. Initial program 74.2%

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

    if -5.9999999999999997e-7 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))

    1. Initial program 26.6%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. *-commutative26.6%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    6. Step-by-step derivation
      1. mul-1-neg86.9%

        \[\leadsto \color{blue}{-\frac{c}{b}} \]
      2. distribute-neg-frac86.9%

        \[\leadsto \color{blue}{\frac{-c}{b}} \]
    7. Simplified86.9%

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification79.5%

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

Alternative 5: 83.9% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{-c}{b} - \frac{a}{{b}^{3}} \cdot {c}^{2}\\


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

    1. Initial program 79.5%

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

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right) - \left(4 \cdot a\right) \cdot c} - b}}{2 \cdot a} \]
      4. sqr-neg79.5%

        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b} - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a} \]
      5. fma-neg79.6%

        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b}{2 \cdot a} \]
      6. distribute-lft-neg-in79.6%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-4 \cdot a\right) \cdot c}\right)} - b}{2 \cdot a} \]
      7. *-commutative79.6%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)} - b}{2 \cdot a} \]
      8. *-commutative79.6%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-\color{blue}{a \cdot 4}\right)\right)} - b}{2 \cdot a} \]
      9. distribute-rgt-neg-in79.6%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \color{blue}{\left(a \cdot \left(-4\right)\right)}\right)} - b}{2 \cdot a} \]
      10. metadata-eval79.6%

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot \color{blue}{-4}\right)\right)} - b}{2 \cdot a} \]
      11. *-commutative79.6%

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

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

    if 600 < b

    1. Initial program 40.3%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}} \]
    6. Step-by-step derivation
      1. mul-1-neg89.4%

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

        \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} - \frac{a \cdot {c}^{2}}{{b}^{3}}} \]
      3. mul-1-neg89.4%

        \[\leadsto \color{blue}{\left(-\frac{c}{b}\right)} - \frac{a \cdot {c}^{2}}{{b}^{3}} \]
      4. distribute-neg-frac89.4%

        \[\leadsto \color{blue}{\frac{-c}{b}} - \frac{a \cdot {c}^{2}}{{b}^{3}} \]
      5. associate-/l*89.4%

        \[\leadsto \frac{-c}{b} - \color{blue}{\frac{a}{\frac{{b}^{3}}{{c}^{2}}}} \]
      6. associate-/r/89.4%

        \[\leadsto \frac{-c}{b} - \color{blue}{\frac{a}{{b}^{3}} \cdot {c}^{2}} \]
    7. Simplified89.4%

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

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

Alternative 6: 83.9% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{-c}{b} - \frac{a}{{b}^{3}} \cdot {c}^{2}\\


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

    1. Initial program 79.5%

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

    if 600 < b

    1. Initial program 40.3%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}} \]
    6. Step-by-step derivation
      1. mul-1-neg89.4%

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

        \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} - \frac{a \cdot {c}^{2}}{{b}^{3}}} \]
      3. mul-1-neg89.4%

        \[\leadsto \color{blue}{\left(-\frac{c}{b}\right)} - \frac{a \cdot {c}^{2}}{{b}^{3}} \]
      4. distribute-neg-frac89.4%

        \[\leadsto \color{blue}{\frac{-c}{b}} - \frac{a \cdot {c}^{2}}{{b}^{3}} \]
      5. associate-/l*89.4%

        \[\leadsto \frac{-c}{b} - \color{blue}{\frac{a}{\frac{{b}^{3}}{{c}^{2}}}} \]
      6. associate-/r/89.4%

        \[\leadsto \frac{-c}{b} - \color{blue}{\frac{a}{{b}^{3}} \cdot {c}^{2}} \]
    7. Simplified89.4%

      \[\leadsto \color{blue}{\frac{-c}{b} - \frac{a}{{b}^{3}} \cdot {c}^{2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.8%

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

Alternative 7: 83.6% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 79.5%

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

    if 700 < b

    1. Initial program 40.3%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt38.6%

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\sqrt[3]{b \cdot b} \cdot \sqrt[3]{b \cdot b}, \sqrt[3]{b \cdot b}, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)}}{a \cdot 2} \]
      5. distribute-lft-neg-in38.6%

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\sqrt[3]{{b}^{2} \cdot \color{blue}{{b}^{2}}}, \sqrt[3]{b \cdot b}, c \cdot \left(a \cdot -4\right)\right)}}{a \cdot 2} \]
      11. pow-prod-up39.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left({\left(-b\right)}^{2} - {b}^{2}\right) - a \cdot \left(c \cdot -4\right)}{\left(-b\right) - \sqrt{{b}^{2} + a \cdot \left(c \cdot -4\right)}}}}{a \cdot 2} \]
    11. Taylor expanded in b around inf 89.2%

      \[\leadsto \frac{\color{blue}{-2 \cdot \frac{a \cdot c}{b} + -2 \cdot \frac{{a}^{2} \cdot {c}^{2}}{{b}^{3}}}}{a \cdot 2} \]
    12. Step-by-step derivation
      1. distribute-lft-out89.2%

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 64.2% accurate, 29.0× speedup?

\[\begin{array}{l} \\ \frac{-c}{b} \end{array} \]
(FPCore (a b c) :precision binary64 (/ (- c) b))
double code(double a, double b, double c) {
	return -c / b;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = -c / b
end function
public static double code(double a, double b, double c) {
	return -c / b;
}
def code(a, b, c):
	return -c / b
function code(a, b, c)
	return Float64(Float64(-c) / b)
end
function tmp = code(a, b, c)
	tmp = -c / b;
end
code[a_, b_, c_] := N[((-c) / b), $MachinePrecision]
\begin{array}{l}

\\
\frac{-c}{b}
\end{array}
Derivation
  1. Initial program 54.5%

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
  6. Step-by-step derivation
    1. mul-1-neg64.5%

      \[\leadsto \color{blue}{-\frac{c}{b}} \]
    2. distribute-neg-frac64.5%

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
  7. Simplified64.5%

    \[\leadsto \color{blue}{\frac{-c}{b}} \]
  8. Final simplification64.5%

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

Reproduce

?
herbie shell --seed 2024020 
(FPCore (a b c)
  :name "Quadratic roots, 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) (* (* 4.0 a) c)))) (* 2.0 a)))