
(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 10 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 -680000.0)
(- 1.0 (/ x y))
(if (<= y -1.7e-36)
(/ y (+ y -1.0))
(if (<= y 2.7e+14) (/ x (- 1.0 y)) (+ 1.0 (/ (- 1.0 x) y))))))
double code(double x, double y) {
double tmp;
if (y <= -680000.0) {
tmp = 1.0 - (x / y);
} else if (y <= -1.7e-36) {
tmp = y / (y + -1.0);
} else if (y <= 2.7e+14) {
tmp = x / (1.0 - y);
} else {
tmp = 1.0 + ((1.0 - 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 <= (-680000.0d0)) then
tmp = 1.0d0 - (x / y)
else if (y <= (-1.7d-36)) then
tmp = y / (y + (-1.0d0))
else if (y <= 2.7d+14) then
tmp = x / (1.0d0 - y)
else
tmp = 1.0d0 + ((1.0d0 - x) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -680000.0) {
tmp = 1.0 - (x / y);
} else if (y <= -1.7e-36) {
tmp = y / (y + -1.0);
} else if (y <= 2.7e+14) {
tmp = x / (1.0 - y);
} else {
tmp = 1.0 + ((1.0 - x) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -680000.0: tmp = 1.0 - (x / y) elif y <= -1.7e-36: tmp = y / (y + -1.0) elif y <= 2.7e+14: tmp = x / (1.0 - y) else: tmp = 1.0 + ((1.0 - x) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -680000.0) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= -1.7e-36) tmp = Float64(y / Float64(y + -1.0)); elseif (y <= 2.7e+14) tmp = Float64(x / Float64(1.0 - y)); else tmp = Float64(1.0 + Float64(Float64(1.0 - x) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -680000.0) tmp = 1.0 - (x / y); elseif (y <= -1.7e-36) tmp = y / (y + -1.0); elseif (y <= 2.7e+14) tmp = x / (1.0 - y); else tmp = 1.0 + ((1.0 - x) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -680000.0], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.7e-36], N[(y / N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.7e+14], N[(x / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -680000:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq -1.7 \cdot 10^{-36}:\\
\;\;\;\;\frac{y}{y + -1}\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+14}:\\
\;\;\;\;\frac{x}{1 - y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{1 - x}{y}\\
\end{array}
\end{array}
if y < -6.8e5Initial program 100.0%
add-sqr-sqrt83.2%
pow283.2%
Applied egg-rr83.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 inf 98.2%
if -6.8e5 < y < -1.7000000000000001e-36Initial program 99.9%
Taylor expanded in x around 0 91.6%
metadata-eval91.6%
times-frac91.6%
*-lft-identity91.6%
neg-mul-191.6%
neg-sub091.6%
associate--r-91.6%
metadata-eval91.6%
Simplified91.6%
if -1.7000000000000001e-36 < y < 2.7e14Initial program 100.0%
Taylor expanded in x around inf 82.6%
if 2.7e14 < y Initial program 100.0%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
div-sub100.0%
Simplified100.0%
Final simplification90.7%
(FPCore (x y)
:precision binary64
(if (<= y -5e+79)
1.0
(if (<= y -45.0)
(/ (- x) y)
(if (<= y -1.32e-36) (- y) (if (<= y 1.0) x 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -5e+79) {
tmp = 1.0;
} else if (y <= -45.0) {
tmp = -x / y;
} else if (y <= -1.32e-36) {
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 <= (-5d+79)) then
tmp = 1.0d0
else if (y <= (-45.0d0)) then
tmp = -x / y
else if (y <= (-1.32d-36)) 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 <= -5e+79) {
tmp = 1.0;
} else if (y <= -45.0) {
tmp = -x / y;
} else if (y <= -1.32e-36) {
tmp = -y;
} else if (y <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5e+79: tmp = 1.0 elif y <= -45.0: tmp = -x / y elif y <= -1.32e-36: tmp = -y elif y <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5e+79) tmp = 1.0; elseif (y <= -45.0) tmp = Float64(Float64(-x) / y); elseif (y <= -1.32e-36) 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 <= -5e+79) tmp = 1.0; elseif (y <= -45.0) tmp = -x / y; elseif (y <= -1.32e-36) tmp = -y; elseif (y <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5e+79], 1.0, If[LessEqual[y, -45.0], N[((-x) / y), $MachinePrecision], If[LessEqual[y, -1.32e-36], (-y), If[LessEqual[y, 1.0], x, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+79}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -45:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq -1.32 \cdot 10^{-36}:\\
\;\;\;\;-y\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5e79 or 1 < y Initial program 100.0%
Taylor expanded in y around inf 79.4%
if -5e79 < y < -45Initial program 99.9%
Taylor expanded in x around inf 72.8%
Taylor expanded in y around inf 66.9%
associate-*r/66.9%
neg-mul-166.9%
Simplified66.9%
if -45 < y < -1.31999999999999993e-36Initial program 99.9%
Taylor expanded in x around 0 91.6%
metadata-eval91.6%
times-frac91.6%
*-lft-identity91.6%
neg-mul-191.6%
neg-sub091.6%
associate--r-91.6%
metadata-eval91.6%
Simplified91.6%
Taylor expanded in y around 0 74.4%
neg-mul-174.4%
Simplified74.4%
if -1.31999999999999993e-36 < y < 1Initial program 100.0%
Taylor expanded in y around 0 82.2%
Final simplification79.6%
(FPCore (x y)
:precision binary64
(if (<= y -2.65e+81)
1.0
(if (<= y -0.185)
(/ (- x) y)
(if (<= y -1.02e-35) (* y (- -1.0 y)) (if (<= y 1.0) x 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -2.65e+81) {
tmp = 1.0;
} else if (y <= -0.185) {
tmp = -x / y;
} else if (y <= -1.02e-35) {
tmp = y * (-1.0 - 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 <= (-2.65d+81)) then
tmp = 1.0d0
else if (y <= (-0.185d0)) then
tmp = -x / y
else if (y <= (-1.02d-35)) then
tmp = y * ((-1.0d0) - 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 <= -2.65e+81) {
tmp = 1.0;
} else if (y <= -0.185) {
tmp = -x / y;
} else if (y <= -1.02e-35) {
tmp = y * (-1.0 - y);
} else if (y <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.65e+81: tmp = 1.0 elif y <= -0.185: tmp = -x / y elif y <= -1.02e-35: tmp = y * (-1.0 - y) elif y <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -2.65e+81) tmp = 1.0; elseif (y <= -0.185) tmp = Float64(Float64(-x) / y); elseif (y <= -1.02e-35) tmp = Float64(y * Float64(-1.0 - 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 <= -2.65e+81) tmp = 1.0; elseif (y <= -0.185) tmp = -x / y; elseif (y <= -1.02e-35) tmp = y * (-1.0 - y); elseif (y <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.65e+81], 1.0, If[LessEqual[y, -0.185], N[((-x) / y), $MachinePrecision], If[LessEqual[y, -1.02e-35], N[(y * N[(-1.0 - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], x, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.65 \cdot 10^{+81}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -0.185:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq -1.02 \cdot 10^{-35}:\\
\;\;\;\;y \cdot \left(-1 - y\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.65000000000000014e81 or 1 < y Initial program 100.0%
Taylor expanded in y around inf 79.4%
if -2.65000000000000014e81 < y < -0.185Initial program 99.9%
Taylor expanded in x around inf 69.3%
Taylor expanded in y around inf 63.7%
associate-*r/63.7%
neg-mul-163.7%
Simplified63.7%
if -0.185 < y < -1.01999999999999995e-35Initial program 99.9%
Taylor expanded in x around 0 90.8%
metadata-eval90.8%
times-frac90.8%
*-lft-identity90.8%
neg-mul-190.8%
neg-sub090.8%
associate--r-90.8%
metadata-eval90.8%
Simplified90.8%
Taylor expanded in y around 0 84.6%
mul-1-neg84.6%
unpow284.6%
distribute-lft-neg-in84.6%
distribute-rgt-in84.5%
sub-neg84.5%
Simplified84.5%
if -1.01999999999999995e-35 < y < 1Initial program 100.0%
Taylor expanded in y around 0 82.2%
Final simplification79.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -0.105)
t_0
(if (<= y -1.75e-36) (* y (- -1.0 y)) (if (<= y 1.0) x t_0)))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -0.105) {
tmp = t_0;
} else if (y <= -1.75e-36) {
tmp = y * (-1.0 - y);
} else if (y <= 1.0) {
tmp = x;
} 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 - (x / y)
if (y <= (-0.105d0)) then
tmp = t_0
else if (y <= (-1.75d-36)) then
tmp = y * ((-1.0d0) - y)
else if (y <= 1.0d0) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -0.105) {
tmp = t_0;
} else if (y <= -1.75e-36) {
tmp = y * (-1.0 - y);
} else if (y <= 1.0) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) tmp = 0 if y <= -0.105: tmp = t_0 elif y <= -1.75e-36: tmp = y * (-1.0 - y) elif y <= 1.0: tmp = x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -0.105) tmp = t_0; elseif (y <= -1.75e-36) tmp = Float64(y * Float64(-1.0 - y)); elseif (y <= 1.0) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -0.105) tmp = t_0; elseif (y <= -1.75e-36) tmp = y * (-1.0 - y); elseif (y <= 1.0) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.105], t$95$0, If[LessEqual[y, -1.75e-36], N[(y * N[(-1.0 - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], x, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -0.105:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.75 \cdot 10^{-36}:\\
\;\;\;\;y \cdot \left(-1 - y\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.104999999999999996 or 1 < y Initial program 100.0%
add-sqr-sqrt87.6%
pow287.6%
Applied egg-rr87.6%
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 inf 98.1%
if -0.104999999999999996 < y < -1.75e-36Initial program 99.9%
Taylor expanded in x around 0 90.8%
metadata-eval90.8%
times-frac90.8%
*-lft-identity90.8%
neg-mul-190.8%
neg-sub090.8%
associate--r-90.8%
metadata-eval90.8%
Simplified90.8%
Taylor expanded in y around 0 84.6%
mul-1-neg84.6%
unpow284.6%
distribute-lft-neg-in84.6%
distribute-rgt-in84.5%
sub-neg84.5%
Simplified84.5%
if -1.75e-36 < y < 1Initial program 100.0%
Taylor expanded in y around 0 82.2%
Final simplification89.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -0.076)
t_0
(if (<= y -1.62e-35)
(* y (- -1.0 y))
(if (<= y 2.7e+14) (/ x (- 1.0 y)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -0.076) {
tmp = t_0;
} else if (y <= -1.62e-35) {
tmp = y * (-1.0 - y);
} else if (y <= 2.7e+14) {
tmp = x / (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 = 1.0d0 - (x / y)
if (y <= (-0.076d0)) then
tmp = t_0
else if (y <= (-1.62d-35)) then
tmp = y * ((-1.0d0) - y)
else if (y <= 2.7d+14) then
tmp = x / (1.0d0 - y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -0.076) {
tmp = t_0;
} else if (y <= -1.62e-35) {
tmp = y * (-1.0 - y);
} else if (y <= 2.7e+14) {
tmp = x / (1.0 - y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) tmp = 0 if y <= -0.076: tmp = t_0 elif y <= -1.62e-35: tmp = y * (-1.0 - y) elif y <= 2.7e+14: tmp = x / (1.0 - y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -0.076) tmp = t_0; elseif (y <= -1.62e-35) tmp = Float64(y * Float64(-1.0 - y)); elseif (y <= 2.7e+14) tmp = Float64(x / Float64(1.0 - y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -0.076) tmp = t_0; elseif (y <= -1.62e-35) tmp = y * (-1.0 - y); elseif (y <= 2.7e+14) tmp = x / (1.0 - y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.076], t$95$0, If[LessEqual[y, -1.62e-35], N[(y * N[(-1.0 - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.7e+14], N[(x / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -0.076:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.62 \cdot 10^{-35}:\\
\;\;\;\;y \cdot \left(-1 - y\right)\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+14}:\\
\;\;\;\;\frac{x}{1 - y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.0759999999999999981 or 2.7e14 < y Initial program 100.0%
add-sqr-sqrt89.1%
pow289.1%
Applied egg-rr89.1%
Taylor expanded in y around -inf 98.5%
mul-1-neg98.5%
unsub-neg98.5%
sub-neg98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in x around inf 98.4%
if -0.0759999999999999981 < y < -1.62000000000000011e-35Initial program 99.9%
Taylor expanded in x around 0 90.8%
metadata-eval90.8%
times-frac90.8%
*-lft-identity90.8%
neg-mul-190.8%
neg-sub090.8%
associate--r-90.8%
metadata-eval90.8%
Simplified90.8%
Taylor expanded in y around 0 84.6%
mul-1-neg84.6%
unpow284.6%
distribute-lft-neg-in84.6%
distribute-rgt-in84.5%
sub-neg84.5%
Simplified84.5%
if -1.62000000000000011e-35 < y < 2.7e14Initial program 100.0%
Taylor expanded in x around inf 82.6%
Final simplification90.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -900000.0)
t_0
(if (<= y -7.8e-36)
(/ y (+ y -1.0))
(if (<= y 2.7e+14) (/ x (- 1.0 y)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -900000.0) {
tmp = t_0;
} else if (y <= -7.8e-36) {
tmp = y / (y + -1.0);
} else if (y <= 2.7e+14) {
tmp = x / (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 = 1.0d0 - (x / y)
if (y <= (-900000.0d0)) then
tmp = t_0
else if (y <= (-7.8d-36)) then
tmp = y / (y + (-1.0d0))
else if (y <= 2.7d+14) then
tmp = x / (1.0d0 - y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -900000.0) {
tmp = t_0;
} else if (y <= -7.8e-36) {
tmp = y / (y + -1.0);
} else if (y <= 2.7e+14) {
tmp = x / (1.0 - y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) tmp = 0 if y <= -900000.0: tmp = t_0 elif y <= -7.8e-36: tmp = y / (y + -1.0) elif y <= 2.7e+14: tmp = x / (1.0 - y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -900000.0) tmp = t_0; elseif (y <= -7.8e-36) tmp = Float64(y / Float64(y + -1.0)); elseif (y <= 2.7e+14) tmp = Float64(x / Float64(1.0 - y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -900000.0) tmp = t_0; elseif (y <= -7.8e-36) tmp = y / (y + -1.0); elseif (y <= 2.7e+14) tmp = x / (1.0 - y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -900000.0], t$95$0, If[LessEqual[y, -7.8e-36], N[(y / N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.7e+14], N[(x / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -900000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -7.8 \cdot 10^{-36}:\\
\;\;\;\;\frac{y}{y + -1}\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+14}:\\
\;\;\;\;\frac{x}{1 - y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -9e5 or 2.7e14 < y Initial program 100.0%
add-sqr-sqrt89.0%
pow289.0%
Applied egg-rr89.0%
Taylor expanded in y around -inf 99.1%
mul-1-neg99.1%
unsub-neg99.1%
sub-neg99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in x around inf 99.1%
if -9e5 < y < -7.8000000000000001e-36Initial program 99.9%
Taylor expanded in x around 0 91.6%
metadata-eval91.6%
times-frac91.6%
*-lft-identity91.6%
neg-mul-191.6%
neg-sub091.6%
associate--r-91.6%
metadata-eval91.6%
Simplified91.6%
if -7.8000000000000001e-36 < y < 2.7e14Initial program 100.0%
Taylor expanded in x around inf 82.6%
Final simplification90.7%
(FPCore (x y) :precision binary64 (if (<= y -1.0) 1.0 (if (<= y -4.55e-41) (- y) (if (<= y 1.0) x 1.0))))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = 1.0;
} else if (y <= -4.55e-41) {
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 <= (-1.0d0)) then
tmp = 1.0d0
else if (y <= (-4.55d-41)) 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 <= -1.0) {
tmp = 1.0;
} else if (y <= -4.55e-41) {
tmp = -y;
} else if (y <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = 1.0 elif y <= -4.55e-41: tmp = -y elif y <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = 1.0; elseif (y <= -4.55e-41) 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 <= -1.0) tmp = 1.0; elseif (y <= -4.55e-41) tmp = -y; elseif (y <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], 1.0, If[LessEqual[y, -4.55e-41], (-y), If[LessEqual[y, 1.0], x, 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -4.55 \cdot 10^{-41}:\\
\;\;\;\;-y\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 100.0%
Taylor expanded in y around inf 71.8%
if -1 < y < -4.55000000000000015e-41Initial program 99.9%
Taylor expanded in x around 0 90.8%
metadata-eval90.8%
times-frac90.8%
*-lft-identity90.8%
neg-mul-190.8%
neg-sub090.8%
associate--r-90.8%
metadata-eval90.8%
Simplified90.8%
Taylor expanded in y around 0 79.7%
neg-mul-179.7%
Simplified79.7%
if -4.55000000000000015e-41 < y < 1Initial program 100.0%
Taylor expanded in y around 0 82.2%
Final simplification77.1%
(FPCore (x y) :precision binary64 (if (<= y -6.2e+15) 1.0 (if (<= y 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -6.2e+15) {
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 <= (-6.2d+15)) 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 <= -6.2e+15) {
tmp = 1.0;
} else if (y <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6.2e+15: tmp = 1.0 elif y <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -6.2e+15) 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 <= -6.2e+15) tmp = 1.0; elseif (y <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -6.2e+15], 1.0, If[LessEqual[y, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+15}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -6.2e15 or 1 < y Initial program 100.0%
Taylor expanded in y around inf 74.5%
if -6.2e15 < y < 1Initial program 100.0%
Taylor expanded in y around 0 73.9%
Final simplification74.2%
(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%
Taylor expanded in y around inf 36.3%
Final simplification36.3%
herbie shell --seed 2024026
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, C"
:precision binary64
(/ (- x y) (- 1.0 y)))