Quadratic roots, narrow range

Percentage Accurate: 55.6% → 99.3%
Time: 14.2s
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: 55.6% 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.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(a \cdot c\right) \cdot -4\\ \frac{\frac{t\_0}{b + \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)))
   (/ (/ 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 (t_0 / (b + sqrt(fma(b, b, t_0)))) / (a * 2.0);
}
function code(a, b, c)
	t_0 = Float64(Float64(a * c) * -4.0)
	return Float64(Float64(t_0 / Float64(b + sqrt(fma(b, b, t_0)))) / Float64(a * 2.0))
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]}, N[(N[(t$95$0 / 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 := \left(a \cdot c\right) \cdot -4\\
\frac{\frac{t\_0}{b + \sqrt{\mathsf{fma}\left(b, b, t\_0\right)}}}{a \cdot 2}
\end{array}
\end{array}
Derivation
  1. Initial program 57.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. *-commutative57.8%

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

    \[\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. expm1-log1p-u57.7%

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(4 \cdot \left(a \cdot c\right)\right)\right)}}}{a \cdot 2} \]
    2. associate-*r*57.7%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\left(a \cdot 4\right)} \cdot c\right)\right)}}{a \cdot 2} \]
  8. Simplified57.7%

    \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(a \cdot 4\right) \cdot c\right)\right)}}}{a \cdot 2} \]
  9. Step-by-step derivation
    1. +-commutative57.7%

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

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b \cdot b - \mathsf{expm1}\left(\mathsf{log1p}\left(\left(a \cdot 4\right) \cdot c\right)\right)} \cdot \sqrt{b \cdot b - \mathsf{expm1}\left(\mathsf{log1p}\left(\left(a \cdot 4\right) \cdot c\right)\right)} - \left(-b\right) \cdot \left(-b\right)}{\sqrt{b \cdot b - \mathsf{expm1}\left(\mathsf{log1p}\left(\left(a \cdot 4\right) \cdot c\right)\right)} - \left(-b\right)}}}{a \cdot 2} \]
    3. add-sqr-sqrt58.9%

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

      \[\leadsto \frac{\frac{\left(\color{blue}{{b}^{2}} - \mathsf{expm1}\left(\mathsf{log1p}\left(\left(a \cdot 4\right) \cdot c\right)\right)\right) - \left(-b\right) \cdot \left(-b\right)}{\sqrt{b \cdot b - \mathsf{expm1}\left(\mathsf{log1p}\left(\left(a \cdot 4\right) \cdot c\right)\right)} - \left(-b\right)}}{a \cdot 2} \]
    5. expm1-log1p-u59.0%

      \[\leadsto \frac{\frac{\left({b}^{2} - \color{blue}{\left(a \cdot 4\right) \cdot c}\right) - \left(-b\right) \cdot \left(-b\right)}{\sqrt{b \cdot b - \mathsf{expm1}\left(\mathsf{log1p}\left(\left(a \cdot 4\right) \cdot c\right)\right)} - \left(-b\right)}}{a \cdot 2} \]
    6. associate-*l*59.0%

      \[\leadsto \frac{\frac{\left({b}^{2} - \color{blue}{a \cdot \left(4 \cdot c\right)}\right) - \left(-b\right) \cdot \left(-b\right)}{\sqrt{b \cdot b - \mathsf{expm1}\left(\mathsf{log1p}\left(\left(a \cdot 4\right) \cdot c\right)\right)} - \left(-b\right)}}{a \cdot 2} \]
    7. sqr-neg59.0%

      \[\leadsto \frac{\frac{\left({b}^{2} - a \cdot \left(4 \cdot c\right)\right) - \color{blue}{b \cdot b}}{\sqrt{b \cdot b - \mathsf{expm1}\left(\mathsf{log1p}\left(\left(a \cdot 4\right) \cdot c\right)\right)} - \left(-b\right)}}{a \cdot 2} \]
    8. pow259.0%

      \[\leadsto \frac{\frac{\left({b}^{2} - a \cdot \left(4 \cdot c\right)\right) - \color{blue}{{b}^{2}}}{\sqrt{b \cdot b - \mathsf{expm1}\left(\mathsf{log1p}\left(\left(a \cdot 4\right) \cdot c\right)\right)} - \left(-b\right)}}{a \cdot 2} \]
    9. add-sqr-sqrt0.0%

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

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

      \[\leadsto \frac{\frac{\left({b}^{2} - a \cdot \left(4 \cdot c\right)\right) - {b}^{2}}{\sqrt{b \cdot b - \mathsf{expm1}\left(\mathsf{log1p}\left(\left(a \cdot 4\right) \cdot c\right)\right)} - \sqrt{\color{blue}{b \cdot b}}}}{a \cdot 2} \]
    12. sqrt-prod1.6%

      \[\leadsto \frac{\frac{\left({b}^{2} - a \cdot \left(4 \cdot c\right)\right) - {b}^{2}}{\sqrt{b \cdot b - \mathsf{expm1}\left(\mathsf{log1p}\left(\left(a \cdot 4\right) \cdot c\right)\right)} - \color{blue}{\sqrt{b} \cdot \sqrt{b}}}}{a \cdot 2} \]
    13. add-sqr-sqrt1.4%

      \[\leadsto \frac{\frac{\left({b}^{2} - a \cdot \left(4 \cdot c\right)\right) - {b}^{2}}{\sqrt{b \cdot b - \mathsf{expm1}\left(\mathsf{log1p}\left(\left(a \cdot 4\right) \cdot c\right)\right)} - \color{blue}{b}}}{a \cdot 2} \]
    14. unsub-neg1.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 84.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 81.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. *-commutative81.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot \color{blue}{-4}\right)\right)} - b}{a \cdot 2} \]
    3. Simplified81.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 90 < b

    1. Initial program 47.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. *-commutative47.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified47.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 a around 0 89.2%

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

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

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

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

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

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

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

