
(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 11 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 58.9%
sub-neg58.9%
associate-+l+72.1%
cancel-sign-sub72.1%
log1p-define77.7%
cancel-sign-sub77.7%
+-commutative77.7%
unsub-neg77.7%
*-rgt-identity77.7%
distribute-lft-out--77.7%
expm1-define98.1%
Simplified98.1%
Final simplification98.1%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (* t (- (- -0.5) (/ (/ -1.0 y) (expm1 z)))))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / (t * (-(-0.5) - ((-1.0 / y) / expm1(z)))));
}
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / (t * (-(-0.5) - ((-1.0 / y) / Math.expm1(z)))));
}
def code(x, y, z, t): return x + (-1.0 / (t * (-(-0.5) - ((-1.0 / y) / math.expm1(z)))))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(t * Float64(Float64(-(-0.5)) - Float64(Float64(-1.0 / y) / expm1(z)))))) end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(t * N[((--0.5) - N[(N[(-1.0 / y), $MachinePrecision] / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{t \cdot \left(\left(--0.5\right) - \frac{\frac{-1}{y}}{\mathsf{expm1}\left(z\right)}\right)}
\end{array}
Initial program 58.9%
sub-neg58.9%
associate-+l+72.1%
cancel-sign-sub72.1%
log1p-define77.7%
cancel-sign-sub77.7%
+-commutative77.7%
unsub-neg77.7%
*-rgt-identity77.7%
distribute-lft-out--77.7%
expm1-define98.1%
Simplified98.1%
clear-num98.1%
inv-pow98.1%
Applied egg-rr98.1%
unpow-198.1%
Applied egg-rr98.1%
frac-2neg98.1%
div-inv97.6%
add-sqr-sqrt43.7%
sqrt-unprod71.4%
sqr-neg71.4%
sqrt-unprod48.7%
add-sqr-sqrt65.8%
frac-2neg65.8%
metadata-eval65.8%
add-sqr-sqrt35.9%
sqrt-unprod85.3%
sqr-neg85.3%
sqrt-unprod72.6%
add-sqr-sqrt97.6%
Applied egg-rr97.6%
Taylor expanded in y around 0 72.7%
distribute-neg-in72.7%
metadata-eval72.7%
distribute-neg-frac72.7%
metadata-eval72.7%
associate-/r*72.7%
expm1-define87.8%
Simplified87.8%
Final simplification87.8%
(FPCore (x y z t) :precision binary64 (if (<= y 3.5e+147) (- x (* y (/ (expm1 z) t))) (- x (/ (log (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.5e+147) {
tmp = x - (y * (expm1(z) / t));
} else {
tmp = x - (log((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.5e+147) {
tmp = x - (y * (Math.expm1(z) / t));
} else {
tmp = x - (Math.log((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.5e+147: tmp = x - (y * (math.expm1(z) / t)) else: tmp = x - (math.log((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.5e+147) tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); else tmp = Float64(x - Float64(log(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.5e+147], N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(y * z), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{+147}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if y < 3.49999999999999975e147Initial program 63.5%
sub-neg63.5%
associate-+l+76.0%
cancel-sign-sub76.0%
log1p-define82.0%
cancel-sign-sub82.0%
+-commutative82.0%
unsub-neg82.0%
*-rgt-identity82.0%
distribute-lft-out--82.1%
expm1-define98.8%
Simplified98.8%
clear-num98.8%
inv-pow98.8%
Applied egg-rr98.8%
unpow-198.8%
Applied egg-rr98.8%
Taylor expanded in y around 0 75.5%
expm1-define89.1%
associate-*r/89.8%
Simplified89.8%
if 3.49999999999999975e147 < y Initial program 5.1%
sub-neg5.1%
associate-+l+25.9%
cancel-sign-sub25.9%
log1p-define25.9%
cancel-sign-sub25.9%
+-commutative25.9%
unsub-neg25.9%
*-rgt-identity25.9%
distribute-lft-out--25.7%
expm1-define90.2%
Simplified90.2%
Taylor expanded in y around inf 9.7%
mul-1-neg9.7%
expm1-define70.0%
log-rec70.0%
Simplified70.0%
Taylor expanded in z around 0 66.0%
+-commutative66.0%
Simplified66.0%
Taylor expanded in z around 0 66.0%
log-prod66.2%
Simplified66.2%
Final simplification88.0%
(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 58.9%
sub-neg58.9%
associate-+l+72.1%
cancel-sign-sub72.1%
log1p-define77.7%
cancel-sign-sub77.7%
+-commutative77.7%
unsub-neg77.7%
*-rgt-identity77.7%
distribute-lft-out--77.7%
expm1-define98.1%
Simplified98.1%
clear-num98.1%
inv-pow98.1%
Applied egg-rr98.1%
unpow-198.1%
Applied egg-rr98.1%
Taylor expanded in y around 0 71.4%
expm1-define85.9%
associate-*r/86.3%
Simplified86.3%
Final simplification86.3%
(FPCore (x y z t) :precision binary64 (if (<= t -1.45e-215) x (if (<= t 2.15e-150) (* z (/ (- y) t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.45e-215) {
tmp = x;
} else if (t <= 2.15e-150) {
tmp = z * (-y / 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 <= (-1.45d-215)) then
tmp = x
else if (t <= 2.15d-150) then
tmp = z * (-y / 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 <= -1.45e-215) {
tmp = x;
} else if (t <= 2.15e-150) {
tmp = z * (-y / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.45e-215: tmp = x elif t <= 2.15e-150: tmp = z * (-y / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.45e-215) tmp = x; elseif (t <= 2.15e-150) tmp = Float64(z * Float64(Float64(-y) / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.45e-215) tmp = x; elseif (t <= 2.15e-150) tmp = z * (-y / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.45e-215], x, If[LessEqual[t, 2.15e-150], N[(z * N[((-y) / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.45 \cdot 10^{-215}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 2.15 \cdot 10^{-150}:\\
\;\;\;\;z \cdot \frac{-y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -1.45e-215 or 2.15000000000000002e-150 < t Initial program 65.6%
sub-neg65.6%
associate-+l+82.1%
cancel-sign-sub82.1%
log1p-define86.5%
cancel-sign-sub86.5%
+-commutative86.5%
unsub-neg86.5%
*-rgt-identity86.5%
distribute-lft-out--86.5%
expm1-define99.1%
Simplified99.1%
Taylor expanded in x around inf 79.4%
if -1.45e-215 < t < 2.15000000000000002e-150Initial program 32.7%
sub-neg32.7%
associate-+l+32.8%
cancel-sign-sub32.8%
log1p-define43.0%
cancel-sign-sub43.0%
+-commutative43.0%
unsub-neg43.0%
*-rgt-identity43.0%
distribute-lft-out--43.1%
expm1-define94.2%
Simplified94.2%
Taylor expanded in x around 0 19.5%
associate-*r/19.5%
log1p-define30.0%
expm1-define79.9%
neg-mul-179.9%
Simplified79.9%
Taylor expanded in z around 0 44.8%
mul-1-neg44.8%
associate-/l*48.5%
Simplified48.5%
associate-/r/35.2%
Applied egg-rr35.2%
Final simplification70.4%
(FPCore (x y z t) :precision binary64 (if (<= t -1.06e-213) x (if (<= t 1.06e-148) (/ (- y) (/ t z)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.06e-213) {
tmp = x;
} else if (t <= 1.06e-148) {
tmp = -y / (t / z);
} 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 <= (-1.06d-213)) then
tmp = x
else if (t <= 1.06d-148) then
tmp = -y / (t / z)
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 <= -1.06e-213) {
tmp = x;
} else if (t <= 1.06e-148) {
tmp = -y / (t / z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.06e-213: tmp = x elif t <= 1.06e-148: tmp = -y / (t / z) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.06e-213) tmp = x; elseif (t <= 1.06e-148) tmp = Float64(Float64(-y) / Float64(t / z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.06e-213) tmp = x; elseif (t <= 1.06e-148) tmp = -y / (t / z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.06e-213], x, If[LessEqual[t, 1.06e-148], N[((-y) / N[(t / z), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.06 \cdot 10^{-213}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 1.06 \cdot 10^{-148}:\\
\;\;\;\;\frac{-y}{\frac{t}{z}}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -1.06000000000000001e-213 or 1.06000000000000003e-148 < t Initial program 65.6%
sub-neg65.6%
associate-+l+82.1%
cancel-sign-sub82.1%
log1p-define86.5%
cancel-sign-sub86.5%
+-commutative86.5%
unsub-neg86.5%
*-rgt-identity86.5%
distribute-lft-out--86.5%
expm1-define99.1%
Simplified99.1%
Taylor expanded in x around inf 79.4%
if -1.06000000000000001e-213 < t < 1.06000000000000003e-148Initial program 32.7%
sub-neg32.7%
associate-+l+32.8%
cancel-sign-sub32.8%
log1p-define43.0%
cancel-sign-sub43.0%
+-commutative43.0%
unsub-neg43.0%
*-rgt-identity43.0%
distribute-lft-out--43.1%
expm1-define94.2%
Simplified94.2%
Taylor expanded in x around 0 19.5%
associate-*r/19.5%
log1p-define30.0%
expm1-define79.9%
neg-mul-179.9%
Simplified79.9%
Taylor expanded in z around 0 44.8%
mul-1-neg44.8%
associate-/l*48.5%
Simplified48.5%
Final simplification73.2%
(FPCore (x y z t) :precision binary64 (if (<= t -8e-215) x (if (<= t 2.5e-150) (* y (- (/ z t))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -8e-215) {
tmp = x;
} else if (t <= 2.5e-150) {
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 <= (-8d-215)) then
tmp = x
else if (t <= 2.5d-150) 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 <= -8e-215) {
tmp = x;
} else if (t <= 2.5e-150) {
tmp = y * -(z / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -8e-215: tmp = x elif t <= 2.5e-150: tmp = y * -(z / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -8e-215) tmp = x; elseif (t <= 2.5e-150) tmp = Float64(y * Float64(-Float64(z / t))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -8e-215) tmp = x; elseif (t <= 2.5e-150) tmp = y * -(z / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -8e-215], x, If[LessEqual[t, 2.5e-150], N[(y * (-N[(z / t), $MachinePrecision])), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -8 \cdot 10^{-215}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 2.5 \cdot 10^{-150}:\\
\;\;\;\;y \cdot \left(-\frac{z}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -8.00000000000000033e-215 or 2.49999999999999995e-150 < t Initial program 65.6%
sub-neg65.6%
associate-+l+82.1%
cancel-sign-sub82.1%
log1p-define86.5%
cancel-sign-sub86.5%
+-commutative86.5%
unsub-neg86.5%
*-rgt-identity86.5%
distribute-lft-out--86.5%
expm1-define99.1%
Simplified99.1%
Taylor expanded in x around inf 79.4%
if -8.00000000000000033e-215 < t < 2.49999999999999995e-150Initial program 32.7%
sub-neg32.7%
associate-+l+32.8%
cancel-sign-sub32.8%
log1p-define43.0%
cancel-sign-sub43.0%
+-commutative43.0%
unsub-neg43.0%
*-rgt-identity43.0%
distribute-lft-out--43.1%
expm1-define94.2%
Simplified94.2%
Taylor expanded in x around 0 19.5%
associate-*r/19.5%
log1p-define30.0%
expm1-define79.9%
neg-mul-179.9%
Simplified79.9%
Taylor expanded in z around 0 44.8%
mul-1-neg44.8%
associate-*r/48.6%
*-commutative48.6%
distribute-rgt-neg-in48.6%
Simplified48.6%
Final simplification73.2%
(FPCore (x y z t) :precision binary64 (if (<= z -7.6e-11) x (- x (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.6e-11) {
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 <= (-7.6d-11)) 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 <= -7.6e-11) {
tmp = x;
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.6e-11: tmp = x else: tmp = x - (z * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.6e-11) 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 <= -7.6e-11) tmp = x; else tmp = x - (z * (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.6e-11], x, N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.6 \cdot 10^{-11}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -7.5999999999999996e-11Initial program 79.0%
sub-neg79.0%
associate-+l+79.0%
cancel-sign-sub79.0%
log1p-define99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 58.8%
if -7.5999999999999996e-11 < z Initial program 52.7%
sub-neg52.7%
associate-+l+70.0%
cancel-sign-sub70.0%
log1p-define70.7%
cancel-sign-sub70.7%
+-commutative70.7%
unsub-neg70.7%
*-rgt-identity70.7%
distribute-lft-out--70.7%
expm1-define97.6%
Simplified97.6%
Taylor expanded in z around 0 88.2%
associate-/l*88.1%
associate-/r/85.4%
Simplified85.4%
Final simplification79.0%
(FPCore (x y z t) :precision binary64 (if (<= z -7.2e-11) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.2e-11) {
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 <= (-7.2d-11)) 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 <= -7.2e-11) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.2e-11: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.2e-11) 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 <= -7.2e-11) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.2e-11], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{-11}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -7.19999999999999969e-11Initial program 79.0%
sub-neg79.0%
associate-+l+79.0%
cancel-sign-sub79.0%
log1p-define99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 58.8%
if -7.19999999999999969e-11 < z Initial program 52.7%
sub-neg52.7%
associate-+l+70.0%
cancel-sign-sub70.0%
log1p-define70.7%
cancel-sign-sub70.7%
+-commutative70.7%
unsub-neg70.7%
*-rgt-identity70.7%
distribute-lft-out--70.7%
expm1-define97.6%
Simplified97.6%
Taylor expanded in z around 0 88.2%
associate-/l*88.1%
Simplified88.1%
Final simplification81.1%
(FPCore (x y z t) :precision binary64 (if (<= z -7.6e-11) x (- x (/ (* y z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.6e-11) {
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 <= (-7.6d-11)) 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 <= -7.6e-11) {
tmp = x;
} else {
tmp = x - ((y * z) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.6e-11: tmp = x else: tmp = x - ((y * z) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.6e-11) tmp = x; else tmp = Float64(x - Float64(Float64(y * z) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -7.6e-11) tmp = x; else tmp = x - ((y * z) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.6e-11], x, N[(x - N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.6 \cdot 10^{-11}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot z}{t}\\
\end{array}
\end{array}
if z < -7.5999999999999996e-11Initial program 79.0%
sub-neg79.0%
associate-+l+79.0%
cancel-sign-sub79.0%
log1p-define99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 58.8%
if -7.5999999999999996e-11 < z Initial program 52.7%
sub-neg52.7%
associate-+l+70.0%
cancel-sign-sub70.0%
log1p-define70.7%
cancel-sign-sub70.7%
+-commutative70.7%
unsub-neg70.7%
*-rgt-identity70.7%
distribute-lft-out--70.7%
expm1-define97.6%
Simplified97.6%
Taylor expanded in z around 0 88.2%
Final simplification81.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 58.9%
sub-neg58.9%
associate-+l+72.1%
cancel-sign-sub72.1%
log1p-define77.7%
cancel-sign-sub77.7%
+-commutative77.7%
unsub-neg77.7%
*-rgt-identity77.7%
distribute-lft-out--77.7%
expm1-define98.1%
Simplified98.1%
Taylor expanded in x around inf 66.5%
Final simplification66.5%
(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 2024034
(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)))