
(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 12 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 -235000.0) (not (<= y 280000.0))) (+ (- x (/ (+ x -1.0) y)) (/ (+ x -1.0) (pow y 2.0))) (+ 1.0 (/ (* y (+ x -1.0)) (+ y 1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -235000.0) || !(y <= 280000.0)) {
tmp = (x - ((x + -1.0) / y)) + ((x + -1.0) / pow(y, 2.0));
} 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 <= (-235000.0d0)) .or. (.not. (y <= 280000.0d0))) then
tmp = (x - ((x + (-1.0d0)) / y)) + ((x + (-1.0d0)) / (y ** 2.0d0))
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 <= -235000.0) || !(y <= 280000.0)) {
tmp = (x - ((x + -1.0) / y)) + ((x + -1.0) / Math.pow(y, 2.0));
} else {
tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -235000.0) or not (y <= 280000.0): tmp = (x - ((x + -1.0) / y)) + ((x + -1.0) / math.pow(y, 2.0)) else: tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -235000.0) || !(y <= 280000.0)) tmp = Float64(Float64(x - Float64(Float64(x + -1.0) / y)) + Float64(Float64(x + -1.0) / (y ^ 2.0))); else tmp = Float64(1.0 + Float64(Float64(y * Float64(x + -1.0)) / Float64(y + 1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -235000.0) || ~((y <= 280000.0))) tmp = (x - ((x + -1.0) / y)) + ((x + -1.0) / (y ^ 2.0)); else tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -235000.0], N[Not[LessEqual[y, 280000.0]], $MachinePrecision]], N[(N[(x - N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -235000 \lor \neg \left(y \leq 280000\right):\\
\;\;\;\;\left(x - \frac{x + -1}{y}\right) + \frac{x + -1}{{y}^{2}}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{y \cdot \left(x + -1\right)}{y + 1}\\
\end{array}
\end{array}
if y < -235000 or 2.8e5 < y Initial program 30.7%
Taylor expanded in y around -inf 100.0%
associate-+r+100.0%
associate--l+100.0%
mul-1-neg100.0%
unsub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
div-sub100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
if -235000 < y < 2.8e5Initial program 99.9%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- x (/ -1.0 y))))
(if (<= y -1.0)
t_0
(if (<= y 4.6e-159)
(- 1.0 y)
(if (<= y 1.7e-107) (* y x) (if (<= y 0.16) (- 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 <= 4.6e-159) {
tmp = 1.0 - y;
} else if (y <= 1.7e-107) {
tmp = y * x;
} else if (y <= 0.16) {
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 <= 4.6d-159) then
tmp = 1.0d0 - y
else if (y <= 1.7d-107) then
tmp = y * x
else if (y <= 0.16d0) 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 <= 4.6e-159) {
tmp = 1.0 - y;
} else if (y <= 1.7e-107) {
tmp = y * x;
} else if (y <= 0.16) {
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 <= 4.6e-159: tmp = 1.0 - y elif y <= 1.7e-107: tmp = y * x elif y <= 0.16: 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 <= 4.6e-159) tmp = Float64(1.0 - y); elseif (y <= 1.7e-107) tmp = Float64(y * x); elseif (y <= 0.16) 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 <= 4.6e-159) tmp = 1.0 - y; elseif (y <= 1.7e-107) tmp = y * x; elseif (y <= 0.16) 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, 4.6e-159], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 1.7e-107], N[(y * x), $MachinePrecision], If[LessEqual[y, 0.16], 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 4.6 \cdot 10^{-159}:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-107}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 0.16:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 0.160000000000000003 < y Initial program 32.2%
Taylor expanded in y around -inf 98.2%
mul-1-neg98.2%
unsub-neg98.2%
sub-neg98.2%
metadata-eval98.2%
Simplified98.2%
Taylor expanded in x around 0 97.9%
if -1 < y < 4.59999999999999957e-159 or 1.69999999999999997e-107 < y < 0.160000000000000003Initial program 100.0%
Taylor expanded in x around 0 71.7%
Taylor expanded in y around 0 70.4%
neg-mul-170.4%
sub-neg70.4%
Simplified70.4%
if 4.59999999999999957e-159 < y < 1.69999999999999997e-107Initial program 100.0%
Taylor expanded in x around inf 76.4%
associate-/l*75.9%
*-lft-identity75.9%
associate-*l/75.9%
distribute-lft-in75.9%
*-rgt-identity75.9%
lft-mult-inverse75.9%
+-commutative75.9%
Simplified75.9%
Taylor expanded in y around 0 76.4%
*-commutative76.4%
Simplified76.4%
Final simplification85.3%
(FPCore (x y)
:precision binary64
(if (<= y -1.0)
x
(if (<= y 4.6e-159)
(- 1.0 y)
(if (<= y 2.3e-107) (* y x) (if (<= y 0.39) (- 1.0 y) x)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 4.6e-159) {
tmp = 1.0 - y;
} else if (y <= 2.3e-107) {
tmp = y * x;
} else if (y <= 0.39) {
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 <= 4.6d-159) then
tmp = 1.0d0 - y
else if (y <= 2.3d-107) then
tmp = y * x
else if (y <= 0.39d0) 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 <= 4.6e-159) {
tmp = 1.0 - y;
} else if (y <= 2.3e-107) {
tmp = y * x;
} else if (y <= 0.39) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 4.6e-159: tmp = 1.0 - y elif y <= 2.3e-107: tmp = y * x elif y <= 0.39: tmp = 1.0 - y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 4.6e-159) tmp = Float64(1.0 - y); elseif (y <= 2.3e-107) tmp = Float64(y * x); elseif (y <= 0.39) 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 <= 4.6e-159) tmp = 1.0 - y; elseif (y <= 2.3e-107) tmp = y * x; elseif (y <= 0.39) tmp = 1.0 - y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 4.6e-159], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 2.3e-107], N[(y * x), $MachinePrecision], If[LessEqual[y, 0.39], N[(1.0 - y), $MachinePrecision], x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{-159}:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-107}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 0.39:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.39000000000000001 < y Initial program 32.2%
Taylor expanded in y around inf 70.0%
if -1 < y < 4.59999999999999957e-159 or 2.30000000000000003e-107 < y < 0.39000000000000001Initial program 100.0%
Taylor expanded in x around 0 71.7%
Taylor expanded in y around 0 70.4%
neg-mul-170.4%
sub-neg70.4%
Simplified70.4%
if 4.59999999999999957e-159 < y < 2.30000000000000003e-107Initial program 100.0%
Taylor expanded in x around inf 76.4%
associate-/l*75.9%
*-lft-identity75.9%
associate-*l/75.9%
distribute-lft-in75.9%
*-rgt-identity75.9%
lft-mult-inverse75.9%
+-commutative75.9%
Simplified75.9%
Taylor expanded in y around 0 76.4%
*-commutative76.4%
Simplified76.4%
Final simplification70.4%
(FPCore (x y)
:precision binary64
(if (<= y -1.0)
x
(if (<= y 4.6e-159)
1.0
(if (<= y 1.7e-107) (* y x) (if (<= y 0.17) 1.0 x)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 4.6e-159) {
tmp = 1.0;
} else if (y <= 1.7e-107) {
tmp = y * x;
} else if (y <= 0.17) {
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 <= 4.6d-159) then
tmp = 1.0d0
else if (y <= 1.7d-107) then
tmp = y * x
else if (y <= 0.17d0) 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 <= 4.6e-159) {
tmp = 1.0;
} else if (y <= 1.7e-107) {
tmp = y * x;
} else if (y <= 0.17) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 4.6e-159: tmp = 1.0 elif y <= 1.7e-107: tmp = y * x elif y <= 0.17: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 4.6e-159) tmp = 1.0; elseif (y <= 1.7e-107) tmp = Float64(y * x); elseif (y <= 0.17) 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 <= 4.6e-159) tmp = 1.0; elseif (y <= 1.7e-107) tmp = y * x; elseif (y <= 0.17) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 4.6e-159], 1.0, If[LessEqual[y, 1.7e-107], N[(y * x), $MachinePrecision], If[LessEqual[y, 0.17], 1.0, x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{-159}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-107}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 0.17:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.170000000000000012 < y Initial program 32.2%
Taylor expanded in y around inf 70.0%
if -1 < y < 4.59999999999999957e-159 or 1.69999999999999997e-107 < y < 0.170000000000000012Initial program 100.0%
Taylor expanded in y around 0 69.5%
if 4.59999999999999957e-159 < y < 1.69999999999999997e-107Initial program 100.0%
Taylor expanded in x around inf 76.4%
associate-/l*75.9%
*-lft-identity75.9%
associate-*l/75.9%
distribute-lft-in75.9%
*-rgt-identity75.9%
lft-mult-inverse75.9%
+-commutative75.9%
Simplified75.9%
Taylor expanded in y around 0 76.4%
*-commutative76.4%
Simplified76.4%
Final simplification70.0%
(FPCore (x y) :precision binary64 (if (or (<= y -55000000000.0) (not (<= y 17000000000.0))) (- x (/ -1.0 y)) (+ 1.0 (/ (* y (+ x -1.0)) (+ y 1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -55000000000.0) || !(y <= 17000000000.0)) {
tmp = x - (-1.0 / 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 <= (-55000000000.0d0)) .or. (.not. (y <= 17000000000.0d0))) then
tmp = x - ((-1.0d0) / 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 <= -55000000000.0) || !(y <= 17000000000.0)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -55000000000.0) or not (y <= 17000000000.0): tmp = x - (-1.0 / y) else: tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -55000000000.0) || !(y <= 17000000000.0)) tmp = Float64(x - Float64(-1.0 / y)); else tmp = Float64(1.0 + Float64(Float64(y * Float64(x + -1.0)) / Float64(y + 1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -55000000000.0) || ~((y <= 17000000000.0))) tmp = x - (-1.0 / y); else tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -55000000000.0], N[Not[LessEqual[y, 17000000000.0]], $MachinePrecision]], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -55000000000 \lor \neg \left(y \leq 17000000000\right):\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{y \cdot \left(x + -1\right)}{y + 1}\\
\end{array}
\end{array}
if y < -5.5e10 or 1.7e10 < y Initial program 30.2%
Taylor expanded in y around -inf 99.9%
mul-1-neg99.9%
unsub-neg99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
if -5.5e10 < y < 1.7e10Initial program 99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= y -1.0)
(- x (/ -1.0 y))
(if (<= y 1.0)
(+ 1.0 (* y (* (- 1.0 x) (+ y -1.0))))
(- x (/ (+ x -1.0) y)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x - (-1.0 / y);
} else if (y <= 1.0) {
tmp = 1.0 + (y * ((1.0 - x) * (y + -1.0)));
} else {
tmp = x - ((x + -1.0) / 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)) then
tmp = x - ((-1.0d0) / y)
else if (y <= 1.0d0) then
tmp = 1.0d0 + (y * ((1.0d0 - x) * (y + (-1.0d0))))
else
tmp = x - ((x + (-1.0d0)) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x - (-1.0 / y);
} else if (y <= 1.0) {
tmp = 1.0 + (y * ((1.0 - x) * (y + -1.0)));
} else {
tmp = x - ((x + -1.0) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x - (-1.0 / y) elif y <= 1.0: tmp = 1.0 + (y * ((1.0 - x) * (y + -1.0))) else: tmp = x - ((x + -1.0) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = Float64(x - Float64(-1.0 / y)); elseif (y <= 1.0) tmp = Float64(1.0 + Float64(y * Float64(Float64(1.0 - x) * Float64(y + -1.0)))); else tmp = Float64(x - Float64(Float64(x + -1.0) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x - (-1.0 / y); elseif (y <= 1.0) tmp = 1.0 + (y * ((1.0 - x) * (y + -1.0))); else tmp = x - ((x + -1.0) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 + N[(y * N[(N[(1.0 - x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 + y \cdot \left(\left(1 - x\right) \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x + -1}{y}\\
\end{array}
\end{array}
if y < -1Initial program 35.4%
Taylor expanded in y around -inf 97.9%
mul-1-neg97.9%
unsub-neg97.9%
sub-neg97.9%
metadata-eval97.9%
Simplified97.9%
Taylor expanded in x around 0 97.9%
if -1 < y < 1Initial program 100.0%
Taylor expanded in y around 0 98.4%
sub-neg98.4%
metadata-eval98.4%
+-commutative98.4%
metadata-eval98.4%
associate--r-98.4%
neg-sub098.4%
distribute-rgt-neg-in98.4%
*-commutative98.4%
neg-mul-198.4%
unpow298.4%
associate-*l*98.4%
*-commutative98.4%
distribute-rgt-in98.3%
+-commutative98.3%
*-commutative98.3%
associate-*l*98.3%
Simplified98.3%
if 1 < y Initial program 27.4%
Taylor expanded in y around -inf 98.6%
mul-1-neg98.6%
unsub-neg98.6%
sub-neg98.6%
metadata-eval98.6%
Simplified98.6%
Final simplification98.2%
(FPCore (x y) :precision binary64 (if (<= y -1.0) (- x (/ -1.0 y)) (if (<= y 1.0) (- 1.0 (* (+ y -1.0) (* y x))) (- x (/ (+ x -1.0) y)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x - (-1.0 / y);
} else if (y <= 1.0) {
tmp = 1.0 - ((y + -1.0) * (y * x));
} else {
tmp = x - ((x + -1.0) / 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)) then
tmp = x - ((-1.0d0) / y)
else if (y <= 1.0d0) then
tmp = 1.0d0 - ((y + (-1.0d0)) * (y * x))
else
tmp = x - ((x + (-1.0d0)) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x - (-1.0 / y);
} else if (y <= 1.0) {
tmp = 1.0 - ((y + -1.0) * (y * x));
} else {
tmp = x - ((x + -1.0) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x - (-1.0 / y) elif y <= 1.0: tmp = 1.0 - ((y + -1.0) * (y * x)) else: tmp = x - ((x + -1.0) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = Float64(x - Float64(-1.0 / y)); elseif (y <= 1.0) tmp = Float64(1.0 - Float64(Float64(y + -1.0) * Float64(y * x))); else tmp = Float64(x - Float64(Float64(x + -1.0) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x - (-1.0 / y); elseif (y <= 1.0) tmp = 1.0 - ((y + -1.0) * (y * x)); else tmp = x - ((x + -1.0) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[(N[(y + -1.0), $MachinePrecision] * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \left(y + -1\right) \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x + -1}{y}\\
\end{array}
\end{array}
if y < -1Initial program 35.4%
Taylor expanded in y around -inf 97.9%
mul-1-neg97.9%
unsub-neg97.9%
sub-neg97.9%
metadata-eval97.9%
Simplified97.9%
Taylor expanded in x around 0 97.9%
if -1 < y < 1Initial program 100.0%
associate-/l*99.8%
+-commutative99.8%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow-199.7%
associate-/l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 97.9%
associate-*r/97.9%
neg-mul-197.9%
distribute-neg-in97.9%
metadata-eval97.9%
unsub-neg97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in y around 0 97.4%
*-commutative97.4%
*-commutative97.4%
unpow297.4%
associate-*l*97.4%
distribute-rgt-in97.4%
*-commutative97.4%
Simplified97.4%
if 1 < y Initial program 27.4%
Taylor expanded in y around -inf 98.6%
mul-1-neg98.6%
unsub-neg98.6%
sub-neg98.6%
metadata-eval98.6%
Simplified98.6%
Final simplification97.8%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.78))) (- x (/ -1.0 y)) (+ 1.0 (* y (+ x -1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.78)) {
tmp = x - (-1.0 / 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 <= 0.78d0))) then
tmp = x - ((-1.0d0) / 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 <= 0.78)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 + (y * (x + -1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 0.78): tmp = x - (-1.0 / y) else: tmp = 1.0 + (y * (x + -1.0)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.78)) tmp = Float64(x - Float64(-1.0 / 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 <= 0.78))) tmp = x - (-1.0 / 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, 0.78]], $MachinePrecision]], N[(x - N[(-1.0 / 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 0.78\right):\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \left(x + -1\right)\\
\end{array}
\end{array}
if y < -1 or 0.78000000000000003 < y Initial program 32.2%
Taylor expanded in y around -inf 98.2%
mul-1-neg98.2%
unsub-neg98.2%
sub-neg98.2%
metadata-eval98.2%
Simplified98.2%
Taylor expanded in x around 0 97.9%
if -1 < y < 0.78000000000000003Initial program 100.0%
Taylor expanded in y around 0 96.8%
Final simplification97.4%
(FPCore (x y) :precision binary64 (if (<= y -1.0) (- x (/ -1.0 y)) (if (<= y 1.0) (+ 1.0 (* y (+ x -1.0))) (- x (/ (+ x -1.0) y)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x - (-1.0 / y);
} else if (y <= 1.0) {
tmp = 1.0 + (y * (x + -1.0));
} else {
tmp = x - ((x + -1.0) / 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)) then
tmp = x - ((-1.0d0) / y)
else if (y <= 1.0d0) then
tmp = 1.0d0 + (y * (x + (-1.0d0)))
else
tmp = x - ((x + (-1.0d0)) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x - (-1.0 / y);
} else if (y <= 1.0) {
tmp = 1.0 + (y * (x + -1.0));
} else {
tmp = x - ((x + -1.0) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x - (-1.0 / y) elif y <= 1.0: tmp = 1.0 + (y * (x + -1.0)) else: tmp = x - ((x + -1.0) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = Float64(x - Float64(-1.0 / y)); elseif (y <= 1.0) tmp = Float64(1.0 + Float64(y * Float64(x + -1.0))); else tmp = Float64(x - Float64(Float64(x + -1.0) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x - (-1.0 / y); elseif (y <= 1.0) tmp = 1.0 + (y * (x + -1.0)); else tmp = x - ((x + -1.0) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 + N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 + y \cdot \left(x + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x + -1}{y}\\
\end{array}
\end{array}
if y < -1Initial program 35.4%
Taylor expanded in y around -inf 97.9%
mul-1-neg97.9%
unsub-neg97.9%
sub-neg97.9%
metadata-eval97.9%
Simplified97.9%
Taylor expanded in x around 0 97.9%
if -1 < y < 1Initial program 100.0%
Taylor expanded in y around 0 96.8%
if 1 < y Initial program 27.4%
Taylor expanded in y around -inf 98.6%
mul-1-neg98.6%
unsub-neg98.6%
sub-neg98.6%
metadata-eval98.6%
Simplified98.6%
Final simplification97.6%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (- x (/ -1.0 y)) (+ 1.0 (* y x))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x - (-1.0 / y);
} else {
tmp = 1.0 + (y * 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)) .or. (.not. (y <= 1.0d0))) then
tmp = x - ((-1.0d0) / y)
else
tmp = 1.0d0 + (y * x)
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 / y);
} else {
tmp = 1.0 + (y * x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = x - (-1.0 / y) else: tmp = 1.0 + (y * x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(x - Float64(-1.0 / y)); else tmp = Float64(1.0 + Float64(y * x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = x - (-1.0 / y); else tmp = 1.0 + (y * x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x - \frac{-1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot x\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 32.2%
Taylor expanded in y around -inf 98.2%
mul-1-neg98.2%
unsub-neg98.2%
sub-neg98.2%
metadata-eval98.2%
Simplified98.2%
Taylor expanded in x around 0 97.9%
if -1 < y < 1Initial program 100.0%
associate-/l*99.8%
+-commutative99.8%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow-199.7%
associate-/l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 97.9%
associate-*r/97.9%
neg-mul-197.9%
distribute-neg-in97.9%
metadata-eval97.9%
unsub-neg97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in y around 0 96.1%
mul-1-neg96.1%
*-commutative96.1%
distribute-rgt-neg-in96.1%
Simplified96.1%
Final simplification97.0%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 2.5) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 2.5) {
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 <= 2.5d0) 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 <= 2.5) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 2.5: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 2.5) 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 <= 2.5) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 2.5], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.5:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 2.5 < y Initial program 32.2%
Taylor expanded in y around inf 70.0%
if -1 < y < 2.5Initial program 100.0%
Taylor expanded in y around 0 65.6%
Final simplification68.0%
(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 63.7%
Taylor expanded in y around 0 32.5%
Final simplification32.5%
(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 2024034
(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))))