
(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
double code(double x, double y, double z, double t) {
return x - (log(((1.0 - y) + (y * exp(z)))) / t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x - (log(((1.0d0 - y) + (y * exp(z)))) / t)
end function
public static double code(double x, double y, double z, double t) {
return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
def code(x, y, z, t): return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
function code(x, y, z, t) return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t)) end
function tmp = code(x, y, z, t) tmp = x - (log(((1.0 - y) + (y * exp(z)))) / t); end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
double code(double x, double y, double z, double t) {
return x - (log(((1.0 - y) + (y * exp(z)))) / t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x - (log(((1.0d0 - y) + (y * exp(z)))) / t)
end function
public static double code(double x, double y, double z, double t) {
return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
def code(x, y, z, t): return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
function code(x, y, z, t) return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t)) end
function tmp = code(x, y, z, t) tmp = x - (log(((1.0 - y) + (y * exp(z)))) / t); end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (- x (/ (log1p (* y (expm1 z))) t)))
double code(double x, double y, double z, double t) {
return x - (log1p((y * expm1(z))) / t);
}
public static double code(double x, double y, double z, double t) {
return x - (Math.log1p((y * Math.expm1(z))) / t);
}
def code(x, y, z, t): return x - (math.log1p((y * math.expm1(z))) / t)
function code(x, y, z, t) return Float64(x - Float64(log1p(Float64(y * expm1(z))) / t)) end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}
\end{array}
Initial program 61.4%
associate-+l-76.3%
sub-neg76.3%
log1p-def82.4%
neg-sub082.4%
associate-+l-82.4%
neg-sub082.4%
neg-mul-182.4%
*-commutative82.4%
distribute-rgt-out82.3%
+-commutative82.3%
metadata-eval82.3%
sub-neg82.3%
expm1-def98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (+ (/ t (* y (expm1 z))) (* t 0.5)))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t / (y * expm1(z))) + (t * 0.5)));
}
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t / (y * Math.expm1(z))) + (t * 0.5)));
}
def code(x, y, z, t): return x + (-1.0 / ((t / (y * math.expm1(z))) + (t * 0.5)))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(Float64(t / Float64(y * expm1(z))) + Float64(t * 0.5)))) end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(N[(t / N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{\frac{t}{y \cdot \mathsf{expm1}\left(z\right)} + t \cdot 0.5}
\end{array}
Initial program 61.4%
associate-+l-76.3%
sub-neg76.3%
log1p-def82.4%
neg-sub082.4%
associate-+l-82.4%
neg-sub082.4%
neg-mul-182.4%
*-commutative82.4%
distribute-rgt-out82.3%
+-commutative82.3%
metadata-eval82.3%
sub-neg82.3%
expm1-def98.4%
Simplified98.4%
clear-num98.3%
inv-pow98.3%
Applied egg-rr98.3%
unpow-198.3%
Applied egg-rr98.3%
Taylor expanded in y around 0 78.0%
expm1-def89.9%
*-commutative89.9%
Simplified89.9%
Final simplification89.9%
(FPCore (x y z t) :precision binary64 (if (<= y -8.7e+15) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (- x (* y (/ (expm1 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -8.7e+15) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (y * (expm1(z) / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -8.7e+15) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (y * (Math.expm1(z) / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -8.7e+15: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) else: tmp = x - (y * (math.expm1(z) / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -8.7e+15) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); else tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -8.7e+15], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.7 \cdot 10^{+15}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -8.7e15Initial program 39.7%
associate-+l-76.3%
sub-neg76.3%
log1p-def76.3%
neg-sub076.3%
associate-+l-76.3%
neg-sub076.3%
neg-mul-176.3%
*-commutative76.3%
distribute-rgt-out76.3%
+-commutative76.3%
metadata-eval76.3%
sub-neg76.3%
expm1-def99.7%
Simplified99.7%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow-199.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 57.2%
expm1-def65.0%
*-commutative65.0%
Simplified65.0%
Taylor expanded in z around 0 65.0%
*-commutative65.0%
Simplified65.0%
if -8.7e15 < y Initial program 66.6%
associate-+l-76.3%
sub-neg76.3%
log1p-def83.8%
neg-sub083.8%
associate-+l-83.8%
neg-sub083.8%
neg-mul-183.8%
*-commutative83.8%
distribute-rgt-out83.8%
+-commutative83.8%
metadata-eval83.8%
sub-neg83.8%
expm1-def98.0%
Simplified98.0%
Taylor expanded in y around 0 83.6%
associate-/l*83.0%
associate-/r/83.6%
expm1-def96.7%
Simplified96.7%
Final simplification90.6%
(FPCore (x y z t) :precision binary64 (if (<= z 3.3e-299) (+ x (/ -1.0 (- (+ (* t 0.5) (/ t (* y z))) (* 0.5 (/ t y))))) (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.3e-299) {
tmp = x + (-1.0 / (((t * 0.5) + (t / (y * z))) - (0.5 * (t / y))));
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= 3.3d-299) then
tmp = x + ((-1.0d0) / (((t * 0.5d0) + (t / (y * z))) - (0.5d0 * (t / y))))
else
tmp = x - (y / (t / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.3e-299) {
tmp = x + (-1.0 / (((t * 0.5) + (t / (y * z))) - (0.5 * (t / y))));
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 3.3e-299: tmp = x + (-1.0 / (((t * 0.5) + (t / (y * z))) - (0.5 * (t / y)))) else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 3.3e-299) tmp = Float64(x + Float64(-1.0 / Float64(Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))) - Float64(0.5 * Float64(t / y))))); else tmp = Float64(x - Float64(y / Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 3.3e-299) tmp = x + (-1.0 / (((t * 0.5) + (t / (y * z))) - (0.5 * (t / y)))); else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 3.3e-299], N[(x + N[(-1.0 / N[(N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.3 \cdot 10^{-299}:\\
\;\;\;\;x + \frac{-1}{\left(t \cdot 0.5 + \frac{t}{y \cdot z}\right) - 0.5 \cdot \frac{t}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < 3.3000000000000002e-299Initial program 65.7%
associate-+l-76.2%
sub-neg76.2%
log1p-def85.4%
neg-sub085.4%
associate-+l-85.4%
neg-sub085.4%
neg-mul-185.4%
*-commutative85.4%
distribute-rgt-out85.4%
+-commutative85.4%
metadata-eval85.4%
sub-neg85.4%
expm1-def99.2%
Simplified99.2%
clear-num99.1%
inv-pow99.1%
Applied egg-rr99.1%
unpow-199.1%
Applied egg-rr99.1%
Taylor expanded in y around 0 79.5%
expm1-def88.1%
*-commutative88.1%
Simplified88.1%
Taylor expanded in z around 0 80.6%
if 3.3000000000000002e-299 < z Initial program 54.4%
associate-+l-76.5%
sub-neg76.5%
log1p-def77.3%
neg-sub077.3%
associate-+l-77.3%
neg-sub077.3%
neg-mul-177.3%
*-commutative77.3%
distribute-rgt-out77.3%
+-commutative77.3%
metadata-eval77.3%
sub-neg77.3%
expm1-def97.0%
Simplified97.0%
Taylor expanded in z around 0 91.0%
associate-/l*94.4%
Simplified94.4%
Final simplification85.7%
(FPCore (x y z t) :precision binary64 (if (<= t -2.4e-260) x (if (<= t 2.15e-240) (* (/ z t) (- y)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -2.4e-260) {
tmp = x;
} else if (t <= 2.15e-240) {
tmp = (z / t) * -y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-2.4d-260)) then
tmp = x
else if (t <= 2.15d-240) then
tmp = (z / t) * -y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -2.4e-260) {
tmp = x;
} else if (t <= 2.15e-240) {
tmp = (z / t) * -y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -2.4e-260: tmp = x elif t <= 2.15e-240: tmp = (z / t) * -y else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -2.4e-260) tmp = x; elseif (t <= 2.15e-240) tmp = Float64(Float64(z / t) * Float64(-y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -2.4e-260) tmp = x; elseif (t <= 2.15e-240) tmp = (z / t) * -y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -2.4e-260], x, If[LessEqual[t, 2.15e-240], N[(N[(z / t), $MachinePrecision] * (-y)), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.4 \cdot 10^{-260}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 2.15 \cdot 10^{-240}:\\
\;\;\;\;\frac{z}{t} \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -2.4000000000000001e-260 or 2.15000000000000007e-240 < t Initial program 65.5%
associate-+l-82.6%
sub-neg82.6%
log1p-def88.3%
neg-sub088.3%
associate-+l-88.3%
neg-sub088.3%
neg-mul-188.3%
*-commutative88.3%
distribute-rgt-out88.2%
+-commutative88.2%
metadata-eval88.2%
sub-neg88.2%
expm1-def98.8%
Simplified98.8%
Taylor expanded in x around inf 78.0%
if -2.4000000000000001e-260 < t < 2.15000000000000007e-240Initial program 33.8%
associate-+l-33.9%
sub-neg33.9%
log1p-def42.6%
neg-sub042.6%
associate-+l-42.6%
neg-sub042.6%
neg-mul-142.6%
*-commutative42.6%
distribute-rgt-out42.6%
+-commutative42.6%
metadata-eval42.6%
sub-neg42.6%
expm1-def95.5%
Simplified95.5%
Taylor expanded in y around 0 39.8%
expm1-def85.0%
Simplified85.0%
*-commutative85.0%
expm1-log1p-u85.0%
expm1-udef32.2%
log1p-udef32.2%
add-exp-log32.2%
*-commutative32.2%
+-commutative32.2%
*-commutative32.2%
Applied egg-rr32.2%
Taylor expanded in x around 0 17.4%
associate-*r/17.4%
*-commutative17.4%
expm1-def62.6%
neg-mul-162.6%
expm1-def17.4%
*-commutative17.4%
distribute-rgt-neg-in17.4%
expm1-def62.6%
Simplified62.6%
Taylor expanded in z around 0 54.0%
mul-1-neg54.0%
associate-*r/56.9%
distribute-lft-neg-in56.9%
Simplified56.9%
Final simplification75.3%
(FPCore (x y z t) :precision binary64 (if (<= z -8.4e+61) x (- x (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.4e+61) {
tmp = x;
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-8.4d+61)) then
tmp = x
else
tmp = x - (z * (y / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.4e+61) {
tmp = x;
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.4e+61: tmp = x else: tmp = x - (z * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.4e+61) tmp = x; else tmp = Float64(x - Float64(z * Float64(y / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -8.4e+61) tmp = x; else tmp = x - (z * (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.4e+61], x, N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.4 \cdot 10^{+61}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -8.4000000000000004e61Initial program 81.2%
associate-+l-81.2%
sub-neg81.2%
log1p-def99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
neg-mul-199.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
metadata-eval99.9%
sub-neg99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 65.0%
if -8.4000000000000004e61 < z Initial program 55.0%
associate-+l-74.7%
sub-neg74.7%
log1p-def76.7%
neg-sub076.7%
associate-+l-76.7%
neg-sub076.7%
neg-mul-176.7%
*-commutative76.7%
distribute-rgt-out76.6%
+-commutative76.6%
metadata-eval76.6%
sub-neg76.6%
expm1-def97.9%
Simplified97.9%
Taylor expanded in z around 0 88.0%
associate-/l*90.3%
associate-/r/86.1%
Simplified86.1%
Final simplification80.9%
(FPCore (x y z t) :precision binary64 (if (<= z -8.4e+61) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.4e+61) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-8.4d+61)) then
tmp = x
else
tmp = x - (y * (z / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.4e+61) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.4e+61: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.4e+61) tmp = x; else tmp = Float64(x - Float64(y * Float64(z / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -8.4e+61) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.4e+61], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.4 \cdot 10^{+61}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -8.4000000000000004e61Initial program 81.2%
associate-+l-81.2%
sub-neg81.2%
log1p-def99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
neg-mul-199.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
metadata-eval99.9%
sub-neg99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 65.0%
if -8.4000000000000004e61 < z Initial program 55.0%
associate-+l-74.7%
sub-neg74.7%
log1p-def76.7%
neg-sub076.7%
associate-+l-76.7%
neg-sub076.7%
neg-mul-176.7%
*-commutative76.7%
distribute-rgt-out76.6%
+-commutative76.6%
metadata-eval76.6%
sub-neg76.6%
expm1-def97.9%
Simplified97.9%
Taylor expanded in z around 0 88.0%
*-commutative88.0%
Simplified88.0%
associate-/l*86.6%
associate-/r/89.8%
Applied egg-rr89.8%
Final simplification83.7%
(FPCore (x y z t) :precision binary64 (if (<= z -8.4e+61) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.4e+61) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-8.4d+61)) then
tmp = x
else
tmp = x - (y / (t / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.4e+61) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.4e+61: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.4e+61) tmp = x; else tmp = Float64(x - Float64(y / Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -8.4e+61) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.4e+61], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.4 \cdot 10^{+61}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -8.4000000000000004e61Initial program 81.2%
associate-+l-81.2%
sub-neg81.2%
log1p-def99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
neg-mul-199.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
metadata-eval99.9%
sub-neg99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 65.0%
if -8.4000000000000004e61 < z Initial program 55.0%
associate-+l-74.7%
sub-neg74.7%
log1p-def76.7%
neg-sub076.7%
associate-+l-76.7%
neg-sub076.7%
neg-mul-176.7%
*-commutative76.7%
distribute-rgt-out76.6%
+-commutative76.6%
metadata-eval76.6%
sub-neg76.6%
expm1-def97.9%
Simplified97.9%
Taylor expanded in z around 0 88.0%
associate-/l*90.3%
Simplified90.3%
Final simplification84.1%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 61.4%
associate-+l-76.3%
sub-neg76.3%
log1p-def82.4%
neg-sub082.4%
associate-+l-82.4%
neg-sub082.4%
neg-mul-182.4%
*-commutative82.4%
distribute-rgt-out82.3%
+-commutative82.3%
metadata-eval82.3%
sub-neg82.3%
expm1-def98.4%
Simplified98.4%
Taylor expanded in x around inf 71.2%
Final simplification71.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (- 0.5) (* y t))))
(if (< z -2.8874623088207947e+119)
(- (- x (/ t_1 (* z z))) (* t_1 (/ (/ 2.0 z) (* z z))))
(- x (/ (log (+ 1.0 (* z y))) t)))))
double code(double x, double y, double z, double t) {
double t_1 = -0.5 / (y * t);
double tmp;
if (z < -2.8874623088207947e+119) {
tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z)));
} else {
tmp = x - (log((1.0 + (z * y))) / t);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = -0.5d0 / (y * t)
if (z < (-2.8874623088207947d+119)) then
tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0d0 / z) / (z * z)))
else
tmp = x - (log((1.0d0 + (z * y))) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = -0.5 / (y * t);
double tmp;
if (z < -2.8874623088207947e+119) {
tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z)));
} else {
tmp = x - (Math.log((1.0 + (z * y))) / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = -0.5 / (y * t) tmp = 0 if z < -2.8874623088207947e+119: tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z))) else: tmp = x - (math.log((1.0 + (z * y))) / t) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(-0.5) / Float64(y * t)) tmp = 0.0 if (z < -2.8874623088207947e+119) tmp = Float64(Float64(x - Float64(t_1 / Float64(z * z))) - Float64(t_1 * Float64(Float64(2.0 / z) / Float64(z * z)))); else tmp = Float64(x - Float64(log(Float64(1.0 + Float64(z * y))) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -0.5 / (y * t); tmp = 0.0; if (z < -2.8874623088207947e+119) tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z))); else tmp = x - (log((1.0 + (z * y))) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-0.5) / N[(y * t), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -2.8874623088207947e+119], N[(N[(x - N[(t$95$1 / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[(N[(2.0 / z), $MachinePrecision] / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{-0.5}{y \cdot t}\\
\mathbf{if}\;z < -2.8874623088207947 \cdot 10^{+119}:\\
\;\;\;\;\left(x - \frac{t_1}{z \cdot z}\right) - t_1 \cdot \frac{\frac{2}{z}}{z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\
\end{array}
\end{array}
herbie shell --seed 2023192
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:precision binary64
:herbie-target
(if (< z -2.8874623088207947e+119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2.0 z) (* z z)))) (- x (/ (log (+ 1.0 (* z y))) t)))
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))