Average Error: 0.0 → 5.3
Time: 2.6s
Precision: 64
\[x - \frac{y}{1 + \frac{x \cdot y}{2}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.52295109951887609 \cdot 10^{-17} \lor \neg \left(x \le 6.68360706888572707 \cdot 10^{-37}\right):\\ \;\;\;\;x - \frac{2}{x}\\ \mathbf{else}:\\ \;\;\;\;x - \left(\frac{y}{\left(-{\left(\frac{x \cdot y}{2}\right)}^{3} \cdot \frac{x \cdot y}{2}\right) + {1}^{4}} \cdot \left(1 \cdot 1 + \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}\right)\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.52295109951887609 \cdot 10^{-17} \lor \neg \left(x \le 6.68360706888572707 \cdot 10^{-37}\right):\\
\;\;\;\;x - \frac{2}{x}\\

\mathbf{else}:\\
\;\;\;\;x - \left(\frac{y}{\left(-{\left(\frac{x \cdot y}{2}\right)}^{3} \cdot \frac{x \cdot y}{2}\right) + {1}^{4}} \cdot \left(1 \cdot 1 + \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}\right)\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.522951099518876e-17) || !(x <= 6.683607068885727e-37))) {
		VAR = (x - (2.0 / x));
	} else {
		VAR = (x - (((y / (-(pow(((x * y) / 2.0), 3.0) * ((x * y) / 2.0)) + pow(1.0, 4.0))) * ((1.0 * 1.0) + (((x * y) / 2.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.522951099518876e-17 or 6.683607068885727e-37 < x

    1. Initial program 0.0

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

      \[\leadsto \color{blue}{x - 2 \cdot \frac{1}{x}}\]
    3. Simplified3.0

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

    if -2.522951099518876e-17 < x < 6.683607068885727e-37

    1. Initial program 0.1

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

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

      \[\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 flip--8.1

      \[\leadsto x - \frac{y}{\color{blue}{\frac{\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right) - \left(\frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}\right) \cdot \left(\frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}\right)}{1 \cdot 1 + \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}}}} \cdot \left(1 - \frac{x \cdot y}{2}\right)\]
    7. Applied associate-/r/8.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.52295109951887609 \cdot 10^{-17} \lor \neg \left(x \le 6.68360706888572707 \cdot 10^{-37}\right):\\ \;\;\;\;x - \frac{2}{x}\\ \mathbf{else}:\\ \;\;\;\;x - \left(\frac{y}{\left(-{\left(\frac{x \cdot y}{2}\right)}^{3} \cdot \frac{x \cdot y}{2}\right) + {1}^{4}} \cdot \left(1 \cdot 1 + \frac{x \cdot y}{2} \cdot \frac{x \cdot y}{2}\right)\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)))))