
(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 (pow (/ t (log1p (* y (expm1 z)))) -1.0)))
double code(double x, double y, double z, double t) {
return x - pow((t / log1p((y * expm1(z)))), -1.0);
}
public static double code(double x, double y, double z, double t) {
return x - Math.pow((t / Math.log1p((y * Math.expm1(z)))), -1.0);
}
def code(x, y, z, t): return x - math.pow((t / math.log1p((y * math.expm1(z)))), -1.0)
function code(x, y, z, t) return Float64(x - (Float64(t / log1p(Float64(y * expm1(z)))) ^ -1.0)) end
code[x_, y_, z_, t_] := N[(x - N[Power[N[(t / N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - {\left(\frac{t}{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}\right)}^{-1}
\end{array}
Initial program 55.7%
associate-+l-72.9%
sub-neg72.9%
log1p-define76.0%
neg-sub076.0%
associate-+l-76.0%
neg-sub076.0%
+-commutative76.0%
unsub-neg76.0%
*-rgt-identity76.0%
distribute-lft-out--76.0%
expm1-define97.2%
Simplified97.2%
clear-num97.2%
inv-pow97.2%
Applied egg-rr97.2%
(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 55.7%
associate-+l-72.9%
sub-neg72.9%
log1p-define76.0%
neg-sub076.0%
associate-+l-76.0%
neg-sub076.0%
+-commutative76.0%
unsub-neg76.0%
*-rgt-identity76.0%
distribute-lft-out--76.0%
expm1-define97.2%
Simplified97.2%
(FPCore (x y z t) :precision binary64 (if (<= z -9e+46) (- x (/ (* y (expm1 z)) t)) (+ x (/ -1.0 (/ t (log1p (* y z)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9e+46) {
tmp = x - ((y * expm1(z)) / t);
} else {
tmp = x + (-1.0 / (t / log1p((y * z))));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9e+46) {
tmp = x - ((y * Math.expm1(z)) / t);
} else {
tmp = x + (-1.0 / (t / Math.log1p((y * z))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -9e+46: tmp = x - ((y * math.expm1(z)) / t) else: tmp = x + (-1.0 / (t / math.log1p((y * z)))) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -9e+46) tmp = Float64(x - Float64(Float64(y * expm1(z)) / t)); else tmp = Float64(x + Float64(-1.0 / Float64(t / log1p(Float64(y * z))))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -9e+46], N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x + N[(-1.0 / N[(t / N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+46}:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{\frac{t}{\mathsf{log1p}\left(y \cdot z\right)}}\\
\end{array}
\end{array}
if z < -9.00000000000000019e46Initial program 81.7%
associate-+l-81.7%
sub-neg81.7%
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 80.1%
expm1-define80.1%
Simplified80.1%
if -9.00000000000000019e46 < z Initial program 50.4%
associate-+l-71.1%
sub-neg71.1%
log1p-define71.1%
neg-sub071.1%
associate-+l-71.1%
neg-sub071.1%
+-commutative71.1%
unsub-neg71.1%
*-rgt-identity71.1%
distribute-lft-out--71.1%
expm1-define96.6%
Simplified96.6%
clear-num96.7%
inv-pow96.7%
Applied egg-rr96.7%
Taylor expanded in z around 0 95.1%
unpow-195.1%
Applied egg-rr95.1%
Final simplification92.6%
(FPCore (x y z t) :precision binary64 (if (<= z -9e+46) (- x (/ (* y (expm1 z)) t)) (+ x (* (log1p (* y z)) (/ -1.0 t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9e+46) {
tmp = x - ((y * expm1(z)) / t);
} else {
tmp = x + (log1p((y * z)) * (-1.0 / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9e+46) {
tmp = x - ((y * Math.expm1(z)) / t);
} else {
tmp = x + (Math.log1p((y * z)) * (-1.0 / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -9e+46: tmp = x - ((y * math.expm1(z)) / t) else: tmp = x + (math.log1p((y * z)) * (-1.0 / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -9e+46) tmp = Float64(x - Float64(Float64(y * expm1(z)) / t)); else tmp = Float64(x + Float64(log1p(Float64(y * z)) * Float64(-1.0 / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -9e+46], N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+46}:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \mathsf{log1p}\left(y \cdot z\right) \cdot \frac{-1}{t}\\
\end{array}
\end{array}
if z < -9.00000000000000019e46Initial program 81.7%
associate-+l-81.7%
sub-neg81.7%
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 80.1%
expm1-define80.1%
Simplified80.1%
if -9.00000000000000019e46 < z Initial program 50.4%
associate-+l-71.1%
sub-neg71.1%
log1p-define71.1%
neg-sub071.1%
associate-+l-71.1%
neg-sub071.1%
+-commutative71.1%
unsub-neg71.1%
*-rgt-identity71.1%
distribute-lft-out--71.1%
expm1-define96.6%
Simplified96.6%
Taylor expanded in z around 0 95.1%
clear-num95.1%
associate-/r/95.1%
Applied egg-rr95.1%
Final simplification92.6%
(FPCore (x y z t) :precision binary64 (if (<= z -9.5e+46) (- x (/ (* y (expm1 z)) t)) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9.5e+46) {
tmp = x - ((y * expm1(z)) / t);
} else {
tmp = x - (log1p((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9.5e+46) {
tmp = x - ((y * Math.expm1(z)) / t);
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -9.5e+46: tmp = x - ((y * math.expm1(z)) / t) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -9.5e+46) tmp = Float64(x - Float64(Float64(y * expm1(z)) / t)); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -9.5e+46], N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{+46}:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if z < -9.5000000000000008e46Initial program 81.7%
associate-+l-81.7%
sub-neg81.7%
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 80.1%
expm1-define80.1%
Simplified80.1%
if -9.5000000000000008e46 < z Initial program 50.4%
associate-+l-71.1%
sub-neg71.1%
log1p-define71.1%
neg-sub071.1%
associate-+l-71.1%
neg-sub071.1%
+-commutative71.1%
unsub-neg71.1%
*-rgt-identity71.1%
distribute-lft-out--71.1%
expm1-define96.6%
Simplified96.6%
Taylor expanded in z around 0 95.1%
(FPCore (x y z t) :precision binary64 (if (<= z -2.45e+23) x (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.45e+23) {
tmp = x;
} else {
tmp = x - (log1p((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.45e+23) {
tmp = x;
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.45e+23: tmp = x else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.45e+23) tmp = x; else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.45e+23], x, N[(x - N[(N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.45 \cdot 10^{+23}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if z < -2.4500000000000001e23Initial program 83.9%
associate-+l-83.9%
sub-neg83.9%
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 68.1%
if -2.4500000000000001e23 < z Initial program 49.0%
associate-+l-70.3%
sub-neg70.3%
log1p-define70.3%
neg-sub070.3%
associate-+l-70.3%
neg-sub070.3%
+-commutative70.3%
unsub-neg70.3%
*-rgt-identity70.3%
distribute-lft-out--70.3%
expm1-define96.5%
Simplified96.5%
Taylor expanded in z around 0 96.2%
(FPCore (x y z t) :precision binary64 (if (<= x -5.8e-225) x (if (<= x 9.2e-244) (/ y (/ t (- z))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -5.8e-225) {
tmp = x;
} else if (x <= 9.2e-244) {
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 (x <= (-5.8d-225)) then
tmp = x
else if (x <= 9.2d-244) 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 (x <= -5.8e-225) {
tmp = x;
} else if (x <= 9.2e-244) {
tmp = y / (t / -z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -5.8e-225: tmp = x elif x <= 9.2e-244: tmp = y / (t / -z) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -5.8e-225) tmp = x; elseif (x <= 9.2e-244) tmp = Float64(y / Float64(t / Float64(-z))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -5.8e-225) tmp = x; elseif (x <= 9.2e-244) tmp = y / (t / -z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -5.8e-225], x, If[LessEqual[x, 9.2e-244], N[(y / N[(t / (-z)), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{-225}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 9.2 \cdot 10^{-244}:\\
\;\;\;\;\frac{y}{\frac{t}{-z}}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -5.7999999999999996e-225 or 9.2e-244 < x Initial program 60.9%
associate-+l-80.5%
sub-neg80.5%
log1p-define82.8%
neg-sub082.8%
associate-+l-82.8%
neg-sub082.8%
+-commutative82.8%
unsub-neg82.8%
*-rgt-identity82.8%
distribute-lft-out--82.8%
expm1-define99.0%
Simplified99.0%
Taylor expanded in x around inf 76.7%
if -5.7999999999999996e-225 < x < 9.2e-244Initial program 24.0%
associate-+l-26.4%
sub-neg26.4%
log1p-define34.2%
neg-sub034.2%
associate-+l-34.2%
neg-sub034.2%
+-commutative34.2%
unsub-neg34.2%
*-rgt-identity34.2%
distribute-lft-out--34.3%
expm1-define85.9%
Simplified85.9%
Taylor expanded in z around 0 63.7%
associate-/l*73.8%
Simplified73.8%
Taylor expanded in x around 0 47.4%
mul-1-neg47.4%
associate-*r/56.1%
distribute-rgt-neg-out56.1%
distribute-frac-neg256.1%
Simplified56.1%
Taylor expanded in y around 0 47.4%
mul-1-neg47.4%
*-commutative47.4%
associate-*r/47.7%
*-commutative47.7%
associate-/r/56.2%
distribute-neg-frac256.2%
Simplified56.2%
Final simplification73.9%
(FPCore (x y z t) :precision binary64 (if (<= x -1.04e-224) x (if (<= x 8e-244) (* (/ z t) (- y)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.04e-224) {
tmp = x;
} else if (x <= 8e-244) {
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.04d-224)) then
tmp = x
else if (x <= 8d-244) 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.04e-224) {
tmp = x;
} else if (x <= 8e-244) {
tmp = (z / t) * -y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.04e-224: tmp = x elif x <= 8e-244: tmp = (z / t) * -y else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.04e-224) tmp = x; elseif (x <= 8e-244) 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 (x <= -1.04e-224) tmp = x; elseif (x <= 8e-244) tmp = (z / t) * -y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.04e-224], x, If[LessEqual[x, 8e-244], N[(N[(z / t), $MachinePrecision] * (-y)), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.04 \cdot 10^{-224}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-244}:\\
\;\;\;\;\frac{z}{t} \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.04000000000000005e-224 or 7.9999999999999994e-244 < x Initial program 60.9%
associate-+l-80.5%
sub-neg80.5%
log1p-define82.8%
neg-sub082.8%
associate-+l-82.8%
neg-sub082.8%
+-commutative82.8%
unsub-neg82.8%
*-rgt-identity82.8%
distribute-lft-out--82.8%
expm1-define99.0%
Simplified99.0%
Taylor expanded in x around inf 76.7%
if -1.04000000000000005e-224 < x < 7.9999999999999994e-244Initial program 24.0%
associate-+l-26.4%
sub-neg26.4%
log1p-define34.2%
neg-sub034.2%
associate-+l-34.2%
neg-sub034.2%
+-commutative34.2%
unsub-neg34.2%
*-rgt-identity34.2%
distribute-lft-out--34.3%
expm1-define85.9%
Simplified85.9%
Taylor expanded in z around 0 63.7%
associate-/l*73.8%
Simplified73.8%
Taylor expanded in x around 0 47.4%
mul-1-neg47.4%
associate-*r/56.1%
distribute-rgt-neg-out56.1%
distribute-frac-neg256.1%
Simplified56.1%
Final simplification73.8%
(FPCore (x y z t) :precision binary64 (if (<= z -2.6e-14) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.6e-14) {
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 <= (-2.6d-14)) 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 <= -2.6e-14) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.6e-14: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.6e-14) 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 <= -2.6e-14) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.6e-14], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \cdot 10^{-14}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -2.59999999999999997e-14Initial program 86.3%
associate-+l-86.3%
sub-neg86.3%
log1p-define99.4%
neg-sub099.4%
associate-+l-99.4%
neg-sub099.4%
+-commutative99.4%
unsub-neg99.4%
*-rgt-identity99.4%
distribute-lft-out--99.3%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 69.2%
if -2.59999999999999997e-14 < z Initial program 46.3%
associate-+l-68.8%
sub-neg68.8%
log1p-define68.8%
neg-sub068.8%
associate-+l-68.8%
neg-sub068.8%
+-commutative68.8%
unsub-neg68.8%
*-rgt-identity68.8%
distribute-lft-out--68.8%
expm1-define96.3%
Simplified96.3%
Taylor expanded in z around 0 88.5%
associate-/l*90.6%
Simplified90.6%
clear-num90.6%
un-div-inv90.7%
Applied egg-rr90.7%
(FPCore (x y z t) :precision binary64 (if (<= z -8e-12) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8e-12) {
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 <= (-8d-12)) 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 <= -8e-12) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8e-12: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8e-12) 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 <= -8e-12) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8e-12], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{-12}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -7.99999999999999984e-12Initial program 86.3%
associate-+l-86.3%
sub-neg86.3%
log1p-define99.4%
neg-sub099.4%
associate-+l-99.4%
neg-sub099.4%
+-commutative99.4%
unsub-neg99.4%
*-rgt-identity99.4%
distribute-lft-out--99.3%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 69.2%
if -7.99999999999999984e-12 < z Initial program 46.3%
associate-+l-68.8%
sub-neg68.8%
log1p-define68.8%
neg-sub068.8%
associate-+l-68.8%
neg-sub068.8%
+-commutative68.8%
unsub-neg68.8%
*-rgt-identity68.8%
distribute-lft-out--68.8%
expm1-define96.3%
Simplified96.3%
Taylor expanded in z around 0 88.5%
associate-/l*90.6%
Simplified90.6%
(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 55.7%
associate-+l-72.9%
sub-neg72.9%
log1p-define76.0%
neg-sub076.0%
associate-+l-76.0%
neg-sub076.0%
+-commutative76.0%
unsub-neg76.0%
*-rgt-identity76.0%
distribute-lft-out--76.0%
expm1-define97.2%
Simplified97.2%
Taylor expanded in x around inf 69.1%
(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 2024116
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:precision binary64
:alt
(! :herbie-platform default (if (< z -288746230882079470000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (- x (/ (/ (- 1/2) (* y t)) (* z z))) (* (/ (- 1/2) (* y t)) (/ (/ 2 z) (* z z)))) (- x (/ (log (+ 1 (* z y))) t))))
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))