Quadratic roots, narrow range

Percentage Accurate: 56.1% → 99.2%
Time: 11.0s
Alternatives: 6
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 6 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: 56.1% 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.2% accurate, 0.5× speedup?

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

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

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Step-by-step derivation
    1. /-rgt-identity54.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{b \cdot b + \color{blue}{\left(-4\right)} \cdot \left(a \cdot c\right)} - b\right) \cdot \frac{0.5}{a} \]
    4. cancel-sign-sub-inv54.8%

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

      \[\leadsto \left(\sqrt{b \cdot b - \color{blue}{\left(4 \cdot a\right) \cdot c}} - b\right) \cdot \frac{0.5}{a} \]
    6. add-sqr-sqrt53.4%

      \[\leadsto \left(\color{blue}{\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}} - b\right) \cdot \frac{0.5}{a} \]
    7. pow253.4%

      \[\leadsto \left(\color{blue}{{\left(\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right)}^{2}} - b\right) \cdot \frac{0.5}{a} \]
    8. pow1/253.4%

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

      \[\leadsto \left({\color{blue}{\left({\left(b \cdot b - \left(4 \cdot a\right) \cdot c\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2} - b\right) \cdot \frac{0.5}{a} \]
    10. associate-*l*53.5%

      \[\leadsto \left({\left({\left(b \cdot b - \color{blue}{4 \cdot \left(a \cdot c\right)}\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b\right) \cdot \frac{0.5}{a} \]
    11. cancel-sign-sub-inv53.5%

      \[\leadsto \left({\left({\color{blue}{\left(b \cdot b + \left(-4\right) \cdot \left(a \cdot c\right)\right)}}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b\right) \cdot \frac{0.5}{a} \]
    12. metadata-eval53.5%

      \[\leadsto \left({\left({\left(b \cdot b + \color{blue}{-4} \cdot \left(a \cdot c\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b\right) \cdot \frac{0.5}{a} \]
    13. *-commutative53.5%

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

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

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

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

    \[\leadsto \left(\color{blue}{{\left({\left(\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)\right)}^{0.25}\right)}^{2}} - b\right) \cdot \frac{0.5}{a} \]
  6. Step-by-step derivation
    1. flip--53.7%

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

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

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

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

      \[\leadsto \frac{{\left(\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)\right)}^{0.5} \cdot {\left(\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)\right)}^{\color{blue}{0.5}} - b \cdot b}{{\left({\left(\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)\right)}^{0.25}\right)}^{2} + b} \cdot \frac{0.5}{a} \]
    6. pow-pow54.8%

      \[\leadsto \frac{{\left(\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)\right)}^{0.5} \cdot {\left(\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)\right)}^{0.5} - b \cdot b}{\color{blue}{{\left(\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)\right)}^{\left(0.25 \cdot 2\right)}} + b} \cdot \frac{0.5}{a} \]
    7. metadata-eval54.8%

      \[\leadsto \frac{{\left(\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)\right)}^{0.5} \cdot {\left(\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)\right)}^{0.5} - b \cdot b}{{\left(\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)\right)}^{\color{blue}{0.5}} + b} \cdot \frac{0.5}{a} \]
  7. Applied egg-rr54.8%

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

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(b, b, \color{blue}{\left(c \cdot a\right)} \cdot -4\right) - b \cdot b}{{\left(\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)\right)}^{0.5} + b} \cdot \frac{0.5}{a} \]
    6. +-commutative56.0%

      \[\leadsto \frac{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right) - b \cdot b}{\color{blue}{b + {\left(\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)\right)}^{0.5}}} \cdot \frac{0.5}{a} \]
    7. unpow1/256.0%

      \[\leadsto \frac{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right) - b \cdot b}{b + \color{blue}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)}}} \cdot \frac{0.5}{a} \]
    8. associate-*r*56.0%

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

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right) - b \cdot b}{b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)}}} \cdot \frac{0.5}{a} \]
  10. Taylor expanded in b around 0 99.4%

    \[\leadsto \frac{\color{blue}{-4 \cdot \left(c \cdot a\right)}}{b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)}} \cdot \frac{0.5}{a} \]
  11. Step-by-step derivation
    1. *-commutative99.4%

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

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

    \[\leadsto \frac{\left(c \cdot a\right) \cdot -4}{b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)}} \cdot \frac{0.5}{a} \]

Alternative 2: 84.9% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 78.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. /-rgt-identity78.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 13.5999999999999996 < b

    1. Initial program 48.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + -1 \cdot \frac{c}{b}} \]
    5. Step-by-step derivation
      1. +-commutative87.7%

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

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

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

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

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

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

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

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

Alternative 3: 84.8% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 78.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. /-rgt-identity78.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{b \cdot b + \color{blue}{\left(-4\right)} \cdot \left(a \cdot c\right)} - b\right) \cdot \frac{0.5}{a} \]
      4. cancel-sign-sub-inv78.8%

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

        \[\leadsto \left(\sqrt{b \cdot b - \color{blue}{\left(4 \cdot a\right) \cdot c}} - b\right) \cdot \frac{0.5}{a} \]
      6. *-un-lft-identity78.8%

        \[\leadsto \left(\sqrt{b \cdot b - \color{blue}{1 \cdot \left(\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{0.5}{a} \]
      7. prod-diff79.1%

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(\left(4 \cdot a\right) \cdot c\right) \cdot 1\right) + \mathsf{fma}\left(-\left(4 \cdot a\right) \cdot c, 1, \left(\left(4 \cdot a\right) \cdot c\right) \cdot 1\right)}} - b\right) \cdot \frac{0.5}{a} \]
    5. Applied egg-rr79.0%

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

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

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

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

        \[\leadsto \left(\sqrt{\left(a \cdot \left(c \cdot -4\right) + \color{blue}{a \cdot \left(c \cdot -4\right)}\right) + \mathsf{fma}\left(b, b, -\left(a \cdot \left(c \cdot -4\right)\right) \cdot 1\right)} - b\right) \cdot \frac{0.5}{a} \]
      5. count-279.0%

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

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

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

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

    if 13.5999999999999996 < b

    1. Initial program 48.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + -1 \cdot \frac{c}{b}} \]
    5. Step-by-step derivation
      1. +-commutative87.7%

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

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

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

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

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

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

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

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

