
(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 58.2%
remove-double-neg58.2%
neg-mul-158.2%
*-commutative58.2%
*-commutative58.2%
neg-mul-158.2%
remove-double-neg58.2%
sub-neg58.2%
associate-+l+74.6%
cancel-sign-sub74.6%
log1p-def80.9%
cancel-sign-sub80.9%
+-commutative80.9%
unsub-neg80.9%
*-rgt-identity80.9%
distribute-lft-out--80.9%
expm1-def97.3%
Simplified97.3%
Final simplification97.3%
(FPCore (x y z t) :precision binary64 (if (<= z -8.2e-31) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y (+ (exp z) -1.0)))))) (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.2e-31) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (exp(z) + -1.0)))));
} 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.2d-31)) then
tmp = x + ((-1.0d0) / ((t * 0.5d0) + (t / (y * (exp(z) + (-1.0d0))))))
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.2e-31) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (Math.exp(z) + -1.0)))));
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.2e-31: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (math.exp(z) + -1.0))))) else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.2e-31) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * Float64(exp(z) + -1.0)))))); 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.2e-31) tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (exp(z) + -1.0))))); else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.2e-31], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * N[(N[Exp[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{-31}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot \left(e^{z} + -1\right)}}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -8.1999999999999993e-31Initial program 73.6%
remove-double-neg73.6%
neg-mul-173.6%
*-commutative73.6%
*-commutative73.6%
neg-mul-173.6%
remove-double-neg73.6%
sub-neg73.6%
associate-+l+76.2%
cancel-sign-sub76.2%
log1p-def97.4%
cancel-sign-sub97.4%
+-commutative97.4%
unsub-neg97.4%
*-rgt-identity97.4%
distribute-lft-out--97.4%
expm1-def100.0%
Simplified100.0%
clear-num99.9%
associate-/r/99.9%
Applied egg-rr99.9%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 90.8%
if -8.1999999999999993e-31 < z Initial program 51.7%
remove-double-neg51.7%
neg-mul-151.7%
*-commutative51.7%
*-commutative51.7%
neg-mul-151.7%
remove-double-neg51.7%
sub-neg51.7%
associate-+l+73.9%
cancel-sign-sub73.9%
log1p-def73.9%
cancel-sign-sub73.9%
+-commutative73.9%
unsub-neg73.9%
*-rgt-identity73.9%
distribute-lft-out--73.9%
expm1-def96.2%
Simplified96.2%
Taylor expanded in z around 0 85.0%
associate-/l*87.6%
associate-/r/85.9%
Simplified85.9%
*-commutative85.9%
clear-num85.9%
un-div-inv86.5%
Applied egg-rr86.5%
associate-/r/87.6%
Simplified87.6%
Final simplification88.6%
(FPCore (x y z t) :precision binary64 (if (<= y -2.7e+109) x (+ x (/ -1.0 (/ (/ t y) (expm1 z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.7e+109) {
tmp = x;
} else {
tmp = x + (-1.0 / ((t / y) / expm1(z)));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.7e+109) {
tmp = x;
} else {
tmp = x + (-1.0 / ((t / y) / Math.expm1(z)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.7e+109: tmp = x else: tmp = x + (-1.0 / ((t / y) / math.expm1(z))) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -2.7e+109) tmp = x; else tmp = Float64(x + Float64(-1.0 / Float64(Float64(t / y) / expm1(z)))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.7e+109], x, N[(x + N[(-1.0 / N[(N[(t / y), $MachinePrecision] / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+109}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{\frac{\frac{t}{y}}{\mathsf{expm1}\left(z\right)}}\\
\end{array}
\end{array}
if y < -2.70000000000000001e109Initial program 33.7%
remove-double-neg33.7%
neg-mul-133.7%
*-commutative33.7%
*-commutative33.7%
neg-mul-133.7%
remove-double-neg33.7%
sub-neg33.7%
associate-+l+79.0%
cancel-sign-sub79.0%
log1p-def79.0%
cancel-sign-sub79.0%
+-commutative79.0%
unsub-neg79.0%
*-rgt-identity79.0%
distribute-lft-out--79.0%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 71.5%
if -2.70000000000000001e109 < y Initial program 62.4%
remove-double-neg62.4%
neg-mul-162.4%
*-commutative62.4%
*-commutative62.4%
neg-mul-162.4%
remove-double-neg62.4%
sub-neg62.4%
associate-+l+73.9%
cancel-sign-sub73.9%
log1p-def81.2%
cancel-sign-sub81.2%
+-commutative81.2%
unsub-neg81.2%
*-rgt-identity81.2%
distribute-lft-out--81.2%
expm1-def96.9%
Simplified96.9%
clear-num96.8%
associate-/r/96.8%
Applied egg-rr96.8%
associate-/r/96.8%
Applied egg-rr96.8%
Taylor expanded in y around 0 76.8%
associate-/r*76.7%
expm1-def89.9%
Simplified89.9%
Final simplification87.2%
(FPCore (x y z t) :precision binary64 (if (<= y -1.35e+110) x (- x (/ (* y (expm1 z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.35e+110) {
tmp = x;
} 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 <= -1.35e+110) {
tmp = x;
} else {
tmp = x - ((y * Math.expm1(z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.35e+110: tmp = x else: tmp = x - ((y * math.expm1(z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.35e+110) tmp = x; else tmp = Float64(x - Float64(Float64(y * expm1(z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.35e+110], x, N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+110}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -1.35000000000000005e110Initial program 33.7%
remove-double-neg33.7%
neg-mul-133.7%
*-commutative33.7%
*-commutative33.7%
neg-mul-133.7%
remove-double-neg33.7%
sub-neg33.7%
associate-+l+79.0%
cancel-sign-sub79.0%
log1p-def79.0%
cancel-sign-sub79.0%
+-commutative79.0%
unsub-neg79.0%
*-rgt-identity79.0%
distribute-lft-out--79.0%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 71.5%
if -1.35000000000000005e110 < y Initial program 62.4%
remove-double-neg62.4%
neg-mul-162.4%
*-commutative62.4%
*-commutative62.4%
neg-mul-162.4%
remove-double-neg62.4%
sub-neg62.4%
associate-+l+73.9%
cancel-sign-sub73.9%
log1p-def81.2%
cancel-sign-sub81.2%
+-commutative81.2%
unsub-neg81.2%
*-rgt-identity81.2%
distribute-lft-out--81.2%
expm1-def96.9%
Simplified96.9%
Taylor expanded in y around 0 76.8%
expm1-def88.2%
Simplified88.2%
Final simplification85.8%
(FPCore (x y z t) :precision binary64 (if (<= x -4e-238) x (if (<= x 6.2e-188) (* z (/ (- y) t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4e-238) {
tmp = x;
} else if (x <= 6.2e-188) {
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 (x <= (-4d-238)) then
tmp = x
else if (x <= 6.2d-188) 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 (x <= -4e-238) {
tmp = x;
} else if (x <= 6.2e-188) {
tmp = z * (-y / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -4e-238: tmp = x elif x <= 6.2e-188: tmp = z * (-y / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -4e-238) tmp = x; elseif (x <= 6.2e-188) 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 (x <= -4e-238) tmp = x; elseif (x <= 6.2e-188) tmp = z * (-y / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -4e-238], x, If[LessEqual[x, 6.2e-188], N[(z * N[((-y) / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-238}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-188}:\\
\;\;\;\;z \cdot \frac{-y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -4e-238 or 6.2000000000000004e-188 < x Initial program 65.4%
remove-double-neg65.4%
neg-mul-165.4%
*-commutative65.4%
*-commutative65.4%
neg-mul-165.4%
remove-double-neg65.4%
sub-neg65.4%
associate-+l+83.7%
cancel-sign-sub83.7%
log1p-def87.8%
cancel-sign-sub87.8%
+-commutative87.8%
unsub-neg87.8%
*-rgt-identity87.8%
distribute-lft-out--87.8%
expm1-def98.6%
Simplified98.6%
Taylor expanded in x around inf 80.1%
if -4e-238 < x < 6.2000000000000004e-188Initial program 23.8%
remove-double-neg23.8%
neg-mul-123.8%
*-commutative23.8%
*-commutative23.8%
neg-mul-123.8%
remove-double-neg23.8%
sub-neg23.8%
associate-+l+30.9%
cancel-sign-sub30.9%
log1p-def47.7%
cancel-sign-sub47.7%
+-commutative47.7%
unsub-neg47.7%
*-rgt-identity47.7%
distribute-lft-out--47.7%
expm1-def91.1%
Simplified91.1%
Taylor expanded in x around 0 9.9%
associate-*r/9.9%
log1p-def26.7%
expm1-def70.2%
neg-mul-170.2%
Simplified70.2%
Taylor expanded in z around 0 42.3%
mul-1-neg42.3%
associate-/l*46.6%
associate-/r/48.8%
distribute-rgt-neg-in48.8%
Simplified48.8%
Final simplification74.8%
(FPCore (x y z t) :precision binary64 (if (<= x -1.1e-237) x (if (<= x 6.4e-188) (/ z (/ (- t) y)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.1e-237) {
tmp = x;
} else if (x <= 6.4e-188) {
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 (x <= (-1.1d-237)) then
tmp = x
else if (x <= 6.4d-188) 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 (x <= -1.1e-237) {
tmp = x;
} else if (x <= 6.4e-188) {
tmp = z / (-t / y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.1e-237: tmp = x elif x <= 6.4e-188: tmp = z / (-t / y) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.1e-237) tmp = x; elseif (x <= 6.4e-188) tmp = Float64(z / Float64(Float64(-t) / y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.1e-237) tmp = x; elseif (x <= 6.4e-188) tmp = z / (-t / y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.1e-237], x, If[LessEqual[x, 6.4e-188], N[(z / N[((-t) / y), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{-237}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-188}:\\
\;\;\;\;\frac{z}{\frac{-t}{y}}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.09999999999999999e-237 or 6.40000000000000044e-188 < x Initial program 65.4%
remove-double-neg65.4%
neg-mul-165.4%
*-commutative65.4%
*-commutative65.4%
neg-mul-165.4%
remove-double-neg65.4%
sub-neg65.4%
associate-+l+83.7%
cancel-sign-sub83.7%
log1p-def87.8%
cancel-sign-sub87.8%
+-commutative87.8%
unsub-neg87.8%
*-rgt-identity87.8%
distribute-lft-out--87.8%
expm1-def98.6%
Simplified98.6%
Taylor expanded in x around inf 80.1%
if -1.09999999999999999e-237 < x < 6.40000000000000044e-188Initial program 23.8%
remove-double-neg23.8%
neg-mul-123.8%
*-commutative23.8%
*-commutative23.8%
neg-mul-123.8%
remove-double-neg23.8%
sub-neg23.8%
associate-+l+30.9%
cancel-sign-sub30.9%
log1p-def47.7%
cancel-sign-sub47.7%
+-commutative47.7%
unsub-neg47.7%
*-rgt-identity47.7%
distribute-lft-out--47.7%
expm1-def91.1%
Simplified91.1%
Taylor expanded in x around 0 9.9%
associate-*r/9.9%
log1p-def26.7%
expm1-def70.2%
neg-mul-170.2%
Simplified70.2%
Taylor expanded in z around 0 42.3%
mul-1-neg42.3%
associate-/l*46.6%
associate-/r/48.8%
distribute-rgt-neg-in48.8%
Simplified48.8%
clear-num49.0%
associate-*l/49.0%
*-un-lft-identity49.0%
add-sqr-sqrt23.1%
sqrt-unprod13.7%
sqr-neg13.7%
sqrt-unprod1.4%
add-sqr-sqrt3.4%
frac-2neg3.4%
add-sqr-sqrt2.0%
sqrt-unprod18.4%
sqr-neg18.4%
sqrt-unprod25.8%
add-sqr-sqrt49.0%
distribute-neg-frac49.0%
Applied egg-rr49.0%
Final simplification74.8%
(FPCore (x y z t) :precision binary64 (if (<= z -8.2e-31) x (- x (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.2e-31) {
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.2d-31)) 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.2e-31) {
tmp = x;
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.2e-31: tmp = x else: tmp = x - (z * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.2e-31) 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.2e-31) tmp = x; else tmp = x - (z * (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.2e-31], x, N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{-31}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -8.1999999999999993e-31Initial program 73.6%
remove-double-neg73.6%
neg-mul-173.6%
*-commutative73.6%
*-commutative73.6%
neg-mul-173.6%
remove-double-neg73.6%
sub-neg73.6%
associate-+l+76.2%
cancel-sign-sub76.2%
log1p-def97.4%
cancel-sign-sub97.4%
+-commutative97.4%
unsub-neg97.4%
*-rgt-identity97.4%
distribute-lft-out--97.4%
expm1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 67.9%
if -8.1999999999999993e-31 < z Initial program 51.7%
remove-double-neg51.7%
neg-mul-151.7%
*-commutative51.7%
*-commutative51.7%
neg-mul-151.7%
remove-double-neg51.7%
sub-neg51.7%
associate-+l+73.9%
cancel-sign-sub73.9%
log1p-def73.9%
cancel-sign-sub73.9%
+-commutative73.9%
unsub-neg73.9%
*-rgt-identity73.9%
distribute-lft-out--73.9%
expm1-def96.2%
Simplified96.2%
Taylor expanded in z around 0 85.0%
associate-/l*87.6%
associate-/r/85.9%
Simplified85.9%
Final simplification80.5%
(FPCore (x y z t) :precision binary64 (if (<= z -8.2e-31) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.2e-31) {
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.2d-31)) 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.2e-31) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.2e-31: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.2e-31) 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.2e-31) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.2e-31], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{-31}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -8.1999999999999993e-31Initial program 73.6%
remove-double-neg73.6%
neg-mul-173.6%
*-commutative73.6%
*-commutative73.6%
neg-mul-173.6%
remove-double-neg73.6%
sub-neg73.6%
associate-+l+76.2%
cancel-sign-sub76.2%
log1p-def97.4%
cancel-sign-sub97.4%
+-commutative97.4%
unsub-neg97.4%
*-rgt-identity97.4%
distribute-lft-out--97.4%
expm1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 67.9%
if -8.1999999999999993e-31 < z Initial program 51.7%
remove-double-neg51.7%
neg-mul-151.7%
*-commutative51.7%
*-commutative51.7%
neg-mul-151.7%
remove-double-neg51.7%
sub-neg51.7%
associate-+l+73.9%
cancel-sign-sub73.9%
log1p-def73.9%
cancel-sign-sub73.9%
+-commutative73.9%
unsub-neg73.9%
*-rgt-identity73.9%
distribute-lft-out--73.9%
expm1-def96.2%
Simplified96.2%
Taylor expanded in z around 0 85.0%
associate-/l*87.6%
associate-/r/85.9%
Simplified85.9%
*-commutative85.9%
clear-num85.9%
un-div-inv86.5%
Applied egg-rr86.5%
associate-/r/87.6%
Simplified87.6%
Final simplification81.8%
(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.2%
remove-double-neg58.2%
neg-mul-158.2%
*-commutative58.2%
*-commutative58.2%
neg-mul-158.2%
remove-double-neg58.2%
sub-neg58.2%
associate-+l+74.6%
cancel-sign-sub74.6%
log1p-def80.9%
cancel-sign-sub80.9%
+-commutative80.9%
unsub-neg80.9%
*-rgt-identity80.9%
distribute-lft-out--80.9%
expm1-def97.3%
Simplified97.3%
Taylor expanded in x around inf 70.8%
Final simplification70.8%
(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 2024021
(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)))