
(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
(let* ((t_0 (/ (- 1.0 x) y)))
(if (<= y -250000.0)
(+ (+ x (/ (+ x -1.0) (pow y 2.0))) t_0)
(if (<= y 245000000.0) (fma (/ (+ x -1.0) (+ y 1.0)) y 1.0) (+ x t_0)))))
double code(double x, double y) {
double t_0 = (1.0 - x) / y;
double tmp;
if (y <= -250000.0) {
tmp = (x + ((x + -1.0) / pow(y, 2.0))) + t_0;
} else if (y <= 245000000.0) {
tmp = fma(((x + -1.0) / (y + 1.0)), y, 1.0);
} else {
tmp = x + t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(1.0 - x) / y) tmp = 0.0 if (y <= -250000.0) tmp = Float64(Float64(x + Float64(Float64(x + -1.0) / (y ^ 2.0))) + t_0); elseif (y <= 245000000.0) tmp = fma(Float64(Float64(x + -1.0) / Float64(y + 1.0)), y, 1.0); else tmp = Float64(x + t_0); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, -250000.0], N[(N[(x + N[(N[(x + -1.0), $MachinePrecision] / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[y, 245000000.0], N[(N[(N[(x + -1.0), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision], N[(x + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 - x}{y}\\
\mathbf{if}\;y \leq -250000:\\
\;\;\;\;\left(x + \frac{x + -1}{{y}^{2}}\right) + t_0\\
\mathbf{elif}\;y \leq 245000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{x + -1}{y + 1}, y, 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + t_0\\
\end{array}
\end{array}
if y < -2.5e5Initial program 36.0%
associate-*l/56.4%
+-commutative56.4%
Simplified56.4%
Taylor expanded in y around inf 100.0%
associate-+r+100.0%
neg-mul-1100.0%
sub-neg100.0%
associate--l+100.0%
mul-1-neg100.0%
unsub-neg100.0%
div-sub100.0%
Simplified100.0%
if -2.5e5 < y < 2.45e8Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
associate-*l/100.0%
distribute-lft-neg-in100.0%
fma-def100.0%
distribute-frac-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
if 2.45e8 < y Initial program 31.6%
associate-*l/48.3%
+-commutative48.3%
Simplified48.3%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
div-sub100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (or (<= y -130000000.0) (not (<= y 165000000.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 <= -130000000.0) || !(y <= 165000000.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 <= -130000000.0) || !(y <= 165000000.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, -130000000.0], N[Not[LessEqual[y, 165000000.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 -130000000 \lor \neg \left(y \leq 165000000\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 < -1.3e8 or 1.65e8 < y Initial program 33.7%
associate-*l/52.1%
+-commutative52.1%
Simplified52.1%
Taylor expanded in y around inf 99.9%
associate--l+99.9%
div-sub99.9%
Simplified99.9%
if -1.3e8 < y < 1.65e8Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
associate-*l/100.0%
distribute-lft-neg-in100.0%
fma-def100.0%
distribute-frac-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= y -4.2e+132)
x
(if (<= y -2.15e+30)
(/ 1.0 y)
(if (<= y -6500000000000.0)
x
(if (<= y -1.32e-46)
(- 1.0 y)
(if (<= y -1.55e-115)
(* y x)
(if (<= y 3.65e-127)
1.0
(if (<= y 5.8e-92)
(* y x)
(if (<= y 0.75)
(- 1.0 y)
(if (<= y 1.2e+68) (/ 1.0 y) x))))))))))
double code(double x, double y) {
double tmp;
if (y <= -4.2e+132) {
tmp = x;
} else if (y <= -2.15e+30) {
tmp = 1.0 / y;
} else if (y <= -6500000000000.0) {
tmp = x;
} else if (y <= -1.32e-46) {
tmp = 1.0 - y;
} else if (y <= -1.55e-115) {
tmp = y * x;
} else if (y <= 3.65e-127) {
tmp = 1.0;
} else if (y <= 5.8e-92) {
tmp = y * x;
} else if (y <= 0.75) {
tmp = 1.0 - y;
} else if (y <= 1.2e+68) {
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 <= (-4.2d+132)) then
tmp = x
else if (y <= (-2.15d+30)) then
tmp = 1.0d0 / y
else if (y <= (-6500000000000.0d0)) then
tmp = x
else if (y <= (-1.32d-46)) then
tmp = 1.0d0 - y
else if (y <= (-1.55d-115)) then
tmp = y * x
else if (y <= 3.65d-127) then
tmp = 1.0d0
else if (y <= 5.8d-92) then
tmp = y * x
else if (y <= 0.75d0) then
tmp = 1.0d0 - y
else if (y <= 1.2d+68) 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 <= -4.2e+132) {
tmp = x;
} else if (y <= -2.15e+30) {
tmp = 1.0 / y;
} else if (y <= -6500000000000.0) {
tmp = x;
} else if (y <= -1.32e-46) {
tmp = 1.0 - y;
} else if (y <= -1.55e-115) {
tmp = y * x;
} else if (y <= 3.65e-127) {
tmp = 1.0;
} else if (y <= 5.8e-92) {
tmp = y * x;
} else if (y <= 0.75) {
tmp = 1.0 - y;
} else if (y <= 1.2e+68) {
tmp = 1.0 / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.2e+132: tmp = x elif y <= -2.15e+30: tmp = 1.0 / y elif y <= -6500000000000.0: tmp = x elif y <= -1.32e-46: tmp = 1.0 - y elif y <= -1.55e-115: tmp = y * x elif y <= 3.65e-127: tmp = 1.0 elif y <= 5.8e-92: tmp = y * x elif y <= 0.75: tmp = 1.0 - y elif y <= 1.2e+68: tmp = 1.0 / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -4.2e+132) tmp = x; elseif (y <= -2.15e+30) tmp = Float64(1.0 / y); elseif (y <= -6500000000000.0) tmp = x; elseif (y <= -1.32e-46) tmp = Float64(1.0 - y); elseif (y <= -1.55e-115) tmp = Float64(y * x); elseif (y <= 3.65e-127) tmp = 1.0; elseif (y <= 5.8e-92) tmp = Float64(y * x); elseif (y <= 0.75) tmp = Float64(1.0 - y); elseif (y <= 1.2e+68) tmp = Float64(1.0 / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4.2e+132) tmp = x; elseif (y <= -2.15e+30) tmp = 1.0 / y; elseif (y <= -6500000000000.0) tmp = x; elseif (y <= -1.32e-46) tmp = 1.0 - y; elseif (y <= -1.55e-115) tmp = y * x; elseif (y <= 3.65e-127) tmp = 1.0; elseif (y <= 5.8e-92) tmp = y * x; elseif (y <= 0.75) tmp = 1.0 - y; elseif (y <= 1.2e+68) tmp = 1.0 / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4.2e+132], x, If[LessEqual[y, -2.15e+30], N[(1.0 / y), $MachinePrecision], If[LessEqual[y, -6500000000000.0], x, If[LessEqual[y, -1.32e-46], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, -1.55e-115], N[(y * x), $MachinePrecision], If[LessEqual[y, 3.65e-127], 1.0, If[LessEqual[y, 5.8e-92], N[(y * x), $MachinePrecision], If[LessEqual[y, 0.75], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 1.2e+68], N[(1.0 / y), $MachinePrecision], x]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+132}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -2.15 \cdot 10^{+30}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{elif}\;y \leq -6500000000000:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -1.32 \cdot 10^{-46}:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq -1.55 \cdot 10^{-115}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 3.65 \cdot 10^{-127}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{-92}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 0.75:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+68}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -4.19999999999999987e132 or -2.15e30 < y < -6.5e12 or 1.20000000000000004e68 < y Initial program 35.1%
associate-*l/59.1%
+-commutative59.1%
Simplified59.1%
Taylor expanded in y around inf 84.4%
if -4.19999999999999987e132 < y < -2.15e30 or 0.75 < y < 1.20000000000000004e68Initial program 31.7%
associate-*l/34.2%
+-commutative34.2%
Simplified34.2%
Taylor expanded in x around 0 3.4%
Taylor expanded in y around inf 67.1%
Taylor expanded in y around inf 67.1%
if -6.5e12 < y < -1.32000000000000001e-46 or 5.79999999999999969e-92 < y < 0.75Initial program 97.8%
associate-*l/97.8%
+-commutative97.8%
Simplified97.8%
Taylor expanded in y around 0 94.4%
Taylor expanded in x around 0 74.5%
if -1.32000000000000001e-46 < y < -1.55000000000000003e-115 or 3.65000000000000017e-127 < y < 5.79999999999999969e-92Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 70.5%
*-commutative70.5%
Simplified70.5%
if -1.55000000000000003e-115 < y < 3.65000000000000017e-127Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 84.9%
Final simplification80.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ x (/ (- 1.0 x) y))))
(if (<= y -1.0)
t_0
(if (<= y 3.65e-127)
(- 1.0 y)
(if (<= y 2.2e-89) (* y x) (if (<= y 0.94) (- 1.0 y) t_0))))))
double code(double x, double y) {
double t_0 = x + ((1.0 - x) / y);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 3.65e-127) {
tmp = 1.0 - y;
} else if (y <= 2.2e-89) {
tmp = y * x;
} else if (y <= 0.94) {
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 <= (-1.0d0)) then
tmp = t_0
else if (y <= 3.65d-127) then
tmp = 1.0d0 - y
else if (y <= 2.2d-89) then
tmp = y * x
else if (y <= 0.94d0) 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 <= -1.0) {
tmp = t_0;
} else if (y <= 3.65e-127) {
tmp = 1.0 - y;
} else if (y <= 2.2e-89) {
tmp = y * x;
} else if (y <= 0.94) {
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 <= -1.0: tmp = t_0 elif y <= 3.65e-127: tmp = 1.0 - y elif y <= 2.2e-89: tmp = y * x elif y <= 0.94: 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 <= -1.0) tmp = t_0; elseif (y <= 3.65e-127) tmp = Float64(1.0 - y); elseif (y <= 2.2e-89) tmp = Float64(y * x); elseif (y <= 0.94) 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 <= -1.0) tmp = t_0; elseif (y <= 3.65e-127) tmp = 1.0 - y; elseif (y <= 2.2e-89) tmp = y * x; elseif (y <= 0.94) 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, -1.0], t$95$0, If[LessEqual[y, 3.65e-127], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 2.2e-89], N[(y * x), $MachinePrecision], If[LessEqual[y, 0.94], 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 -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.65 \cdot 10^{-127}:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{-89}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 0.94:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1 or 0.93999999999999995 < y Initial program 34.2%
associate-*l/52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in y around inf 99.5%
associate--l+99.5%
div-sub99.5%
Simplified99.5%
if -1 < y < 3.65000000000000017e-127 or 2.20000000000000012e-89 < y < 0.93999999999999995Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 99.5%
Taylor expanded in x around 0 77.4%
if 3.65000000000000017e-127 < y < 2.20000000000000012e-89Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification88.9%
(FPCore (x y) :precision binary64 (if (or (<= y -155000000.0) (not (<= y 140000000.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 <= -155000000.0) || !(y <= 140000000.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 <= (-155000000.0d0)) .or. (.not. (y <= 140000000.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 <= -155000000.0) || !(y <= 140000000.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 <= -155000000.0) or not (y <= 140000000.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 <= -155000000.0) || !(y <= 140000000.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 <= -155000000.0) || ~((y <= 140000000.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, -155000000.0], N[Not[LessEqual[y, 140000000.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 -155000000 \lor \neg \left(y \leq 140000000\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\
\end{array}
\end{array}
if y < -1.55e8 or 1.4e8 < y Initial program 33.7%
associate-*l/52.1%
+-commutative52.1%
Simplified52.1%
Taylor expanded in y around inf 99.9%
associate--l+99.9%
div-sub99.9%
Simplified99.9%
if -1.55e8 < y < 1.4e8Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ x (/ 1.0 y))))
(if (<= y -1.0)
t_0
(if (<= y 3.65e-127)
(- 1.0 y)
(if (<= y 1.32e-97) (* y x) (if (<= y 0.024) (- 1.0 y) t_0))))))
double code(double x, double y) {
double t_0 = x + (1.0 / y);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 3.65e-127) {
tmp = 1.0 - y;
} else if (y <= 1.32e-97) {
tmp = y * x;
} else if (y <= 0.024) {
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 / y)
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= 3.65d-127) then
tmp = 1.0d0 - y
else if (y <= 1.32d-97) then
tmp = y * x
else if (y <= 0.024d0) 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 / y);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 3.65e-127) {
tmp = 1.0 - y;
} else if (y <= 1.32e-97) {
tmp = y * x;
} else if (y <= 0.024) {
tmp = 1.0 - y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x + (1.0 / y) tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 3.65e-127: tmp = 1.0 - y elif y <= 1.32e-97: tmp = y * x elif y <= 0.024: tmp = 1.0 - y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x + Float64(1.0 / y)) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 3.65e-127) tmp = Float64(1.0 - y); elseif (y <= 1.32e-97) tmp = Float64(y * x); elseif (y <= 0.024) tmp = Float64(1.0 - y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x + (1.0 / y); tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= 3.65e-127) tmp = 1.0 - y; elseif (y <= 1.32e-97) tmp = y * x; elseif (y <= 0.024) tmp = 1.0 - y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 3.65e-127], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 1.32e-97], N[(y * x), $MachinePrecision], If[LessEqual[y, 0.024], N[(1.0 - y), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \frac{1}{y}\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.65 \cdot 10^{-127}:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq 1.32 \cdot 10^{-97}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 0.024:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1 or 0.024 < y Initial program 34.2%
associate-*l/52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in y around inf 99.5%
associate--l+99.5%
div-sub99.5%
Simplified99.5%
Taylor expanded in x around 0 99.1%
if -1 < y < 3.65000000000000017e-127 or 1.32e-97 < y < 0.024Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 99.5%
Taylor expanded in x around 0 77.4%
if 3.65000000000000017e-127 < y < 1.32e-97Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification88.7%
(FPCore (x y)
:precision binary64
(if (<= y -1.0)
x
(if (<= y 3.6e-127)
(- 1.0 y)
(if (<= y 1.3e-97) (* y x) (if (<= y 0.73) (- 1.0 y) x)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 3.6e-127) {
tmp = 1.0 - y;
} else if (y <= 1.3e-97) {
tmp = y * x;
} else if (y <= 0.73) {
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 <= 3.6d-127) then
tmp = 1.0d0 - y
else if (y <= 1.3d-97) then
tmp = y * x
else if (y <= 0.73d0) 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 <= 3.6e-127) {
tmp = 1.0 - y;
} else if (y <= 1.3e-97) {
tmp = y * x;
} else if (y <= 0.73) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 3.6e-127: tmp = 1.0 - y elif y <= 1.3e-97: tmp = y * x elif y <= 0.73: tmp = 1.0 - y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 3.6e-127) tmp = Float64(1.0 - y); elseif (y <= 1.3e-97) tmp = Float64(y * x); elseif (y <= 0.73) 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 <= 3.6e-127) tmp = 1.0 - y; elseif (y <= 1.3e-97) tmp = y * x; elseif (y <= 0.73) tmp = 1.0 - y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 3.6e-127], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 1.3e-97], N[(y * x), $MachinePrecision], If[LessEqual[y, 0.73], N[(1.0 - y), $MachinePrecision], x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-127}:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-97}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 0.73:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.72999999999999998 < y Initial program 34.2%
associate-*l/52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in y around inf 70.4%
if -1 < y < 3.5999999999999999e-127 or 1.30000000000000003e-97 < y < 0.72999999999999998Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 99.5%
Taylor expanded in x around 0 77.4%
if 3.5999999999999999e-127 < y < 1.30000000000000003e-97Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification74.3%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (+ x (/ (- 1.0 x) y)) (+ 1.0 (* y (+ x -1.0)))))
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 + -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.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = x + ((1.0d0 - x) / y)
else
tmp = 1.0d0 + (y * (x + (-1.0d0)))
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 + -1.0));
}
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 + -1.0)) 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(y * Float64(x + -1.0))); 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 + -1.0)); 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[(y * N[(x + -1.0), $MachinePrecision]), $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 + y \cdot \left(x + -1\right)\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 34.2%
associate-*l/52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in y around inf 99.5%
associate--l+99.5%
div-sub99.5%
Simplified99.5%
if -1 < y < 1Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 99.5%
Final simplification99.5%
(FPCore (x y)
:precision binary64
(if (<= y -1.0)
x
(if (<= y 3.65e-127)
1.0
(if (<= y 1.3e-97) (* y x) (if (<= y 1.05) 1.0 x)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 3.65e-127) {
tmp = 1.0;
} else if (y <= 1.3e-97) {
tmp = y * x;
} else if (y <= 1.05) {
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.65d-127) then
tmp = 1.0d0
else if (y <= 1.3d-97) then
tmp = y * x
else if (y <= 1.05d0) 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.65e-127) {
tmp = 1.0;
} else if (y <= 1.3e-97) {
tmp = y * x;
} else if (y <= 1.05) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 3.65e-127: tmp = 1.0 elif y <= 1.3e-97: tmp = y * x elif y <= 1.05: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 3.65e-127) tmp = 1.0; elseif (y <= 1.3e-97) tmp = Float64(y * x); elseif (y <= 1.05) 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.65e-127) tmp = 1.0; elseif (y <= 1.3e-97) tmp = y * x; elseif (y <= 1.05) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 3.65e-127], 1.0, If[LessEqual[y, 1.3e-97], N[(y * x), $MachinePrecision], If[LessEqual[y, 1.05], 1.0, x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3.65 \cdot 10^{-127}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-97}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 1.05:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 1.05000000000000004 < y Initial program 34.2%
associate-*l/52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in y around inf 70.4%
if -1 < y < 3.65000000000000017e-127 or 1.30000000000000003e-97 < y < 1.05000000000000004Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 75.8%
if 3.65000000000000017e-127 < y < 1.30000000000000003e-97Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification73.6%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.43) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.43) {
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 <= 0.43d0) 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 <= 0.43) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.43: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 0.43) 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 <= 0.43) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 0.43], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.43:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.429999999999999993 < y Initial program 34.2%
associate-*l/52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in y around inf 70.4%
if -1 < y < 0.429999999999999993Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 73.0%
Final simplification71.7%
(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 67.1%
associate-*l/76.2%
+-commutative76.2%
Simplified76.2%
Taylor expanded in y around 0 38.6%
Final simplification38.6%
(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 2023309
(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))))