Average Error: 0.0 → 0.7
Time: 3.5s
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 - \frac{2}{x}\\ \mathbf{else}:\\ \;\;\;\;x - \left(\frac{1}{1 + \frac{x \cdot y}{2}} \cdot \frac{y}{1 - \frac{x \cdot y}{2}}\right) \cdot \left(1 - \frac{x \cdot y}{2}\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 - \frac{2}{x}\\

\mathbf{else}:\\
\;\;\;\;x - \left(\frac{1}{1 + \frac{x \cdot y}{2}} \cdot \frac{y}{1 - \frac{x \cdot y}{2}}\right) \cdot \left(1 - \frac{x \cdot y}{2}\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 / x));
	} else {
		VAR = (x - (((1.0 / (1.0 + ((x * y) / 2.0))) * (y / (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}}\]
    3. Simplified1.3

      \[\leadsto \color{blue}{x - \frac{2}{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. Using strategy rm
    6. Applied difference-of-squares3.7

      \[\leadsto x - \frac{y}{\color{blue}{\left(1 + \frac{x \cdot y}{2}\right) \cdot \left(1 - \frac{x \cdot y}{2}\right)}} \cdot \left(1 - \frac{x \cdot y}{2}\right)\]
    7. Applied *-un-lft-identity3.7

      \[\leadsto x - \frac{\color{blue}{1 \cdot y}}{\left(1 + \frac{x \cdot y}{2}\right) \cdot \left(1 - \frac{x \cdot y}{2}\right)} \cdot \left(1 - \frac{x \cdot y}{2}\right)\]
    8. Applied times-frac0.1

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

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

Reproduce

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