Quadratic roots, narrow range

Percentage Accurate: 55.3% → 99.3%
Time: 13.6s
Alternatives: 7
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 7 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 55.3% 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} \\ \frac{\frac{0 \cdot \left(b + b\right) - c \cdot \left(a \cdot 4\right)}{b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)}}}{a \cdot 2} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/
  (/
   (- (* 0.0 (+ b b)) (* c (* a 4.0)))
   (+ b (sqrt (fma b b (* (* c a) -4.0)))))
  (* a 2.0)))
double code(double a, double b, double c) {
	return (((0.0 * (b + b)) - (c * (a * 4.0))) / (b + sqrt(fma(b, b, ((c * a) * -4.0))))) / (a * 2.0);
}
function code(a, b, c)
	return Float64(Float64(Float64(Float64(0.0 * Float64(b + b)) - Float64(c * Float64(a * 4.0))) / Float64(b + sqrt(fma(b, b, Float64(Float64(c * a) * -4.0))))) / Float64(a * 2.0))
end
code[a_, b_, c_] := N[(N[(N[(N[(0.0 * N[(b + b), $MachinePrecision]), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(b + N[Sqrt[N[(b * b + N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{0 \cdot \left(b + b\right) - c \cdot \left(a \cdot 4\right)}{b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)}}}{a \cdot 2}
\end{array}
Derivation
  1. Initial program 54.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. *-commutative54.6%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
  3. Simplified54.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. Step-by-step derivation
    1. add-cube-cbrt52.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 85.7% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{b}}{\frac{a}{{b}^{2}} + \frac{-1}{c}}\\


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

    1. Initial program 80.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 24 < b

    1. Initial program 44.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. *-commutative44.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(-c\right) - a \cdot \frac{{c}^{2}}{{b}^{2}}}{b}} \]
    8. Step-by-step derivation
      1. clear-num88.2%

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{b}{\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)}\right)}^{-1}} \]
    10. Taylor expanded in b around inf 88.7%

      \[\leadsto {\color{blue}{\left(b \cdot \left(\frac{a}{{b}^{2}} - \frac{1}{c}\right)\right)}}^{-1} \]
    11. Step-by-step derivation
      1. *-un-lft-identity88.7%

        \[\leadsto \color{blue}{1 \cdot {\left(b \cdot \left(\frac{a}{{b}^{2}} - \frac{1}{c}\right)\right)}^{-1}} \]
      2. unpow-188.7%

        \[\leadsto 1 \cdot \color{blue}{\frac{1}{b \cdot \left(\frac{a}{{b}^{2}} - \frac{1}{c}\right)}} \]
    12. Applied egg-rr88.7%

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{b}}{\frac{a}{{b}^{2}} - \frac{1}{c}}} \]
      3. sub-neg88.8%

        \[\leadsto \frac{\frac{1}{b}}{\color{blue}{\frac{a}{{b}^{2}} + \left(-\frac{1}{c}\right)}} \]
      4. distribute-neg-frac88.8%

        \[\leadsto \frac{\frac{1}{b}}{\frac{a}{{b}^{2}} + \color{blue}{\frac{-1}{c}}} \]
      5. metadata-eval88.8%

        \[\leadsto \frac{\frac{1}{b}}{\frac{a}{{b}^{2}} + \frac{\color{blue}{-1}}{c}} \]
    14. Simplified88.8%

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

Alternative 3: 85.6% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{b}}{\frac{a}{{b}^{2}} + \frac{-1}{c}}\\


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

    1. Initial program 81.4%

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

    if 4.79999999999999982 < b

    1. Initial program 46.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{b}{\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)}\right)}^{-1}} \]
    10. Taylor expanded in b around inf 87.8%

      \[\leadsto {\color{blue}{\left(b \cdot \left(\frac{a}{{b}^{2}} - \frac{1}{c}\right)\right)}}^{-1} \]
    11. Step-by-step derivation
      1. *-un-lft-identity87.8%

        \[\leadsto \color{blue}{1 \cdot {\left(b \cdot \left(\frac{a}{{b}^{2}} - \frac{1}{c}\right)\right)}^{-1}} \]
      2. unpow-187.8%

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

      \[\leadsto \color{blue}{1 \cdot \frac{1}{b \cdot \left(\frac{a}{{b}^{2}} - \frac{1}{c}\right)}} \]
    13. Step-by-step derivation
      1. *-lft-identity87.8%

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

        \[\leadsto \color{blue}{\frac{\frac{1}{b}}{\frac{a}{{b}^{2}} - \frac{1}{c}}} \]
      3. sub-neg87.9%

        \[\leadsto \frac{\frac{1}{b}}{\color{blue}{\frac{a}{{b}^{2}} + \left(-\frac{1}{c}\right)}} \]
      4. distribute-neg-frac87.9%

        \[\leadsto \frac{\frac{1}{b}}{\frac{a}{{b}^{2}} + \color{blue}{\frac{-1}{c}}} \]
      5. metadata-eval87.9%

        \[\leadsto \frac{\frac{1}{b}}{\frac{a}{{b}^{2}} + \frac{\color{blue}{-1}}{c}} \]
    14. Simplified87.9%

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

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

Alternative 4: 82.1% accurate, 1.0× speedup?

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

