
(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.9%
associate-+l-81.9%
sub-neg81.9%
log1p-define86.8%
neg-sub086.8%
associate-+l-86.8%
neg-sub086.8%
+-commutative86.8%
unsub-neg86.8%
*-rgt-identity86.8%
distribute-lft-out--86.8%
expm1-define98.7%
Simplified98.7%
(FPCore (x y z t)
:precision binary64
(if (<= z -50000000000000.0)
(* x (+ 1.0 (/ 1.0 (* t (/ (- (/ x (- 1.0 (exp z))) (* 0.5 (* x y))) y)))))
(-
x
(/ (log1p (* z (+ y (* y (* z (+ 0.5 (* z 0.16666666666666666))))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -50000000000000.0) {
tmp = x * (1.0 + (1.0 / (t * (((x / (1.0 - exp(z))) - (0.5 * (x * y))) / y))));
} else {
tmp = x - (log1p((z * (y + (y * (z * (0.5 + (z * 0.16666666666666666))))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -50000000000000.0) {
tmp = x * (1.0 + (1.0 / (t * (((x / (1.0 - Math.exp(z))) - (0.5 * (x * y))) / y))));
} else {
tmp = x - (Math.log1p((z * (y + (y * (z * (0.5 + (z * 0.16666666666666666))))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -50000000000000.0: tmp = x * (1.0 + (1.0 / (t * (((x / (1.0 - math.exp(z))) - (0.5 * (x * y))) / y)))) else: tmp = x - (math.log1p((z * (y + (y * (z * (0.5 + (z * 0.16666666666666666))))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -50000000000000.0) tmp = Float64(x * Float64(1.0 + Float64(1.0 / Float64(t * Float64(Float64(Float64(x / Float64(1.0 - exp(z))) - Float64(0.5 * Float64(x * y))) / y))))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(y * Float64(z * Float64(0.5 + Float64(z * 0.16666666666666666))))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -50000000000000.0], N[(x * N[(1.0 + N[(1.0 / N[(t * N[(N[(N[(x / N[(1.0 - N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(y * N[(z * N[(0.5 + N[(z * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -50000000000000:\\
\;\;\;\;x \cdot \left(1 + \frac{1}{t \cdot \frac{\frac{x}{1 - e^{z}} - 0.5 \cdot \left(x \cdot y\right)}{y}}\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + y \cdot \left(z \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\right)\right)\right)}{t}\\
\end{array}
\end{array}
if z < -5e13Initial program 83.5%
associate-+l-83.5%
sub-neg83.5%
log1p-define100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
*-rgt-identity100.0%
distribute-lft-out--100.0%
expm1-define100.0%
Simplified100.0%
Taylor expanded in x around inf 80.8%
mul-1-neg80.8%
unsub-neg80.8%
log1p-define90.7%
expm1-define90.7%
Simplified90.7%
clear-num90.6%
inv-pow90.6%
*-un-lft-identity90.6%
times-frac93.4%
/-rgt-identity93.4%
Applied egg-rr93.4%
unpow-193.4%
Simplified93.4%
Taylor expanded in y around 0 84.1%
if -5e13 < z Initial program 53.3%
associate-+l-81.2%
sub-neg81.2%
log1p-define81.6%
neg-sub081.6%
associate-+l-81.6%
neg-sub081.6%
+-commutative81.6%
unsub-neg81.6%
*-rgt-identity81.6%
distribute-lft-out--81.6%
expm1-define98.2%
Simplified98.2%
Taylor expanded in z around 0 97.8%
Taylor expanded in t around 0 85.5%
log1p-define97.8%
distribute-rgt-in97.8%
*-commutative97.8%
associate-*r*97.8%
*-commutative97.8%
associate-*r*97.8%
distribute-rgt-in97.8%
+-commutative97.8%
associate-*r*97.8%
*-commutative97.8%
Simplified97.8%
Final simplification93.9%
(FPCore (x y z t)
:precision binary64
(if (<= z -50000000000000.0)
(- x (* (expm1 z) (/ y t)))
(-
x
(/ (log1p (* z (+ y (* y (* z (+ 0.5 (* z 0.16666666666666666))))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -50000000000000.0) {
tmp = x - (expm1(z) * (y / t));
} else {
tmp = x - (log1p((z * (y + (y * (z * (0.5 + (z * 0.16666666666666666))))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -50000000000000.0) {
tmp = x - (Math.expm1(z) * (y / t));
} else {
tmp = x - (Math.log1p((z * (y + (y * (z * (0.5 + (z * 0.16666666666666666))))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -50000000000000.0: tmp = x - (math.expm1(z) * (y / t)) else: tmp = x - (math.log1p((z * (y + (y * (z * (0.5 + (z * 0.16666666666666666))))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -50000000000000.0) tmp = Float64(x - Float64(expm1(z) * Float64(y / t))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(y * Float64(z * Float64(0.5 + Float64(z * 0.16666666666666666))))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -50000000000000.0], N[(x - N[(N[(Exp[z] - 1), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(y * N[(z * N[(0.5 + N[(z * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -50000000000000:\\
\;\;\;\;x - \mathsf{expm1}\left(z\right) \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + y \cdot \left(z \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\right)\right)\right)}{t}\\
\end{array}
\end{array}
if z < -5e13Initial program 83.5%
associate-+l-83.5%
sub-neg83.5%
log1p-define100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
*-rgt-identity100.0%
distribute-lft-out--100.0%
expm1-define100.0%
Simplified100.0%
Taylor expanded in y around 0 83.0%
associate-/l*83.0%
expm1-define83.0%
Simplified83.0%
clear-num83.0%
un-div-inv83.0%
Applied egg-rr83.0%
associate-/r/83.0%
Simplified83.0%
if -5e13 < z Initial program 53.3%
associate-+l-81.2%
sub-neg81.2%
log1p-define81.6%
neg-sub081.6%
associate-+l-81.6%
neg-sub081.6%
+-commutative81.6%
unsub-neg81.6%
*-rgt-identity81.6%
distribute-lft-out--81.6%
expm1-define98.2%
Simplified98.2%
Taylor expanded in z around 0 97.8%
Taylor expanded in t around 0 85.5%
log1p-define97.8%
distribute-rgt-in97.8%
*-commutative97.8%
associate-*r*97.8%
*-commutative97.8%
associate-*r*97.8%
distribute-rgt-in97.8%
+-commutative97.8%
associate-*r*97.8%
*-commutative97.8%
Simplified97.8%
Final simplification93.6%
(FPCore (x y z t) :precision binary64 (if (<= z -4.3e-7) (- x (* (expm1 z) (/ y t))) (- x (/ (log1p (* z (+ y (* 0.5 (* y z))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.3e-7) {
tmp = x - (expm1(z) * (y / t));
} else {
tmp = x - (log1p((z * (y + (0.5 * (y * z))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.3e-7) {
tmp = x - (Math.expm1(z) * (y / t));
} else {
tmp = x - (Math.log1p((z * (y + (0.5 * (y * z))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -4.3e-7: tmp = x - (math.expm1(z) * (y / t)) else: tmp = x - (math.log1p((z * (y + (0.5 * (y * z))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -4.3e-7) tmp = Float64(x - Float64(expm1(z) * Float64(y / t))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(0.5 * Float64(y * z))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -4.3e-7], N[(x - N[(N[(Exp[z] - 1), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(0.5 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.3 \cdot 10^{-7}:\\
\;\;\;\;x - \mathsf{expm1}\left(z\right) \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + 0.5 \cdot \left(y \cdot z\right)\right)\right)}{t}\\
\end{array}
\end{array}
if z < -4.3000000000000001e-7Initial program 83.4%
associate-+l-83.4%
sub-neg83.4%
log1p-define99.6%
neg-sub099.6%
associate-+l-99.6%
neg-sub099.6%
+-commutative99.6%
unsub-neg99.6%
*-rgt-identity99.6%
distribute-lft-out--99.6%
expm1-define99.9%
Simplified99.9%
Taylor expanded in y around 0 82.5%
associate-/l*82.5%
expm1-define82.9%
Simplified82.9%
clear-num82.9%
un-div-inv82.9%
Applied egg-rr82.9%
associate-/r/82.9%
Simplified82.9%
if -4.3000000000000001e-7 < z Initial program 52.5%
associate-+l-81.2%
sub-neg81.2%
log1p-define81.2%
neg-sub081.2%
associate-+l-81.2%
neg-sub081.2%
+-commutative81.2%
unsub-neg81.2%
*-rgt-identity81.2%
distribute-lft-out--81.2%
expm1-define98.2%
Simplified98.2%
Taylor expanded in z around 0 98.2%
Final simplification93.5%
(FPCore (x y z t) :precision binary64 (- x (* y (/ (expm1 z) t))))
double code(double x, double y, double z, double t) {
return x - (y * (expm1(z) / t));
}
public static double code(double x, double y, double z, double t) {
return x - (y * (Math.expm1(z) / t));
}
def code(x, y, z, t): return x - (y * (math.expm1(z) / t))
function code(x, y, z, t) return Float64(x - Float64(y * Float64(expm1(z) / t))) end
code[x_, y_, z_, t_] := N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}
\end{array}
Initial program 61.9%
associate-+l-81.9%
sub-neg81.9%
log1p-define86.8%
neg-sub086.8%
associate-+l-86.8%
neg-sub086.8%
+-commutative86.8%
unsub-neg86.8%
*-rgt-identity86.8%
distribute-lft-out--86.8%
expm1-define98.7%
Simplified98.7%
Taylor expanded in y around 0 81.6%
associate-/l*81.6%
expm1-define90.4%
Simplified90.4%
(FPCore (x y z t) :precision binary64 (if (<= z -0.62) x (- x (* y (* z (+ (* 0.5 (/ z t)) (/ 1.0 t)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.62) {
tmp = x;
} else {
tmp = x - (y * (z * ((0.5 * (z / t)) + (1.0 / 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 <= (-0.62d0)) then
tmp = x
else
tmp = x - (y * (z * ((0.5d0 * (z / t)) + (1.0d0 / t))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.62) {
tmp = x;
} else {
tmp = x - (y * (z * ((0.5 * (z / t)) + (1.0 / t))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -0.62: tmp = x else: tmp = x - (y * (z * ((0.5 * (z / t)) + (1.0 / t)))) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -0.62) tmp = x; else tmp = Float64(x - Float64(y * Float64(z * Float64(Float64(0.5 * Float64(z / t)) + Float64(1.0 / t))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -0.62) tmp = x; else tmp = x - (y * (z * ((0.5 * (z / t)) + (1.0 / t)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.62], x, N[(x - N[(y * N[(z * N[(N[(0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision] + N[(1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.62:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \left(z \cdot \left(0.5 \cdot \frac{z}{t} + \frac{1}{t}\right)\right)\\
\end{array}
\end{array}
if z < -0.619999999999999996Initial program 84.2%
associate-+l-84.2%
sub-neg84.2%
log1p-define100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
*-rgt-identity100.0%
distribute-lft-out--100.0%
expm1-define100.0%
Simplified100.0%
Taylor expanded in x around inf 70.5%
if -0.619999999999999996 < z Initial program 52.5%
associate-+l-80.9%
sub-neg80.9%
log1p-define81.2%
neg-sub081.2%
associate-+l-81.2%
neg-sub081.2%
+-commutative81.2%
unsub-neg81.2%
*-rgt-identity81.2%
distribute-lft-out--81.3%
expm1-define98.2%
Simplified98.2%
Taylor expanded in y around 0 81.3%
associate-/l*81.3%
expm1-define93.8%
Simplified93.8%
Taylor expanded in z around 0 93.7%
(FPCore (x y z t) :precision binary64 (if (<= t -2.25e-246) x (if (<= t 9.5e-248) (* y (/ z (- t))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -2.25e-246) {
tmp = x;
} else if (t <= 9.5e-248) {
tmp = y * (z / -t);
} 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.25d-246)) then
tmp = x
else if (t <= 9.5d-248) then
tmp = y * (z / -t)
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.25e-246) {
tmp = x;
} else if (t <= 9.5e-248) {
tmp = y * (z / -t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -2.25e-246: tmp = x elif t <= 9.5e-248: tmp = y * (z / -t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -2.25e-246) tmp = x; elseif (t <= 9.5e-248) tmp = Float64(y * Float64(z / Float64(-t))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -2.25e-246) tmp = x; elseif (t <= 9.5e-248) tmp = y * (z / -t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -2.25e-246], x, If[LessEqual[t, 9.5e-248], N[(y * N[(z / (-t)), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.25 \cdot 10^{-246}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 9.5 \cdot 10^{-248}:\\
\;\;\;\;y \cdot \frac{z}{-t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -2.25e-246 or 9.49999999999999971e-248 < t Initial program 65.7%
associate-+l-86.7%
sub-neg86.7%
log1p-define91.3%
neg-sub091.3%
associate-+l-91.3%
neg-sub091.3%
+-commutative91.3%
unsub-neg91.3%
*-rgt-identity91.3%
distribute-lft-out--91.3%
expm1-define99.4%
Simplified99.4%
Taylor expanded in x around inf 82.9%
if -2.25e-246 < t < 9.49999999999999971e-248Initial program 21.1%
associate-+l-30.0%
sub-neg30.0%
log1p-define39.0%
neg-sub039.0%
associate-+l-39.0%
neg-sub039.0%
+-commutative39.0%
unsub-neg39.0%
*-rgt-identity39.0%
distribute-lft-out--39.0%
expm1-define91.4%
Simplified91.4%
Taylor expanded in z around 0 70.3%
associate-/l*78.6%
Simplified78.6%
Taylor expanded in x around 0 49.5%
associate-/l*57.9%
associate-*r*57.9%
neg-mul-157.9%
*-commutative57.9%
Simplified57.9%
Final simplification80.8%
(FPCore (x y z t) :precision binary64 (if (<= z -4.2e+25) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.2e+25) {
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 <= (-4.2d+25)) 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 <= -4.2e+25) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -4.2e+25: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -4.2e+25) 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 <= -4.2e+25) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -4.2e+25], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+25}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -4.1999999999999998e25Initial program 84.2%
associate-+l-84.2%
sub-neg84.2%
log1p-define100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
*-rgt-identity100.0%
distribute-lft-out--100.0%
expm1-define100.0%
Simplified100.0%
Taylor expanded in x around inf 72.1%
if -4.1999999999999998e25 < z Initial program 53.5%
associate-+l-81.0%
sub-neg81.0%
log1p-define81.9%
neg-sub081.9%
associate-+l-81.9%
neg-sub081.9%
+-commutative81.9%
unsub-neg81.9%
*-rgt-identity81.9%
distribute-lft-out--81.9%
expm1-define98.2%
Simplified98.2%
Taylor expanded in z around 0 91.0%
associate-/l*92.2%
Simplified92.2%
(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.9%
associate-+l-81.9%
sub-neg81.9%
log1p-define86.8%
neg-sub086.8%
associate-+l-86.8%
neg-sub086.8%
+-commutative86.8%
unsub-neg86.8%
*-rgt-identity86.8%
distribute-lft-out--86.8%
expm1-define98.7%
Simplified98.7%
Taylor expanded in x around inf 77.6%
(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 2024091
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:precision binary64
:alt
(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)))