(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (- 1.0 x) y) (+ 1.0 y)))
(t_1 (/ y (+ 1.0 y)))
(t_2 (+ (* x t_1) (- 1.0 t_1))))
(if (<= t_0 0.9917361766273673)
t_2
(if (<= t_0 1.000018514059526)
(-
(+ (+ x (/ x (* y y))) (/ 1.0 (pow y 3.0)))
(+ (/ x (pow y 3.0)) (+ (/ 1.0 (* y y)) (/ (+ x -1.0) y))))
t_2))))double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (1.0 + y);
double t_1 = y / (1.0 + y);
double t_2 = (x * t_1) + (1.0 - t_1);
double tmp;
if (t_0 <= 0.9917361766273673) {
tmp = t_2;
} else if (t_0 <= 1.000018514059526) {
tmp = ((x + (x / (y * y))) + (1.0 / pow(y, 3.0))) - ((x / pow(y, 3.0)) + ((1.0 / (y * y)) + ((x + -1.0) / y)));
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((1.0d0 - x) * y) / (1.0d0 + y)
t_1 = y / (1.0d0 + y)
t_2 = (x * t_1) + (1.0d0 - t_1)
if (t_0 <= 0.9917361766273673d0) then
tmp = t_2
else if (t_0 <= 1.000018514059526d0) then
tmp = ((x + (x / (y * y))) + (1.0d0 / (y ** 3.0d0))) - ((x / (y ** 3.0d0)) + ((1.0d0 / (y * y)) + ((x + (-1.0d0)) / y)))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
public static double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (1.0 + y);
double t_1 = y / (1.0 + y);
double t_2 = (x * t_1) + (1.0 - t_1);
double tmp;
if (t_0 <= 0.9917361766273673) {
tmp = t_2;
} else if (t_0 <= 1.000018514059526) {
tmp = ((x + (x / (y * y))) + (1.0 / Math.pow(y, 3.0))) - ((x / Math.pow(y, 3.0)) + ((1.0 / (y * y)) + ((x + -1.0) / y)));
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
def code(x, y): t_0 = ((1.0 - x) * y) / (1.0 + y) t_1 = y / (1.0 + y) t_2 = (x * t_1) + (1.0 - t_1) tmp = 0 if t_0 <= 0.9917361766273673: tmp = t_2 elif t_0 <= 1.000018514059526: tmp = ((x + (x / (y * y))) + (1.0 / math.pow(y, 3.0))) - ((x / math.pow(y, 3.0)) + ((1.0 / (y * y)) + ((x + -1.0) / y))) else: tmp = t_2 return tmp
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function code(x, y) t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(1.0 + y)) t_1 = Float64(y / Float64(1.0 + y)) t_2 = Float64(Float64(x * t_1) + Float64(1.0 - t_1)) tmp = 0.0 if (t_0 <= 0.9917361766273673) tmp = t_2; elseif (t_0 <= 1.000018514059526) tmp = Float64(Float64(Float64(x + Float64(x / Float64(y * y))) + Float64(1.0 / (y ^ 3.0))) - Float64(Float64(x / (y ^ 3.0)) + Float64(Float64(1.0 / Float64(y * y)) + Float64(Float64(x + -1.0) / y)))); else tmp = t_2; end return tmp end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
function tmp_2 = code(x, y) t_0 = ((1.0 - x) * y) / (1.0 + y); t_1 = y / (1.0 + y); t_2 = (x * t_1) + (1.0 - t_1); tmp = 0.0; if (t_0 <= 0.9917361766273673) tmp = t_2; elseif (t_0 <= 1.000018514059526) tmp = ((x + (x / (y * y))) + (1.0 / (y ^ 3.0))) - ((x / (y ^ 3.0)) + ((1.0 / (y * y)) + ((x + -1.0) / y))); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * t$95$1), $MachinePrecision] + N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.9917361766273673], t$95$2, If[LessEqual[t$95$0, 1.000018514059526], N[(N[(N[(x + N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(x / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{1 + y}\\
t_1 := \frac{y}{1 + y}\\
t_2 := x \cdot t_1 + \left(1 - t_1\right)\\
\mathbf{if}\;t_0 \leq 0.9917361766273673:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_0 \leq 1.000018514059526:\\
\;\;\;\;\left(\left(x + \frac{x}{y \cdot y}\right) + \frac{1}{{y}^{3}}\right) - \left(\frac{x}{{y}^{3}} + \left(\frac{1}{y \cdot y} + \frac{x + -1}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}




Bits error versus x




Bits error versus y
Results
| Original | 22.1 |
|---|---|
| Target | 0.2 |
| Herbie | 0.0 |
if (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 0.99173617662736735 or 1.0000185140595259 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) Initial program 10.8
Simplified0.1
Applied fma-udef_binary640.1
Simplified0.1
Applied distribute-lft-in_binary640.1
Applied associate-+l+_binary640.0
Simplified0.0
if 0.99173617662736735 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 1.0000185140595259Initial program 58.7
Simplified58.8
Taylor expanded in y around inf 0.1
Simplified0.1
Final simplification0.0
herbie shell --seed 2022137
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
:precision binary64
:herbie-target
(if (< y -3693.8482788297247) (- (/ 1.0 y) (- (/ x y) x)) (if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) (- (/ 1.0 y) (- (/ x y) x))))
(- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))