Alternative 3: 84.6% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 81.2%

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

    if 90 < b

    1. Initial program 47.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. *-commutative47.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified47.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 a around 0 89.2%

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

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

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

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

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

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

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

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

Alternative 4: 84.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 81.2%

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

    if 90 < b

    1. Initial program 47.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. *-commutative47.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified47.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 a around inf 47.5%

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

      \[\leadsto \frac{\color{blue}{\frac{-2 \cdot \left(a \cdot c\right) + -2 \cdot \frac{{a}^{2} \cdot {c}^{2}}{{b}^{2}}}{b}}}{a \cdot 2} \]
    7. Step-by-step derivation
      1. distribute-lft-out89.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{c \cdot \left(-1 \cdot \frac{a \cdot c}{{b}^{3}} - \frac{1}{b}\right)} \]
    10. Step-by-step derivation
      1. sub-neg89.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 81.2% accurate, 1.0× speedup?

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

\\
c \cdot \left(\frac{-1}{b} - a \cdot \frac{c}{{b}^{3}}\right)
\end{array}
Derivation
  1. Initial program 57.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. *-commutative57.8%

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

    \[\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 a around inf 57.5%

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

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

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

      \[\leadsto \frac{\color{blue}{-2 \cdot \frac{a \cdot c + \frac{{a}^{2} \cdot {c}^{2}}{{b}^{2}}}{b}}}{a \cdot 2} \]
    3. fma-define80.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto c \cdot \left(\left(-\color{blue}{a \cdot \frac{c}{{b}^{3}}}\right) + \left(-\frac{1}{b}\right)\right) \]
    4. distribute-rgt-neg-in80.5%

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

      \[\leadsto c \cdot \left(a \cdot \color{blue}{\left(-1 \cdot \frac{c}{{b}^{3}}\right)} + \left(-\frac{1}{b}\right)\right) \]
    6. distribute-neg-frac80.5%

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

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

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

      \[\leadsto c \cdot \left(\frac{-1}{b} + a \cdot \color{blue}{\left(-\frac{c}{{b}^{3}}\right)}\right) \]
    10. distribute-rgt-neg-in80.5%

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

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

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

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

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

Alternative 6: 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(c / Float64(-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 57.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. *-commutative57.8%

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

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

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

      \[\leadsto \color{blue}{\frac{-1 \cdot c}{b}} \]
    2. mul-1-neg63.1%

      \[\leadsto \frac{\color{blue}{-c}}{b} \]
  7. Simplified63.1%

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

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

Reproduce

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