
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
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
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
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
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\end{array}
(FPCore (x y) :precision binary64 (if (or (<= y -4.7e+14) (not (<= y 240000000.0))) (+ x (/ (- 1.0 x) y)) (fma (/ (+ x -1.0) (+ y 1.0)) y 1.0)))
double code(double x, double y) {
double tmp;
if ((y <= -4.7e+14) || !(y <= 240000000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = fma(((x + -1.0) / (y + 1.0)), y, 1.0);
}
return tmp;
}
function code(x, y) tmp = 0.0 if ((y <= -4.7e+14) || !(y <= 240000000.0)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = fma(Float64(Float64(x + -1.0) / Float64(y + 1.0)), y, 1.0); end return tmp end
code[x_, y_] := If[Or[LessEqual[y, -4.7e+14], N[Not[LessEqual[y, 240000000.0]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + -1.0), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{+14} \lor \neg \left(y \leq 240000000\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x + -1}{y + 1}, y, 1\right)\\
\end{array}
\end{array}
if y < -4.7e14 or 2.4e8 < y Initial program 31.9%
sub-neg31.9%
metadata-eval31.9%
associate--r-31.9%
neg-sub031.9%
remove-double-neg31.9%
associate-/l*50.0%
+-commutative50.0%
Simplified50.0%
Taylor expanded in y around -inf 100.0%
+-commutative100.0%
mul-1-neg100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
+-commutative100.0%
distribute-neg-in100.0%
metadata-eval100.0%
sub-neg100.0%
Simplified100.0%
if -4.7e14 < y < 2.4e8Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
associate-*l/99.9%
distribute-lft-neg-in99.9%
fma-def99.9%
*-rgt-identity99.9%
*-rgt-identity99.9%
distribute-frac-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (or (<= y -4.7e+14) (not (<= y 165000000.0))) (+ x (/ (- 1.0 x) y)) (+ 1.0 (* y (/ (+ x -1.0) (+ y 1.0))))))
double code(double x, double y) {
double tmp;
if ((y <= -4.7e+14) || !(y <= 165000000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-4.7d+14)) .or. (.not. (y <= 165000000.0d0))) then
tmp = x + ((1.0d0 - x) / y)
else
tmp = 1.0d0 + (y * ((x + (-1.0d0)) / (y + 1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -4.7e+14) || !(y <= 165000000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -4.7e+14) or not (y <= 165000000.0): tmp = x + ((1.0 - x) / y) else: tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0))) return tmp
function code(x, y) tmp = 0.0 if ((y <= -4.7e+14) || !(y <= 165000000.0)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(1.0 + Float64(y * Float64(Float64(x + -1.0) / Float64(y + 1.0)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -4.7e+14) || ~((y <= 165000000.0))) tmp = x + ((1.0 - x) / y); else tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -4.7e+14], N[Not[LessEqual[y, 165000000.0]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(y * N[(N[(x + -1.0), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{+14} \lor \neg \left(y \leq 165000000\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\
\end{array}
\end{array}
if y < -4.7e14 or 1.65e8 < y Initial program 31.9%
sub-neg31.9%
metadata-eval31.9%
associate--r-31.9%
neg-sub031.9%
remove-double-neg31.9%
associate-/l*50.0%
+-commutative50.0%
Simplified50.0%
Taylor expanded in y around -inf 100.0%
+-commutative100.0%
mul-1-neg100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
+-commutative100.0%
distribute-neg-in100.0%
metadata-eval100.0%
sub-neg100.0%
Simplified100.0%
if -4.7e14 < y < 1.65e8Initial program 99.9%
sub-neg99.9%
associate-*l/99.9%
distribute-lft-neg-in99.9%
distribute-frac-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ x (/ (- 1.0 x) y))))
(if (<= y -160.0)
t_0
(if (<= y -4e-89) (* x (/ y (+ y 1.0))) (if (<= y 0.98) (- 1.0 y) t_0)))))
double code(double x, double y) {
double t_0 = x + ((1.0 - x) / y);
double tmp;
if (y <= -160.0) {
tmp = t_0;
} else if (y <= -4e-89) {
tmp = x * (y / (y + 1.0));
} else if (y <= 0.98) {
tmp = 1.0 - y;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x + ((1.0d0 - x) / y)
if (y <= (-160.0d0)) then
tmp = t_0
else if (y <= (-4d-89)) then
tmp = x * (y / (y + 1.0d0))
else if (y <= 0.98d0) then
tmp = 1.0d0 - y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x + ((1.0 - x) / y);
double tmp;
if (y <= -160.0) {
tmp = t_0;
} else if (y <= -4e-89) {
tmp = x * (y / (y + 1.0));
} else if (y <= 0.98) {
tmp = 1.0 - y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x + ((1.0 - x) / y) tmp = 0 if y <= -160.0: tmp = t_0 elif y <= -4e-89: tmp = x * (y / (y + 1.0)) elif y <= 0.98: tmp = 1.0 - y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x + Float64(Float64(1.0 - x) / y)) tmp = 0.0 if (y <= -160.0) tmp = t_0; elseif (y <= -4e-89) tmp = Float64(x * Float64(y / Float64(y + 1.0))); elseif (y <= 0.98) tmp = Float64(1.0 - y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x + ((1.0 - x) / y); tmp = 0.0; if (y <= -160.0) tmp = t_0; elseif (y <= -4e-89) tmp = x * (y / (y + 1.0)); elseif (y <= 0.98) tmp = 1.0 - y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -160.0], t$95$0, If[LessEqual[y, -4e-89], N[(x * N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.98], N[(1.0 - y), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \frac{1 - x}{y}\\
\mathbf{if}\;y \leq -160:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -4 \cdot 10^{-89}:\\
\;\;\;\;x \cdot \frac{y}{y + 1}\\
\mathbf{elif}\;y \leq 0.98:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -160 or 0.97999999999999998 < y Initial program 33.8%
sub-neg33.8%
metadata-eval33.8%
associate--r-33.8%
neg-sub033.8%
remove-double-neg33.8%
associate-/l*51.4%
+-commutative51.4%
Simplified51.4%
Taylor expanded in y around -inf 99.5%
+-commutative99.5%
mul-1-neg99.5%
sub-neg99.5%
metadata-eval99.5%
distribute-neg-frac99.5%
+-commutative99.5%
distribute-neg-in99.5%
metadata-eval99.5%
sub-neg99.5%
Simplified99.5%
if -160 < y < -4.00000000000000015e-89Initial program 99.9%
sub-neg99.9%
associate-*l/99.9%
distribute-lft-neg-in99.9%
distribute-frac-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 76.9%
associate-*l/76.9%
Simplified76.9%
if -4.00000000000000015e-89 < y < 0.97999999999999998Initial program 100.0%
sub-neg100.0%
associate-*l/100.0%
distribute-lft-neg-in100.0%
distribute-frac-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 86.3%
neg-mul-186.3%
sub-neg86.3%
Simplified86.3%
Taylor expanded in y around 0 86.1%
neg-mul-186.1%
unsub-neg86.1%
Simplified86.1%
Final simplification92.7%
(FPCore (x y)
:precision binary64
(if (<= y -1.0)
x
(if (<= y -7.4e-90)
(* y x)
(if (<= y 0.75) (- 1.0 y) (if (<= y 2.4e+42) (/ 1.0 y) x)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= -7.4e-90) {
tmp = y * x;
} else if (y <= 0.75) {
tmp = 1.0 - y;
} else if (y <= 2.4e+42) {
tmp = 1.0 / y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.0d0)) then
tmp = x
else if (y <= (-7.4d-90)) then
tmp = y * x
else if (y <= 0.75d0) then
tmp = 1.0d0 - y
else if (y <= 2.4d+42) then
tmp = 1.0d0 / y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= -7.4e-90) {
tmp = y * x;
} else if (y <= 0.75) {
tmp = 1.0 - y;
} else if (y <= 2.4e+42) {
tmp = 1.0 / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= -7.4e-90: tmp = y * x elif y <= 0.75: tmp = 1.0 - y elif y <= 2.4e+42: tmp = 1.0 / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= -7.4e-90) tmp = Float64(y * x); elseif (y <= 0.75) tmp = Float64(1.0 - y); elseif (y <= 2.4e+42) tmp = Float64(1.0 / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x; elseif (y <= -7.4e-90) tmp = y * x; elseif (y <= 0.75) tmp = 1.0 - y; elseif (y <= 2.4e+42) tmp = 1.0 / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, -7.4e-90], N[(y * x), $MachinePrecision], If[LessEqual[y, 0.75], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 2.4e+42], N[(1.0 / y), $MachinePrecision], x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -7.4 \cdot 10^{-90}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 0.75:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+42}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 2.3999999999999999e42 < y Initial program 35.2%
sub-neg35.2%
associate-*l/53.9%
distribute-lft-neg-in53.9%
distribute-frac-neg53.9%
neg-sub053.9%
associate--r-53.9%
metadata-eval53.9%
+-commutative53.9%
+-commutative53.9%
Simplified53.9%
Taylor expanded in y around inf 76.3%
if -1 < y < -7.40000000000000035e-90Initial program 99.9%
sub-neg99.9%
associate-*l/100.0%
distribute-lft-neg-in100.0%
distribute-frac-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 75.5%
associate-*l/75.6%
Simplified75.6%
Taylor expanded in y around 0 72.8%
if -7.40000000000000035e-90 < y < 0.75Initial program 100.0%
sub-neg100.0%
associate-*l/100.0%
distribute-lft-neg-in100.0%
distribute-frac-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 86.3%
neg-mul-186.3%
sub-neg86.3%
Simplified86.3%
Taylor expanded in y around 0 86.1%
neg-mul-186.1%
unsub-neg86.1%
Simplified86.1%
if 0.75 < y < 2.3999999999999999e42Initial program 22.7%
sub-neg22.7%
metadata-eval22.7%
associate--r-22.7%
neg-sub022.7%
remove-double-neg22.7%
associate-/l*22.7%
+-commutative22.7%
Simplified22.7%
Taylor expanded in y around -inf 100.0%
+-commutative100.0%
mul-1-neg100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
+-commutative100.0%
distribute-neg-in100.0%
metadata-eval100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 72.0%
Final simplification79.7%
(FPCore (x y)
:precision binary64
(if (<= y -1.0)
(- x (/ x y))
(if (<= y -4.3e-89)
(* y x)
(if (<= y 0.75) (- 1.0 y) (if (<= y 1.28e+42) (/ 1.0 y) x)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x - (x / y);
} else if (y <= -4.3e-89) {
tmp = y * x;
} else if (y <= 0.75) {
tmp = 1.0 - y;
} else if (y <= 1.28e+42) {
tmp = 1.0 / y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.0d0)) then
tmp = x - (x / y)
else if (y <= (-4.3d-89)) then
tmp = y * x
else if (y <= 0.75d0) then
tmp = 1.0d0 - y
else if (y <= 1.28d+42) then
tmp = 1.0d0 / y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x - (x / y);
} else if (y <= -4.3e-89) {
tmp = y * x;
} else if (y <= 0.75) {
tmp = 1.0 - y;
} else if (y <= 1.28e+42) {
tmp = 1.0 / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x - (x / y) elif y <= -4.3e-89: tmp = y * x elif y <= 0.75: tmp = 1.0 - y elif y <= 1.28e+42: tmp = 1.0 / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = Float64(x - Float64(x / y)); elseif (y <= -4.3e-89) tmp = Float64(y * x); elseif (y <= 0.75) tmp = Float64(1.0 - y); elseif (y <= 1.28e+42) tmp = Float64(1.0 / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x - (x / y); elseif (y <= -4.3e-89) tmp = y * x; elseif (y <= 0.75) tmp = 1.0 - y; elseif (y <= 1.28e+42) tmp = 1.0 / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -4.3e-89], N[(y * x), $MachinePrecision], If[LessEqual[y, 0.75], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 1.28e+42], N[(1.0 / y), $MachinePrecision], x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x - \frac{x}{y}\\
\mathbf{elif}\;y \leq -4.3 \cdot 10^{-89}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 0.75:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq 1.28 \cdot 10^{+42}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1Initial program 35.9%
sub-neg35.9%
associate-*l/53.8%
distribute-lft-neg-in53.8%
distribute-frac-neg53.8%
neg-sub053.8%
associate--r-53.8%
metadata-eval53.8%
+-commutative53.8%
+-commutative53.8%
Simplified53.8%
Taylor expanded in x around inf 55.9%
associate-*l/74.0%
Simplified74.0%
Taylor expanded in y around inf 73.0%
+-commutative73.0%
mul-1-neg73.0%
unsub-neg73.0%
Simplified73.0%
if -1 < y < -4.29999999999999987e-89Initial program 99.9%
sub-neg99.9%
associate-*l/100.0%
distribute-lft-neg-in100.0%
distribute-frac-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 75.5%
associate-*l/75.6%
Simplified75.6%
Taylor expanded in y around 0 72.8%
if -4.29999999999999987e-89 < y < 0.75Initial program 100.0%
sub-neg100.0%
associate-*l/100.0%
distribute-lft-neg-in100.0%
distribute-frac-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 86.3%
neg-mul-186.3%
sub-neg86.3%
Simplified86.3%
Taylor expanded in y around 0 86.1%
neg-mul-186.1%
unsub-neg86.1%
Simplified86.1%
if 0.75 < y < 1.28000000000000004e42Initial program 22.7%
sub-neg22.7%
metadata-eval22.7%
associate--r-22.7%
neg-sub022.7%
remove-double-neg22.7%
associate-/l*22.7%
+-commutative22.7%
Simplified22.7%
Taylor expanded in y around -inf 100.0%
+-commutative100.0%
mul-1-neg100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
+-commutative100.0%
distribute-neg-in100.0%
metadata-eval100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 72.0%
if 1.28000000000000004e42 < y Initial program 34.5%
sub-neg34.5%
associate-*l/54.0%
distribute-lft-neg-in54.0%
distribute-frac-neg54.0%
neg-sub054.0%
associate--r-54.0%
metadata-eval54.0%
+-commutative54.0%
+-commutative54.0%
Simplified54.0%
Taylor expanded in y around inf 80.1%
Final simplification79.9%
(FPCore (x y) :precision binary64 (if (or (<= y -1.16e-89) (not (<= y 2e-53))) (* x (/ y (+ y 1.0))) 1.0))
double code(double x, double y) {
double tmp;
if ((y <= -1.16e-89) || !(y <= 2e-53)) {
tmp = x * (y / (y + 1.0));
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-1.16d-89)) .or. (.not. (y <= 2d-53))) then
tmp = x * (y / (y + 1.0d0))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.16e-89) || !(y <= 2e-53)) {
tmp = x * (y / (y + 1.0));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.16e-89) or not (y <= 2e-53): tmp = x * (y / (y + 1.0)) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.16e-89) || !(y <= 2e-53)) tmp = Float64(x * Float64(y / Float64(y + 1.0))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.16e-89) || ~((y <= 2e-53))) tmp = x * (y / (y + 1.0)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.16e-89], N[Not[LessEqual[y, 2e-53]], $MachinePrecision]], N[(x * N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.16 \cdot 10^{-89} \lor \neg \left(y \leq 2 \cdot 10^{-53}\right):\\
\;\;\;\;x \cdot \frac{y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.15999999999999993e-89 or 2.00000000000000006e-53 < y Initial program 43.5%
sub-neg43.5%
associate-*l/58.5%
distribute-lft-neg-in58.5%
distribute-frac-neg58.5%
neg-sub058.5%
associate--r-58.5%
metadata-eval58.5%
+-commutative58.5%
+-commutative58.5%
Simplified58.5%
Taylor expanded in x around inf 58.5%
associate-*l/73.5%
Simplified73.5%
if -1.15999999999999993e-89 < y < 2.00000000000000006e-53Initial program 100.0%
sub-neg100.0%
associate-*l/100.0%
distribute-lft-neg-in100.0%
distribute-frac-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 89.6%
Final simplification79.3%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (+ x (/ (- 1.0 x) y)) (+ 1.0 (- (* y x) y))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + ((y * x) - y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-1.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = x + ((1.0d0 - x) / y)
else
tmp = 1.0d0 + ((y * x) - y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 + ((y * x) - y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = x + ((1.0 - x) / y) else: tmp = 1.0 + ((y * x) - y) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(1.0 + Float64(Float64(y * x) - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = x + ((1.0 - x) / y); else tmp = 1.0 + ((y * x) - y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(y * x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(y \cdot x - y\right)\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 34.3%
sub-neg34.3%
metadata-eval34.3%
associate--r-34.3%
neg-sub034.3%
remove-double-neg34.3%
associate-/l*51.7%
+-commutative51.7%
Simplified51.7%
Taylor expanded in y around -inf 99.0%
+-commutative99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
distribute-neg-frac99.0%
+-commutative99.0%
distribute-neg-in99.0%
metadata-eval99.0%
sub-neg99.0%
Simplified99.0%
if -1 < y < 1Initial program 100.0%
sub-neg100.0%
metadata-eval100.0%
associate--r-100.0%
neg-sub0100.0%
remove-double-neg100.0%
associate-/l*99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 99.1%
*-commutative99.1%
/-rgt-identity99.1%
associate-/r/99.0%
div-sub99.0%
remove-double-div99.0%
associate-/r/99.1%
/-rgt-identity99.1%
*-commutative99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y -8.6e-90) (* y x) (if (<= y 0.8) (- 1.0 y) x))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= -8.6e-90) {
tmp = y * x;
} else if (y <= 0.8) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.0d0)) then
tmp = x
else if (y <= (-8.6d-90)) then
tmp = y * x
else if (y <= 0.8d0) then
tmp = 1.0d0 - y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= -8.6e-90) {
tmp = y * x;
} else if (y <= 0.8) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= -8.6e-90: tmp = y * x elif y <= 0.8: tmp = 1.0 - y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= -8.6e-90) tmp = Float64(y * x); elseif (y <= 0.8) tmp = Float64(1.0 - y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x; elseif (y <= -8.6e-90) tmp = y * x; elseif (y <= 0.8) tmp = 1.0 - y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, -8.6e-90], N[(y * x), $MachinePrecision], If[LessEqual[y, 0.8], N[(1.0 - y), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -8.6 \cdot 10^{-90}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 0.8:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.80000000000000004 < y Initial program 34.3%
sub-neg34.3%
associate-*l/51.7%
distribute-lft-neg-in51.7%
distribute-frac-neg51.7%
neg-sub051.7%
associate--r-51.7%
metadata-eval51.7%
+-commutative51.7%
+-commutative51.7%
Simplified51.7%
Taylor expanded in y around inf 72.7%
if -1 < y < -8.6000000000000004e-90Initial program 99.9%
sub-neg99.9%
associate-*l/100.0%
distribute-lft-neg-in100.0%
distribute-frac-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 75.5%
associate-*l/75.6%
Simplified75.6%
Taylor expanded in y around 0 72.8%
if -8.6000000000000004e-90 < y < 0.80000000000000004Initial program 100.0%
sub-neg100.0%
associate-*l/100.0%
distribute-lft-neg-in100.0%
distribute-frac-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 86.3%
neg-mul-186.3%
sub-neg86.3%
Simplified86.3%
Taylor expanded in y around 0 86.1%
neg-mul-186.1%
unsub-neg86.1%
Simplified86.1%
Final simplification77.9%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y -1.95e-90) (* y x) (if (<= y 3.6e+25) 1.0 x))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= -1.95e-90) {
tmp = y * x;
} else if (y <= 3.6e+25) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.0d0)) then
tmp = x
else if (y <= (-1.95d-90)) then
tmp = y * x
else if (y <= 3.6d+25) then
tmp = 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= -1.95e-90) {
tmp = y * x;
} else if (y <= 3.6e+25) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= -1.95e-90: tmp = y * x elif y <= 3.6e+25: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= -1.95e-90) tmp = Float64(y * x); elseif (y <= 3.6e+25) tmp = 1.0; else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x; elseif (y <= -1.95e-90) tmp = y * x; elseif (y <= 3.6e+25) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, -1.95e-90], N[(y * x), $MachinePrecision], If[LessEqual[y, 3.6e+25], 1.0, x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -1.95 \cdot 10^{-90}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{+25}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 3.60000000000000015e25 < y Initial program 34.7%
sub-neg34.7%
associate-*l/52.4%
distribute-lft-neg-in52.4%
distribute-frac-neg52.4%
neg-sub052.4%
associate--r-52.4%
metadata-eval52.4%
+-commutative52.4%
+-commutative52.4%
Simplified52.4%
Taylor expanded in y around inf 73.7%
if -1 < y < -1.95000000000000002e-90Initial program 99.9%
sub-neg99.9%
associate-*l/100.0%
distribute-lft-neg-in100.0%
distribute-frac-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 75.5%
associate-*l/75.6%
Simplified75.6%
Taylor expanded in y around 0 72.8%
if -1.95000000000000002e-90 < y < 3.60000000000000015e25Initial program 98.1%
sub-neg98.1%
associate-*l/98.1%
distribute-lft-neg-in98.1%
distribute-frac-neg98.1%
neg-sub098.1%
associate--r-98.1%
metadata-eval98.1%
+-commutative98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in y around 0 83.9%
Final simplification77.7%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 3.6e+25) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 3.6e+25) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.0d0)) then
tmp = x
else if (y <= 3.6d+25) then
tmp = 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 3.6e+25) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 3.6e+25: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 3.6e+25) tmp = 1.0; else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x; elseif (y <= 3.6e+25) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 3.6e+25], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{+25}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 3.60000000000000015e25 < y Initial program 34.7%
sub-neg34.7%
associate-*l/52.4%
distribute-lft-neg-in52.4%
distribute-frac-neg52.4%
neg-sub052.4%
associate--r-52.4%
metadata-eval52.4%
+-commutative52.4%
+-commutative52.4%
Simplified52.4%
Taylor expanded in y around inf 73.7%
if -1 < y < 3.60000000000000015e25Initial program 98.3%
sub-neg98.3%
associate-*l/98.4%
distribute-lft-neg-in98.4%
distribute-frac-neg98.4%
neg-sub098.4%
associate--r-98.4%
metadata-eval98.4%
+-commutative98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in y around 0 75.6%
Final simplification74.6%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 64.1%
sub-neg64.1%
associate-*l/73.6%
distribute-lft-neg-in73.6%
distribute-frac-neg73.6%
neg-sub073.6%
associate--r-73.6%
metadata-eval73.6%
+-commutative73.6%
+-commutative73.6%
Simplified73.6%
Taylor expanded in y around 0 36.9%
Final simplification36.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (/ 1.0 y) (- (/ x y) x))))
(if (< y -3693.8482788297247)
t_0
(if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) t_0))))
double code(double x, double y) {
double t_0 = (1.0 / y) - ((x / y) - x);
double tmp;
if (y < -3693.8482788297247) {
tmp = t_0;
} else if (y < 6799310503.41891) {
tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / y) - ((x / y) - x)
if (y < (-3693.8482788297247d0)) then
tmp = t_0
else if (y < 6799310503.41891d0) then
tmp = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (1.0 / y) - ((x / y) - x);
double tmp;
if (y < -3693.8482788297247) {
tmp = t_0;
} else if (y < 6799310503.41891) {
tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (1.0 / y) - ((x / y) - x) tmp = 0 if y < -3693.8482788297247: tmp = t_0 elif y < 6799310503.41891: tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(1.0 / y) - Float64(Float64(x / y) - x)) tmp = 0.0 if (y < -3693.8482788297247) tmp = t_0; elseif (y < 6799310503.41891) tmp = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (1.0 / y) - ((x / y) - x); tmp = 0.0; if (y < -3693.8482788297247) tmp = t_0; elseif (y < 6799310503.41891) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]}, If[Less[y, -3693.8482788297247], t$95$0, If[Less[y, 6799310503.41891], N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{y} - \left(\frac{x}{y} - x\right)\\
\mathbf{if}\;y < -3693.8482788297247:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y < 6799310503.41891:\\
\;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2023274
(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))))