Average Error: 0.0 → 0.8
Time: 5.4s
Precision: 64
\[x - \frac{y}{1 + \frac{x \cdot y}{2}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.84327720202764277 \cdot 10^{-17} \lor \neg \left(x \le 0.0897259723817682847\right):\\ \;\;\;\;x - 2 \cdot \frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \left(1 - \frac{x \cdot y}{2}\right) \cdot \frac{1}{\frac{\mathsf{fma}\left(\frac{y}{2}, x, 1\right)}{\frac{y}{1 - \frac{x \cdot y}{2}}}}\right) + \frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}} \cdot \left(\left(-\left(1 - \frac{x \cdot y}{2}\right)\right) + \left(1 - \frac{x \cdot y}{2}\right)\right)\\ \end{array}\]
x - \frac{y}{1 + \frac{x \cdot y}{2}}
\begin{array}{l}
\mathbf{if}\;x \le -2.84327720202764277 \cdot 10^{-17} \lor \neg \left(x \le 0.0897259723817682847\right):\\
\;\;\;\;x - 2 \cdot \frac{1}{x}\\

\mathbf{else}:\\
\;\;\;\;\left(x - \left(1 - \frac{x \cdot y}{2}\right) \cdot \frac{1}{\frac{\mathsf{fma}\left(\frac{y}{2}, x, 1\right)}{\frac{y}{1 - \frac{x \cdot y}{2}}}}\right) + \frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}} \cdot \left(\left(-\left(1 - \frac{x \cdot y}{2}\right)\right) + \left(1 - \frac{x \cdot y}{2}\right)\right)\\

\end{array}
double code(double x, double y) {
	return (x - (y / (1.0 + ((x * y) / 2.0))));
}
double code(double x, double y) {
	double VAR;
	if (((x <= -2.843277202027643e-17) || !(x <= 0.08972597238176828))) {
		VAR = (x - (2.0 * (1.0 / x)));
	} else {
		VAR = ((x - ((1.0 - ((x * y) / 2.0)) * (1.0 / (fma((y / 2.0), x, 1.0) / (y / (1.0 - ((x * y) / 2.0))))))) + ((y / ((1.0 * 1.0) - (((x * y) / 2.0) * ((x * y) / 2.0)))) * (-(1.0 - ((x * y) / 2.0)) + (1.0 - ((x * y) / 2.0)))));
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -2.843277202027643e-17 or 0.08972597238176828 < x

    1. Initial program 0.0

      \[x - \frac{y}{1 + \frac{x \cdot y}{2}}\]
    2. Taylor expanded around inf 1.3

      \[\leadsto \color{blue}{x - 2 \cdot \frac{1}{x}}\]

    if -2.843277202027643e-17 < x < 0.08972597238176828

    1. Initial program 0.1

      \[x - \frac{y}{1 + \frac{x \cdot y}{2}}\]
    2. Using strategy rm
    3. Applied flip-+3.7

      \[\leadsto x - \frac{y}{\color{blue}{\frac{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}}{1 - \frac{x \cdot y}{2}}}}\]
    4. Applied associate-/r/3.7

      \[\leadsto x - \color{blue}{\frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}} \cdot \left(1 - \frac{x \cdot y}{2}\right)}\]
    5. Applied add-sqr-sqrt33.2

      \[\leadsto \color{blue}{\sqrt{x} \cdot \sqrt{x}} - \frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}} \cdot \left(1 - \frac{x \cdot y}{2}\right)\]
    6. Applied prod-diff33.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, \sqrt{x}, -\left(1 - \frac{x \cdot y}{2}\right) \cdot \frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}}\right) + \mathsf{fma}\left(-\left(1 - \frac{x \cdot y}{2}\right), \frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}}, \left(1 - \frac{x \cdot y}{2}\right) \cdot \frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}}\right)}\]
    7. Simplified3.7

      \[\leadsto \color{blue}{\left(x - \left(1 - \frac{x \cdot y}{2}\right) \cdot \frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}}\right)} + \mathsf{fma}\left(-\left(1 - \frac{x \cdot y}{2}\right), \frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}}, \left(1 - \frac{x \cdot y}{2}\right) \cdot \frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}}\right)\]
    8. Simplified3.7

      \[\leadsto \left(x - \left(1 - \frac{x \cdot y}{2}\right) \cdot \frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}}\right) + \color{blue}{\frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}} \cdot \left(\left(-\left(1 - \frac{x \cdot y}{2}\right)\right) + \left(1 - \frac{x \cdot y}{2}\right)\right)}\]
    9. Using strategy rm
    10. Applied clear-num3.8

      \[\leadsto \left(x - \left(1 - \frac{x \cdot y}{2}\right) \cdot \color{blue}{\frac{1}{\frac{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}}{y}}}\right) + \frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}} \cdot \left(\left(-\left(1 - \frac{x \cdot y}{2}\right)\right) + \left(1 - \frac{x \cdot y}{2}\right)\right)\]
    11. Simplified0.2

      \[\leadsto \left(x - \left(1 - \frac{x \cdot y}{2}\right) \cdot \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(\frac{y}{2}, x, 1\right)}{\frac{y}{1 - \frac{x \cdot y}{2}}}}}\right) + \frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}} \cdot \left(\left(-\left(1 - \frac{x \cdot y}{2}\right)\right) + \left(1 - \frac{x \cdot y}{2}\right)\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.84327720202764277 \cdot 10^{-17} \lor \neg \left(x \le 0.0897259723817682847\right):\\ \;\;\;\;x - 2 \cdot \frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \left(1 - \frac{x \cdot y}{2}\right) \cdot \frac{1}{\frac{\mathsf{fma}\left(\frac{y}{2}, x, 1\right)}{\frac{y}{1 - \frac{x \cdot y}{2}}}}\right) + \frac{y}{1 \cdot 1 - \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}} \cdot \left(\left(-\left(1 - \frac{x \cdot y}{2}\right)\right) + \left(1 - \frac{x \cdot y}{2}\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020078 +o rules:numerics
(FPCore (x y)
  :name "Data.Number.Erf:$cinvnormcdf from erf-2.0.0.0, B"
  :precision binary64
  (- x (/ y (+ 1 (/ (* x y) 2)))))