Alternative 4: 84.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 78.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. /-rgt-identity78.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{b \cdot b + \color{blue}{\left(-4\right)} \cdot \left(a \cdot c\right)} - b\right) \cdot \frac{0.5}{a} \]
      4. cancel-sign-sub-inv78.8%

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

        \[\leadsto \left(\sqrt{b \cdot b - \color{blue}{\left(4 \cdot a\right) \cdot c}} - b\right) \cdot \frac{0.5}{a} \]
      6. *-un-lft-identity78.8%

        \[\leadsto \left(\sqrt{b \cdot b - \color{blue}{1 \cdot \left(\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{0.5}{a} \]
      7. prod-diff79.1%

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(\left(4 \cdot a\right) \cdot c\right) \cdot 1\right) + \mathsf{fma}\left(-\left(4 \cdot a\right) \cdot c, 1, \left(\left(4 \cdot a\right) \cdot c\right) \cdot 1\right)}} - b\right) \cdot \frac{0.5}{a} \]
    5. Applied egg-rr79.0%

      \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(a \cdot \left(c \cdot -4\right)\right) \cdot 1\right) + \mathsf{fma}\left(a \cdot \left(c \cdot -4\right), 1, \left(a \cdot \left(c \cdot -4\right)\right) \cdot 1\right)}} - b\right) \cdot \frac{0.5}{a} \]
    6. Step-by-step derivation
      1. *-rgt-identity79.0%

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

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

        \[\leadsto \left(\sqrt{\left(b \cdot b - a \cdot \left(c \cdot -4\right)\right) + \color{blue}{\left(\left(a \cdot \left(c \cdot -4\right)\right) \cdot 1 + \left(a \cdot \left(c \cdot -4\right)\right) \cdot 1\right)}} - b\right) \cdot \frac{0.5}{a} \]
      4. *-rgt-identity79.1%

        \[\leadsto \left(\sqrt{\left(b \cdot b - a \cdot \left(c \cdot -4\right)\right) + \left(\color{blue}{a \cdot \left(c \cdot -4\right)} + \left(a \cdot \left(c \cdot -4\right)\right) \cdot 1\right)} - b\right) \cdot \frac{0.5}{a} \]
      5. *-rgt-identity79.1%

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

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

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

        \[\leadsto \left(\sqrt{b \cdot b - \left(\color{blue}{0} - a \cdot \left(c \cdot -4\right)\right)} - b\right) \cdot \frac{0.5}{a} \]
      9. neg-sub078.8%

        \[\leadsto \left(\sqrt{b \cdot b - \color{blue}{\left(-a \cdot \left(c \cdot -4\right)\right)}} - b\right) \cdot \frac{0.5}{a} \]
      10. *-commutative78.8%

        \[\leadsto \left(\sqrt{b \cdot b - \left(-\color{blue}{\left(c \cdot -4\right) \cdot a}\right)} - b\right) \cdot \frac{0.5}{a} \]
      11. *-commutative78.8%

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

        \[\leadsto \left(\sqrt{b \cdot b - \left(-\color{blue}{-4 \cdot \left(c \cdot a\right)}\right)} - b\right) \cdot \frac{0.5}{a} \]
      13. *-commutative78.8%

        \[\leadsto \left(\sqrt{b \cdot b - \left(--4 \cdot \color{blue}{\left(a \cdot c\right)}\right)} - b\right) \cdot \frac{0.5}{a} \]
      14. distribute-lft-neg-in78.8%

        \[\leadsto \left(\sqrt{b \cdot b - \color{blue}{\left(--4\right) \cdot \left(a \cdot c\right)}} - b\right) \cdot \frac{0.5}{a} \]
      15. metadata-eval78.8%

        \[\leadsto \left(\sqrt{b \cdot b - \color{blue}{4} \cdot \left(a \cdot c\right)} - b\right) \cdot \frac{0.5}{a} \]
      16. *-commutative78.8%

        \[\leadsto \left(\sqrt{b \cdot b - 4 \cdot \color{blue}{\left(c \cdot a\right)}} - b\right) \cdot \frac{0.5}{a} \]
    7. Simplified78.8%

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

    if 14.5 < b

    1. Initial program 48.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + -1 \cdot \frac{c}{b}} \]
    5. Step-by-step derivation
      1. +-commutative87.7%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 14.5:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b} - \frac{c \cdot c}{\frac{{b}^{3}}{a}}\\ \end{array} \]

Alternative 5: 81.0% accurate, 1.0× speedup?

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

\\
\frac{-c}{b} - \frac{c \cdot c}{\frac{{b}^{3}}{a}}
\end{array}
Derivation
  1. Initial program 54.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Step-by-step derivation
    1. /-rgt-identity54.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{-c}{b} - \frac{c \cdot c}{\frac{{b}^{3}}{a}} \]

Alternative 6: 63.8% 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.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Step-by-step derivation
    1. /-rgt-identity54.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-\frac{c}{b}} \]
  6. Simplified65.2%

    \[\leadsto \color{blue}{-\frac{c}{b}} \]
  7. Final simplification65.2%

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

Reproduce

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