\\
\frac{\frac{1}{b}}{\frac{a}{{b}^{2}} + \frac{-1}{c}}
\end{array}
Derivation
  1. Initial program 54.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. *-commutative54.6%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\left(-c\right) - a \cdot \frac{{c}^{2}}{{b}^{2}}}{b}} \]
  8. Step-by-step derivation
    1. clear-num81.1%

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

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

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

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

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

    \[\leadsto \color{blue}{{\left(\frac{b}{\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)}\right)}^{-1}} \]
  10. Taylor expanded in b around inf 81.8%

    \[\leadsto {\color{blue}{\left(b \cdot \left(\frac{a}{{b}^{2}} - \frac{1}{c}\right)\right)}}^{-1} \]
  11. Step-by-step derivation
    1. *-un-lft-identity81.8%

      \[\leadsto \color{blue}{1 \cdot {\left(b \cdot \left(\frac{a}{{b}^{2}} - \frac{1}{c}\right)\right)}^{-1}} \]
    2. unpow-181.8%

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

    \[\leadsto \color{blue}{1 \cdot \frac{1}{b \cdot \left(\frac{a}{{b}^{2}} - \frac{1}{c}\right)}} \]
  13. Step-by-step derivation
    1. *-lft-identity81.8%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{b}}{\frac{a}{{b}^{2}} - \frac{1}{c}}} \]
    3. sub-neg81.9%

      \[\leadsto \frac{\frac{1}{b}}{\color{blue}{\frac{a}{{b}^{2}} + \left(-\frac{1}{c}\right)}} \]
    4. distribute-neg-frac81.9%

      \[\leadsto \frac{\frac{1}{b}}{\frac{a}{{b}^{2}} + \color{blue}{\frac{-1}{c}}} \]
    5. metadata-eval81.9%

      \[\leadsto \frac{\frac{1}{b}}{\frac{a}{{b}^{2}} + \frac{\color{blue}{-1}}{c}} \]
  14. Simplified81.9%

    \[\leadsto \color{blue}{\frac{\frac{1}{b}}{\frac{a}{{b}^{2}} + \frac{-1}{c}}} \]
  15. Add Preprocessing

Alternative 5: 82.2% accurate, 1.1× speedup?

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

\\
{\left(\frac{a}{b} - \frac{b}{c}\right)}^{-1}
\end{array}
Derivation
  1. Initial program 54.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. *-commutative54.6%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\left(-c\right) - a \cdot \frac{{c}^{2}}{{b}^{2}}}{b}} \]
  8. Step-by-step derivation
    1. clear-num81.1%

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

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

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

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

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

    \[\leadsto \color{blue}{{\left(\frac{b}{\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)}\right)}^{-1}} \]
  10. Taylor expanded in a around 0 81.9%

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

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

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

      \[\leadsto {\color{blue}{\left(\frac{a}{b} - \frac{b}{c}\right)}}^{-1} \]
  12. Simplified81.9%

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

Alternative 6: 64.5% 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 54.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. *-commutative54.6%

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

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

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

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

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

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

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

Alternative 7: 3.2% accurate, 116.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
	return 0.0;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = 0.0d0
end function
public static double code(double a, double b, double c) {
	return 0.0;
}
def code(a, b, c):
	return 0.0
function code(a, b, c)
	return 0.0
end
function tmp = code(a, b, c)
	tmp = 0.0;
end
code[a_, b_, c_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 54.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. *-commutative54.6%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{-c}{b}} \]
  8. Step-by-step derivation
    1. div-inv64.4%

      \[\leadsto \color{blue}{\left(-c\right) \cdot \frac{1}{b}} \]
  9. Applied egg-rr64.4%

    \[\leadsto \color{blue}{\left(-c\right) \cdot \frac{1}{b}} \]
  10. Step-by-step derivation
    1. expm1-log1p-u56.1%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(-c\right) \cdot \frac{1}{b}\right)} - 1} \]
    3. distribute-lft-neg-out42.4%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{-c \cdot \frac{1}{b}}\right)} - 1 \]
    4. div-inv42.4%

      \[\leadsto e^{\mathsf{log1p}\left(-\color{blue}{\frac{c}{b}}\right)} - 1 \]
  11. Applied egg-rr42.4%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(-\frac{c}{b}\right)} - 1} \]
  12. Step-by-step derivation
    1. sub-neg42.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(-\frac{c}{b}\right)} + \left(-1\right)} \]
    2. log1p-undefine42.4%

      \[\leadsto e^{\color{blue}{\log \left(1 + \left(-\frac{c}{b}\right)\right)}} + \left(-1\right) \]
    3. rem-exp-log50.7%

      \[\leadsto \color{blue}{\left(1 + \left(-\frac{c}{b}\right)\right)} + \left(-1\right) \]
    4. unsub-neg50.7%

      \[\leadsto \color{blue}{\left(1 - \frac{c}{b}\right)} + \left(-1\right) \]
    5. metadata-eval50.7%

      \[\leadsto \left(1 - \frac{c}{b}\right) + \color{blue}{-1} \]
  13. Simplified50.7%

    \[\leadsto \color{blue}{\left(1 - \frac{c}{b}\right) + -1} \]
  14. Taylor expanded in c around 0 3.2%

    \[\leadsto \color{blue}{1} + -1 \]
  15. Final simplification3.2%

    \[\leadsto 0 \]
  16. Add Preprocessing

Reproduce

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