
(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 9 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 (<= y -15500.0)
(+
(+ x (+ (/ (- 1.0 x) (pow y 3.0)) (/ (- 1.0 x) y)))
(/ (/ (+ x -1.0) y) y))
(if (<= y 1800000000.0)
(+ 1.0 (/ (* y (+ x -1.0)) (+ y 1.0)))
(+ x (/ 1.0 y)))))
double code(double x, double y) {
double tmp;
if (y <= -15500.0) {
tmp = (x + (((1.0 - x) / pow(y, 3.0)) + ((1.0 - x) / y))) + (((x + -1.0) / y) / y);
} else if (y <= 1800000000.0) {
tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0));
} else {
tmp = 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 <= (-15500.0d0)) then
tmp = (x + (((1.0d0 - x) / (y ** 3.0d0)) + ((1.0d0 - x) / y))) + (((x + (-1.0d0)) / y) / y)
else if (y <= 1800000000.0d0) then
tmp = 1.0d0 + ((y * (x + (-1.0d0))) / (y + 1.0d0))
else
tmp = x + (1.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -15500.0) {
tmp = (x + (((1.0 - x) / Math.pow(y, 3.0)) + ((1.0 - x) / y))) + (((x + -1.0) / y) / y);
} else if (y <= 1800000000.0) {
tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0));
} else {
tmp = x + (1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -15500.0: tmp = (x + (((1.0 - x) / math.pow(y, 3.0)) + ((1.0 - x) / y))) + (((x + -1.0) / y) / y) elif y <= 1800000000.0: tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)) else: tmp = x + (1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -15500.0) tmp = Float64(Float64(x + Float64(Float64(Float64(1.0 - x) / (y ^ 3.0)) + Float64(Float64(1.0 - x) / y))) + Float64(Float64(Float64(x + -1.0) / y) / y)); elseif (y <= 1800000000.0) tmp = Float64(1.0 + Float64(Float64(y * Float64(x + -1.0)) / Float64(y + 1.0))); else tmp = Float64(x + Float64(1.0 / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -15500.0) tmp = (x + (((1.0 - x) / (y ^ 3.0)) + ((1.0 - x) / y))) + (((x + -1.0) / y) / y); elseif (y <= 1800000000.0) tmp = 1.0 + ((y * (x + -1.0)) / (y + 1.0)); else tmp = x + (1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -15500.0], N[(N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1800000000.0], N[(1.0 + N[(N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -15500:\\
\;\;\;\;\left(x + \left(\frac{1 - x}{{y}^{3}} + \frac{1 - x}{y}\right)\right) + \frac{\frac{x + -1}{y}}{y}\\
\mathbf{elif}\;y \leq 1800000000:\\
\;\;\;\;1 + \frac{y \cdot \left(x + -1\right)}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{y}\\
\end{array}
\end{array}
if y < -15500Initial program 27.6%
Taylor expanded in y around -inf 99.8%
+-commutative99.8%
associate--l+99.8%
Simplified99.8%
if -15500 < y < 1.8e9Initial program 99.9%
if 1.8e9 < y Initial program 40.8%
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 100.0%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= y -225000000000.0) (not (<= y 86000000000.0))) (+ x (/ 1.0 y)) (+ 1.0 (* y (/ (+ x -1.0) (+ y 1.0))))))
double code(double x, double y) {
double tmp;
if ((y <= -225000000000.0) || !(y <= 86000000000.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 <= (-225000000000.0d0)) .or. (.not. (y <= 86000000000.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 <= -225000000000.0) || !(y <= 86000000000.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 <= -225000000000.0) or not (y <= 86000000000.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 <= -225000000000.0) || !(y <= 86000000000.0)) tmp = Float64(x + Float64(1.0 / 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 <= -225000000000.0) || ~((y <= 86000000000.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, -225000000000.0], N[Not[LessEqual[y, 86000000000.0]], $MachinePrecision]], N[(x + N[(1.0 / 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 -225000000000 \lor \neg \left(y \leq 86000000000\right):\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\
\end{array}
\end{array}
if y < -2.25e11 or 8.6e10 < y Initial program 33.1%
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 100.0%
if -2.25e11 < y < 8.6e10Initial program 99.8%
sub-neg99.8%
associate-*l/99.8%
distribute-lft-neg-in99.8%
distribute-frac-neg99.8%
neg-sub099.8%
associate--r-99.8%
metadata-eval99.8%
+-commutative99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= y -24000000000.0) (not (<= y 235000000000.0))) (+ x (/ 1.0 y)) (+ 1.0 (/ (* y (+ x -1.0)) (+ y 1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -24000000000.0) || !(y <= 235000000000.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 <= (-24000000000.0d0)) .or. (.not. (y <= 235000000000.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 <= -24000000000.0) || !(y <= 235000000000.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 <= -24000000000.0) or not (y <= 235000000000.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 <= -24000000000.0) || !(y <= 235000000000.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 <= -24000000000.0) || ~((y <= 235000000000.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, -24000000000.0], N[Not[LessEqual[y, 235000000000.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 -24000000000 \lor \neg \left(y \leq 235000000000\right):\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{y \cdot \left(x + -1\right)}{y + 1}\\
\end{array}
\end{array}
if y < -2.4e10 or 2.35e11 < y Initial program 33.1%
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 100.0%
if -2.4e10 < y < 2.35e11Initial program 99.8%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ x (/ 1.0 y))))
(if (<= y -1.0)
t_0
(if (<= y -4.45e-131)
(- 1.0 y)
(if (<= y -1.1e-163) (* y x) (if (<= y 3.75e-20) 1.0 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.45e-131) {
tmp = 1.0 - y;
} else if (y <= -1.1e-163) {
tmp = y * x;
} else if (y <= 3.75e-20) {
tmp = 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 = x + (1.0d0 / y)
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= (-4.45d-131)) then
tmp = 1.0d0 - y
else if (y <= (-1.1d-163)) then
tmp = y * x
else if (y <= 3.75d-20) then
tmp = 1.0d0
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.45e-131) {
tmp = 1.0 - y;
} else if (y <= -1.1e-163) {
tmp = y * x;
} else if (y <= 3.75e-20) {
tmp = 1.0;
} 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.45e-131: tmp = 1.0 - y elif y <= -1.1e-163: tmp = y * x elif y <= 3.75e-20: tmp = 1.0 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.45e-131) tmp = Float64(1.0 - y); elseif (y <= -1.1e-163) tmp = Float64(y * x); elseif (y <= 3.75e-20) tmp = 1.0; 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.45e-131) tmp = 1.0 - y; elseif (y <= -1.1e-163) tmp = y * x; elseif (y <= 3.75e-20) tmp = 1.0; 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.45e-131], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, -1.1e-163], N[(y * x), $MachinePrecision], If[LessEqual[y, 3.75e-20], 1.0, 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.45 \cdot 10^{-131}:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq -1.1 \cdot 10^{-163}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 3.75 \cdot 10^{-20}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1 or 3.74999999999999991e-20 < y Initial program 35.5%
Taylor expanded in y around -inf 96.8%
+-commutative96.8%
mul-1-neg96.8%
sub-neg96.8%
metadata-eval96.8%
distribute-neg-frac96.8%
+-commutative96.8%
distribute-neg-in96.8%
metadata-eval96.8%
sub-neg96.8%
Simplified96.8%
Taylor expanded in x around 0 97.0%
if -1 < y < -4.4500000000000001e-131Initial 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 71.6%
neg-mul-171.6%
sub-neg71.6%
Simplified71.6%
Taylor expanded in y around 0 69.7%
neg-mul-169.7%
unsub-neg69.7%
Simplified69.7%
if -4.4500000000000001e-131 < y < -1.10000000000000005e-163Initial 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 inf 86.0%
Taylor expanded in y around 0 86.0%
if -1.10000000000000005e-163 < y < 3.74999999999999991e-20Initial 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 86.5%
Final simplification89.5%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.78))) (+ x (/ 1.0 y)) (+ 1.0 (- (* y x) y))))
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) - 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 <= 0.78d0))) then
tmp = x + (1.0d0 / 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 <= 0.78)) {
tmp = x + (1.0 / y);
} else {
tmp = 1.0 + ((y * x) - y);
}
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) - y) 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(Float64(y * x) - y)); 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) - y); 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[(N[(y * x), $MachinePrecision] - y), $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 + \left(y \cdot x - y\right)\\
\end{array}
\end{array}
if y < -1 or 0.78000000000000003 < y Initial program 34.5%
Taylor expanded in y around -inf 98.3%
+-commutative98.3%
mul-1-neg98.3%
sub-neg98.3%
metadata-eval98.3%
distribute-neg-frac98.3%
+-commutative98.3%
distribute-neg-in98.3%
metadata-eval98.3%
sub-neg98.3%
Simplified98.3%
Taylor expanded in x around 0 98.3%
if -1 < y < 0.78000000000000003Initial program 100.0%
Taylor expanded in y around 0 98.8%
*-commutative98.8%
/-rgt-identity98.8%
associate-/r/98.7%
div-sub98.7%
remove-double-div98.7%
associate-/r/98.8%
/-rgt-identity98.8%
*-commutative98.8%
Simplified98.8%
Final simplification98.6%
(FPCore (x y)
:precision binary64
(if (<= y -1.0)
x
(if (<= y -4.45e-131)
1.0
(if (<= y -1.1e-163) (* y x) (if (<= y 6.8e+21) 1.0 x)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= -4.45e-131) {
tmp = 1.0;
} else if (y <= -1.1e-163) {
tmp = y * x;
} else if (y <= 6.8e+21) {
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.45d-131)) then
tmp = 1.0d0
else if (y <= (-1.1d-163)) then
tmp = y * x
else if (y <= 6.8d+21) 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.45e-131) {
tmp = 1.0;
} else if (y <= -1.1e-163) {
tmp = y * x;
} else if (y <= 6.8e+21) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= -4.45e-131: tmp = 1.0 elif y <= -1.1e-163: tmp = y * x elif y <= 6.8e+21: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= -4.45e-131) tmp = 1.0; elseif (y <= -1.1e-163) tmp = Float64(y * x); elseif (y <= 6.8e+21) 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.45e-131) tmp = 1.0; elseif (y <= -1.1e-163) tmp = y * x; elseif (y <= 6.8e+21) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, -4.45e-131], 1.0, If[LessEqual[y, -1.1e-163], N[(y * x), $MachinePrecision], If[LessEqual[y, 6.8e+21], 1.0, x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -4.45 \cdot 10^{-131}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.1 \cdot 10^{-163}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{+21}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 6.8e21 < y Initial program 34.3%
sub-neg34.3%
associate-*l/59.3%
distribute-lft-neg-in59.3%
distribute-frac-neg59.3%
neg-sub059.3%
associate--r-59.3%
metadata-eval59.3%
+-commutative59.3%
+-commutative59.3%
Simplified59.3%
Taylor expanded in y around inf 80.3%
if -1 < y < -4.4500000000000001e-131 or -1.10000000000000005e-163 < y < 6.8e21Initial program 99.2%
sub-neg99.2%
associate-*l/99.1%
distribute-lft-neg-in99.1%
distribute-frac-neg99.1%
neg-sub099.1%
associate--r-99.1%
metadata-eval99.1%
+-commutative99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in y around 0 78.7%
if -4.4500000000000001e-131 < y < -1.10000000000000005e-163Initial 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 inf 86.0%
Taylor expanded in y around 0 86.0%
Final simplification79.7%
(FPCore (x y)
:precision binary64
(if (<= y -1.0)
x
(if (<= y -4.45e-131)
(- 1.0 y)
(if (<= y -1.1e-163) (* y x) (if (<= y 6.8e+21) 1.0 x)))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= -4.45e-131) {
tmp = 1.0 - y;
} else if (y <= -1.1e-163) {
tmp = y * x;
} else if (y <= 6.8e+21) {
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.45d-131)) then
tmp = 1.0d0 - y
else if (y <= (-1.1d-163)) then
tmp = y * x
else if (y <= 6.8d+21) 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.45e-131) {
tmp = 1.0 - y;
} else if (y <= -1.1e-163) {
tmp = y * x;
} else if (y <= 6.8e+21) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= -4.45e-131: tmp = 1.0 - y elif y <= -1.1e-163: tmp = y * x elif y <= 6.8e+21: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= -4.45e-131) tmp = Float64(1.0 - y); elseif (y <= -1.1e-163) tmp = Float64(y * x); elseif (y <= 6.8e+21) 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.45e-131) tmp = 1.0 - y; elseif (y <= -1.1e-163) tmp = y * x; elseif (y <= 6.8e+21) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, -4.45e-131], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, -1.1e-163], N[(y * x), $MachinePrecision], If[LessEqual[y, 6.8e+21], 1.0, x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -4.45 \cdot 10^{-131}:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq -1.1 \cdot 10^{-163}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{+21}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 6.8e21 < y Initial program 34.3%
sub-neg34.3%
associate-*l/59.3%
distribute-lft-neg-in59.3%
distribute-frac-neg59.3%
neg-sub059.3%
associate--r-59.3%
metadata-eval59.3%
+-commutative59.3%
+-commutative59.3%
Simplified59.3%
Taylor expanded in y around inf 80.3%
if -1 < y < -4.4500000000000001e-131Initial 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 71.6%
neg-mul-171.6%
sub-neg71.6%
Simplified71.6%
Taylor expanded in y around 0 69.7%
neg-mul-169.7%
unsub-neg69.7%
Simplified69.7%
if -4.4500000000000001e-131 < y < -1.10000000000000005e-163Initial 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 inf 86.0%
Taylor expanded in y around 0 86.0%
if -1.10000000000000005e-163 < y < 6.8e21Initial program 98.8%
sub-neg98.8%
associate-*l/98.8%
distribute-lft-neg-in98.8%
distribute-frac-neg98.8%
neg-sub098.8%
associate--r-98.8%
metadata-eval98.8%
+-commutative98.8%
+-commutative98.8%
Simplified98.8%
Taylor expanded in y around 0 83.0%
Final simplification80.0%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 6.8e+21) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 6.8e+21) {
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 <= 6.8d+21) 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 <= 6.8e+21) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 6.8e+21: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 6.8e+21) 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 <= 6.8e+21) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 6.8e+21], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{+21}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 6.8e21 < y Initial program 34.3%
sub-neg34.3%
associate-*l/59.3%
distribute-lft-neg-in59.3%
distribute-frac-neg59.3%
neg-sub059.3%
associate--r-59.3%
metadata-eval59.3%
+-commutative59.3%
+-commutative59.3%
Simplified59.3%
Taylor expanded in y around inf 80.3%
if -1 < y < 6.8e21Initial program 99.2%
sub-neg99.2%
associate-*l/99.2%
distribute-lft-neg-in99.2%
distribute-frac-neg99.2%
neg-sub099.2%
associate--r-99.2%
metadata-eval99.2%
+-commutative99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in y around 0 75.4%
Final simplification77.8%
(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.5%
sub-neg67.5%
associate-*l/79.7%
distribute-lft-neg-in79.7%
distribute-frac-neg79.7%
neg-sub079.7%
associate--r-79.7%
metadata-eval79.7%
+-commutative79.7%
+-commutative79.7%
Simplified79.7%
Taylor expanded in y around 0 40.3%
Final simplification40.3%
(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 2023275
(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))))