
(FPCore (x y) :precision binary64 (/ (- x y) (- 1.0 y)))
double code(double x, double y) {
return (x - y) / (1.0 - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (1.0d0 - y)
end function
public static double code(double x, double y) {
return (x - y) / (1.0 - y);
}
def code(x, y): return (x - y) / (1.0 - y)
function code(x, y) return Float64(Float64(x - y) / Float64(1.0 - y)) end
function tmp = code(x, y) tmp = (x - y) / (1.0 - y); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{1 - y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (- x y) (- 1.0 y)))
double code(double x, double y) {
return (x - y) / (1.0 - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (1.0d0 - y)
end function
public static double code(double x, double y) {
return (x - y) / (1.0 - y);
}
def code(x, y): return (x - y) / (1.0 - y)
function code(x, y) return Float64(Float64(x - y) / Float64(1.0 - y)) end
function tmp = code(x, y) tmp = (x - y) / (1.0 - y); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{1 - y}
\end{array}
(FPCore (x y) :precision binary64 (/ (- x y) (- 1.0 y)))
double code(double x, double y) {
return (x - y) / (1.0 - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (1.0d0 - y)
end function
public static double code(double x, double y) {
return (x - y) / (1.0 - y);
}
def code(x, y): return (x - y) / (1.0 - y)
function code(x, y) return Float64(Float64(x - y) / Float64(1.0 - y)) end
function tmp = code(x, y) tmp = (x - y) / (1.0 - y); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{1 - y}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= y -2.3e+23)
1.0
(if (<= y -0.05)
(/ (- x) (+ y -1.0))
(if (or (<= y -7.2e-16) (not (<= y 7e-20))) (/ y (+ y -1.0)) (- x y)))))
double code(double x, double y) {
double tmp;
if (y <= -2.3e+23) {
tmp = 1.0;
} else if (y <= -0.05) {
tmp = -x / (y + -1.0);
} else if ((y <= -7.2e-16) || !(y <= 7e-20)) {
tmp = y / (y + -1.0);
} else {
tmp = 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 <= (-2.3d+23)) then
tmp = 1.0d0
else if (y <= (-0.05d0)) then
tmp = -x / (y + (-1.0d0))
else if ((y <= (-7.2d-16)) .or. (.not. (y <= 7d-20))) then
tmp = y / (y + (-1.0d0))
else
tmp = x - y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.3e+23) {
tmp = 1.0;
} else if (y <= -0.05) {
tmp = -x / (y + -1.0);
} else if ((y <= -7.2e-16) || !(y <= 7e-20)) {
tmp = y / (y + -1.0);
} else {
tmp = x - y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.3e+23: tmp = 1.0 elif y <= -0.05: tmp = -x / (y + -1.0) elif (y <= -7.2e-16) or not (y <= 7e-20): tmp = y / (y + -1.0) else: tmp = x - y return tmp
function code(x, y) tmp = 0.0 if (y <= -2.3e+23) tmp = 1.0; elseif (y <= -0.05) tmp = Float64(Float64(-x) / Float64(y + -1.0)); elseif ((y <= -7.2e-16) || !(y <= 7e-20)) tmp = Float64(y / Float64(y + -1.0)); else tmp = Float64(x - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.3e+23) tmp = 1.0; elseif (y <= -0.05) tmp = -x / (y + -1.0); elseif ((y <= -7.2e-16) || ~((y <= 7e-20))) tmp = y / (y + -1.0); else tmp = x - y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.3e+23], 1.0, If[LessEqual[y, -0.05], N[((-x) / N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -7.2e-16], N[Not[LessEqual[y, 7e-20]], $MachinePrecision]], N[(y / N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x - y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{+23}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -0.05:\\
\;\;\;\;\frac{-x}{y + -1}\\
\mathbf{elif}\;y \leq -7.2 \cdot 10^{-16} \lor \neg \left(y \leq 7 \cdot 10^{-20}\right):\\
\;\;\;\;\frac{y}{y + -1}\\
\mathbf{else}:\\
\;\;\;\;x - y\\
\end{array}
\end{array}
if y < -2.3e23Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 81.9%
if -2.3e23 < y < -0.050000000000000003Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 86.1%
sub-neg86.1%
metadata-eval86.1%
neg-mul-186.1%
distribute-neg-frac86.1%
+-commutative86.1%
Simplified86.1%
if -0.050000000000000003 < y < -7.19999999999999965e-16 or 7.00000000000000007e-20 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 83.9%
if -7.19999999999999965e-16 < y < 7.00000000000000007e-20Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
clear-num99.7%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 100.0%
Final simplification91.1%
(FPCore (x y)
:precision binary64
(if (<= y -1e+23)
1.0
(if (<= y -1.9)
(/ (- x) (+ y -1.0))
(if (<= y -7.2e-16)
(* y (/ 1.0 (+ y -1.0)))
(if (<= y 7e-20) (- x y) (/ y (+ y -1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -1e+23) {
tmp = 1.0;
} else if (y <= -1.9) {
tmp = -x / (y + -1.0);
} else if (y <= -7.2e-16) {
tmp = y * (1.0 / (y + -1.0));
} else if (y <= 7e-20) {
tmp = x - y;
} else {
tmp = y / (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 <= (-1d+23)) then
tmp = 1.0d0
else if (y <= (-1.9d0)) then
tmp = -x / (y + (-1.0d0))
else if (y <= (-7.2d-16)) then
tmp = y * (1.0d0 / (y + (-1.0d0)))
else if (y <= 7d-20) then
tmp = x - y
else
tmp = y / (y + (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1e+23) {
tmp = 1.0;
} else if (y <= -1.9) {
tmp = -x / (y + -1.0);
} else if (y <= -7.2e-16) {
tmp = y * (1.0 / (y + -1.0));
} else if (y <= 7e-20) {
tmp = x - y;
} else {
tmp = y / (y + -1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1e+23: tmp = 1.0 elif y <= -1.9: tmp = -x / (y + -1.0) elif y <= -7.2e-16: tmp = y * (1.0 / (y + -1.0)) elif y <= 7e-20: tmp = x - y else: tmp = y / (y + -1.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -1e+23) tmp = 1.0; elseif (y <= -1.9) tmp = Float64(Float64(-x) / Float64(y + -1.0)); elseif (y <= -7.2e-16) tmp = Float64(y * Float64(1.0 / Float64(y + -1.0))); elseif (y <= 7e-20) tmp = Float64(x - y); else tmp = Float64(y / Float64(y + -1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1e+23) tmp = 1.0; elseif (y <= -1.9) tmp = -x / (y + -1.0); elseif (y <= -7.2e-16) tmp = y * (1.0 / (y + -1.0)); elseif (y <= 7e-20) tmp = x - y; else tmp = y / (y + -1.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1e+23], 1.0, If[LessEqual[y, -1.9], N[((-x) / N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -7.2e-16], N[(y * N[(1.0 / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7e-20], N[(x - y), $MachinePrecision], N[(y / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+23}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.9:\\
\;\;\;\;\frac{-x}{y + -1}\\
\mathbf{elif}\;y \leq -7.2 \cdot 10^{-16}:\\
\;\;\;\;y \cdot \frac{1}{y + -1}\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-20}:\\
\;\;\;\;x - y\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -1}\\
\end{array}
\end{array}
if y < -9.9999999999999992e22Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 81.9%
if -9.9999999999999992e22 < y < -1.8999999999999999Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 86.1%
sub-neg86.1%
metadata-eval86.1%
neg-mul-186.1%
distribute-neg-frac86.1%
+-commutative86.1%
Simplified86.1%
if -1.8999999999999999 < y < -7.19999999999999965e-16Initial program 99.2%
sub-neg99.2%
+-commutative99.2%
neg-sub099.2%
associate-+l-99.2%
sub0-neg99.2%
neg-mul-199.2%
sub-neg99.2%
+-commutative99.2%
neg-sub099.2%
associate-+l-99.2%
sub0-neg99.2%
neg-mul-199.2%
times-frac99.2%
metadata-eval99.2%
*-lft-identity99.2%
sub-neg99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in x around 0 99.2%
clear-num99.6%
associate-/r/99.6%
sub-neg99.6%
metadata-eval99.6%
Applied egg-rr99.6%
if -7.19999999999999965e-16 < y < 7.00000000000000007e-20Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
clear-num99.7%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 100.0%
if 7.00000000000000007e-20 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 82.9%
Final simplification91.1%
(FPCore (x y) :precision binary64 (if (or (<= y -7.2e-16) (not (<= y 7e-20))) (/ y (+ y -1.0)) (- x y)))
double code(double x, double y) {
double tmp;
if ((y <= -7.2e-16) || !(y <= 7e-20)) {
tmp = y / (y + -1.0);
} else {
tmp = 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 <= (-7.2d-16)) .or. (.not. (y <= 7d-20))) then
tmp = y / (y + (-1.0d0))
else
tmp = x - y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -7.2e-16) || !(y <= 7e-20)) {
tmp = y / (y + -1.0);
} else {
tmp = x - y;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -7.2e-16) or not (y <= 7e-20): tmp = y / (y + -1.0) else: tmp = x - y return tmp
function code(x, y) tmp = 0.0 if ((y <= -7.2e-16) || !(y <= 7e-20)) tmp = Float64(y / Float64(y + -1.0)); else tmp = Float64(x - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -7.2e-16) || ~((y <= 7e-20))) tmp = y / (y + -1.0); else tmp = x - y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -7.2e-16], N[Not[LessEqual[y, 7e-20]], $MachinePrecision]], N[(y / N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{-16} \lor \neg \left(y \leq 7 \cdot 10^{-20}\right):\\
\;\;\;\;\frac{y}{y + -1}\\
\mathbf{else}:\\
\;\;\;\;x - y\\
\end{array}
\end{array}
if y < -7.19999999999999965e-16 or 7.00000000000000007e-20 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 79.5%
if -7.19999999999999965e-16 < y < 7.00000000000000007e-20Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
clear-num99.7%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 100.0%
Final simplification89.2%
(FPCore (x y) :precision binary64 (if (<= y -240000.0) 1.0 (if (<= y -3.1e-35) (- y) (if (<= y 1.0) x 1.0))))
double code(double x, double y) {
double tmp;
if (y <= -240000.0) {
tmp = 1.0;
} else if (y <= -3.1e-35) {
tmp = -y;
} else if (y <= 1.0) {
tmp = x;
} 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 <= (-240000.0d0)) then
tmp = 1.0d0
else if (y <= (-3.1d-35)) then
tmp = -y
else if (y <= 1.0d0) then
tmp = x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -240000.0) {
tmp = 1.0;
} else if (y <= -3.1e-35) {
tmp = -y;
} else if (y <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -240000.0: tmp = 1.0 elif y <= -3.1e-35: tmp = -y elif y <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -240000.0) tmp = 1.0; elseif (y <= -3.1e-35) tmp = Float64(-y); elseif (y <= 1.0) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -240000.0) tmp = 1.0; elseif (y <= -3.1e-35) tmp = -y; elseif (y <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -240000.0], 1.0, If[LessEqual[y, -3.1e-35], (-y), If[LessEqual[y, 1.0], x, 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -240000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -3.1 \cdot 10^{-35}:\\
\;\;\;\;-y\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.4e5 or 1 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 78.0%
if -2.4e5 < y < -3.10000000000000012e-35Initial program 99.8%
sub-neg99.8%
+-commutative99.8%
neg-sub099.8%
associate-+l-99.8%
sub0-neg99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
neg-sub099.8%
associate-+l-99.8%
sub0-neg99.8%
neg-mul-199.8%
times-frac99.8%
metadata-eval99.8%
*-lft-identity99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 70.1%
Taylor expanded in y around 0 59.6%
neg-mul-159.6%
Simplified59.6%
if -3.10000000000000012e-35 < y < 1Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 75.6%
Final simplification76.0%
(FPCore (x y) :precision binary64 (if (<= y -145000000.0) 1.0 (if (<= y 1.0) (- x y) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -145000000.0) {
tmp = 1.0;
} else if (y <= 1.0) {
tmp = x - y;
} 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 <= (-145000000.0d0)) then
tmp = 1.0d0
else if (y <= 1.0d0) then
tmp = x - y
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -145000000.0) {
tmp = 1.0;
} else if (y <= 1.0) {
tmp = x - y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -145000000.0: tmp = 1.0 elif y <= 1.0: tmp = x - y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -145000000.0) tmp = 1.0; elseif (y <= 1.0) tmp = Float64(x - y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -145000000.0) tmp = 1.0; elseif (y <= 1.0) tmp = x - y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -145000000.0], 1.0, If[LessEqual[y, 1.0], N[(x - y), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -145000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x - y\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.45e8 or 1 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 79.2%
if -1.45e8 < y < 1Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
clear-num99.7%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 96.0%
Final simplification87.9%
(FPCore (x y) :precision binary64 (if (<= y -145000000.0) 1.0 (if (<= y 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -145000000.0) {
tmp = 1.0;
} else if (y <= 1.0) {
tmp = x;
} 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 <= (-145000000.0d0)) then
tmp = 1.0d0
else if (y <= 1.0d0) then
tmp = x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -145000000.0) {
tmp = 1.0;
} else if (y <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -145000000.0: tmp = 1.0 elif y <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -145000000.0) tmp = 1.0; elseif (y <= 1.0) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -145000000.0) tmp = 1.0; elseif (y <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -145000000.0], 1.0, If[LessEqual[y, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -145000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.45e8 or 1 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 79.2%
if -1.45e8 < y < 1Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 69.2%
Final simplification74.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 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 40.2%
Final simplification40.2%
herbie shell --seed 2023238
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, C"
:precision binary64
(/ (- x y) (- 1.0 y)))