?

Average Accuracy: 99.9% → 99.9%
Time: 5.9s
Precision: binary64
Cost: 704

?

\[x - \frac{y}{1 + \frac{x \cdot y}{2}} \]
\[x + \frac{-1}{\frac{1}{y} + x \cdot 0.5} \]
(FPCore (x y) :precision binary64 (- x (/ y (+ 1.0 (/ (* x y) 2.0)))))
(FPCore (x y) :precision binary64 (+ x (/ -1.0 (+ (/ 1.0 y) (* x 0.5)))))
double code(double x, double y) {
	return x - (y / (1.0 + ((x * y) / 2.0)));
}
double code(double x, double y) {
	return x + (-1.0 / ((1.0 / y) + (x * 0.5)));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x - (y / (1.0d0 + ((x * y) / 2.0d0)))
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x + ((-1.0d0) / ((1.0d0 / y) + (x * 0.5d0)))
end function
public static double code(double x, double y) {
	return x - (y / (1.0 + ((x * y) / 2.0)));
}
public static double code(double x, double y) {
	return x + (-1.0 / ((1.0 / y) + (x * 0.5)));
}
def code(x, y):
	return x - (y / (1.0 + ((x * y) / 2.0)))
def code(x, y):
	return x + (-1.0 / ((1.0 / y) + (x * 0.5)))
function code(x, y)
	return Float64(x - Float64(y / Float64(1.0 + Float64(Float64(x * y) / 2.0))))
end
function code(x, y)
	return Float64(x + Float64(-1.0 / Float64(Float64(1.0 / y) + Float64(x * 0.5))))
end
function tmp = code(x, y)
	tmp = x - (y / (1.0 + ((x * y) / 2.0)));
end
function tmp = code(x, y)
	tmp = x + (-1.0 / ((1.0 / y) + (x * 0.5)));
end
code[x_, y_] := N[(x - N[(y / N[(1.0 + N[(N[(x * y), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(x + N[(-1.0 / N[(N[(1.0 / y), $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x - \frac{y}{1 + \frac{x \cdot y}{2}}
x + \frac{-1}{\frac{1}{y} + x \cdot 0.5}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 99.9%

    \[x - \frac{y}{1 + \frac{x \cdot y}{2}} \]
  2. Applied egg-rr99.9%

    \[\leadsto x - \color{blue}{{\left(\frac{\mathsf{fma}\left(y, x \cdot 0.5, 1\right)}{y}\right)}^{-1}} \]
    Proof

    [Start]99.9

    \[ x - \frac{y}{1 + \frac{x \cdot y}{2}} \]

    clear-num [=>]99.9

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

    inv-pow [=>]99.9

    \[ x - \color{blue}{{\left(\frac{1 + \frac{x \cdot y}{2}}{y}\right)}^{-1}} \]

    *-un-lft-identity [=>]99.9

    \[ x - {\left(\frac{\color{blue}{1 \cdot \left(1 + \frac{x \cdot y}{2}\right)}}{y}\right)}^{-1} \]

    *-un-lft-identity [<=]99.9

    \[ x - {\left(\frac{\color{blue}{1 + \frac{x \cdot y}{2}}}{y}\right)}^{-1} \]

    +-commutative [=>]99.9

    \[ x - {\left(\frac{\color{blue}{\frac{x \cdot y}{2} + 1}}{y}\right)}^{-1} \]

    div-inv [=>]99.9

    \[ x - {\left(\frac{\color{blue}{\left(x \cdot y\right) \cdot \frac{1}{2}} + 1}{y}\right)}^{-1} \]

    *-commutative [=>]99.9

    \[ x - {\left(\frac{\color{blue}{\left(y \cdot x\right)} \cdot \frac{1}{2} + 1}{y}\right)}^{-1} \]

    associate-*l* [=>]99.9

    \[ x - {\left(\frac{\color{blue}{y \cdot \left(x \cdot \frac{1}{2}\right)} + 1}{y}\right)}^{-1} \]

    fma-def [=>]99.9

    \[ x - {\left(\frac{\color{blue}{\mathsf{fma}\left(y, x \cdot \frac{1}{2}, 1\right)}}{y}\right)}^{-1} \]

    metadata-eval [=>]99.9

    \[ x - {\left(\frac{\mathsf{fma}\left(y, x \cdot \color{blue}{0.5}, 1\right)}{y}\right)}^{-1} \]
  3. Taylor expanded in y around 0 99.9%

    \[\leadsto x - {\color{blue}{\left(\frac{1}{y} + 0.5 \cdot x\right)}}^{-1} \]
  4. Applied egg-rr99.9%

    \[\leadsto x - \color{blue}{\left(0 + \frac{1}{\mathsf{fma}\left(0.5, x, \frac{1}{y}\right)}\right)} \]
    Proof

    [Start]99.9

    \[ x - {\left(\frac{1}{y} + 0.5 \cdot x\right)}^{-1} \]

    add-log-exp [=>]63.7

    \[ x - \color{blue}{\log \left(e^{{\left(\frac{1}{y} + 0.5 \cdot x\right)}^{-1}}\right)} \]

    *-un-lft-identity [=>]63.7

    \[ x - \log \color{blue}{\left(1 \cdot e^{{\left(\frac{1}{y} + 0.5 \cdot x\right)}^{-1}}\right)} \]

    log-prod [=>]63.7

    \[ x - \color{blue}{\left(\log 1 + \log \left(e^{{\left(\frac{1}{y} + 0.5 \cdot x\right)}^{-1}}\right)\right)} \]

    metadata-eval [=>]63.7

    \[ x - \left(\color{blue}{0} + \log \left(e^{{\left(\frac{1}{y} + 0.5 \cdot x\right)}^{-1}}\right)\right) \]

    add-log-exp [<=]99.9

    \[ x - \left(0 + \color{blue}{{\left(\frac{1}{y} + 0.5 \cdot x\right)}^{-1}}\right) \]

    unpow-1 [=>]99.9

    \[ x - \left(0 + \color{blue}{\frac{1}{\frac{1}{y} + 0.5 \cdot x}}\right) \]

    +-commutative [=>]99.9

    \[ x - \left(0 + \frac{1}{\color{blue}{0.5 \cdot x + \frac{1}{y}}}\right) \]

    fma-def [=>]99.9

    \[ x - \left(0 + \frac{1}{\color{blue}{\mathsf{fma}\left(0.5, x, \frac{1}{y}\right)}}\right) \]
  5. Simplified99.9%

    \[\leadsto x - \color{blue}{\frac{1}{\mathsf{fma}\left(x, 0.5, \frac{1}{y}\right)}} \]
    Proof

    [Start]99.9

    \[ x - \left(0 + \frac{1}{\mathsf{fma}\left(0.5, x, \frac{1}{y}\right)}\right) \]

    +-lft-identity [=>]99.9

    \[ x - \color{blue}{\frac{1}{\mathsf{fma}\left(0.5, x, \frac{1}{y}\right)}} \]

    fma-udef [=>]99.9

    \[ x - \frac{1}{\color{blue}{0.5 \cdot x + \frac{1}{y}}} \]

    *-commutative [=>]99.9

    \[ x - \frac{1}{\color{blue}{x \cdot 0.5} + \frac{1}{y}} \]

    fma-udef [<=]99.9

    \[ x - \frac{1}{\color{blue}{\mathsf{fma}\left(x, 0.5, \frac{1}{y}\right)}} \]
  6. Applied egg-rr99.9%

    \[\leadsto x - \frac{1}{\color{blue}{\frac{1}{y} + x \cdot 0.5}} \]
    Proof

    [Start]99.9

    \[ x - \frac{1}{\mathsf{fma}\left(x, 0.5, \frac{1}{y}\right)} \]

    fma-udef [=>]99.9

    \[ x - \frac{1}{\color{blue}{x \cdot 0.5 + \frac{1}{y}}} \]

    +-commutative [=>]99.9

    \[ x - \frac{1}{\color{blue}{\frac{1}{y} + x \cdot 0.5}} \]
  7. Final simplification99.9%

    \[\leadsto x + \frac{-1}{\frac{1}{y} + x \cdot 0.5} \]

Alternatives

Alternative 1
Accuracy89.8%
Cost708
\[\begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{+84}:\\ \;\;\;\;x + \frac{y \cdot \frac{-2}{y}}{x}\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+25}:\\ \;\;\;\;x - y\\ \mathbf{else}:\\ \;\;\;\;x + \frac{-2}{x}\\ \end{array} \]
Alternative 2
Accuracy89.8%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{+83} \lor \neg \left(y \leq 3.7 \cdot 10^{+25}\right):\\ \;\;\;\;x + \frac{-2}{x}\\ \mathbf{else}:\\ \;\;\;\;x - y\\ \end{array} \]
Alternative 3
Accuracy74.7%
Cost192
\[x - y \]

Error

Reproduce?

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