
(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 53.4%
sub-neg53.4%
associate-+l+68.7%
cancel-sign-sub68.7%
log1p-def73.9%
cancel-sign-sub73.9%
+-commutative73.9%
unsub-neg73.9%
*-rgt-identity73.9%
distribute-lft-out--73.9%
expm1-def99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x y z t) :precision binary64 (if (<= z -12500.0) (+ x (/ -1.0 (+ (/ t (* y (expm1 z))) (* t 0.5)))) (- x (/ (log1p (+ (* y z) (* (* y 0.5) (* z z)))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -12500.0) {
tmp = x + (-1.0 / ((t / (y * expm1(z))) + (t * 0.5)));
} else {
tmp = x - (log1p(((y * z) + ((y * 0.5) * (z * z)))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -12500.0) {
tmp = x + (-1.0 / ((t / (y * Math.expm1(z))) + (t * 0.5)));
} else {
tmp = x - (Math.log1p(((y * z) + ((y * 0.5) * (z * z)))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -12500.0: tmp = x + (-1.0 / ((t / (y * math.expm1(z))) + (t * 0.5))) else: tmp = x - (math.log1p(((y * z) + ((y * 0.5) * (z * z)))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -12500.0) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t / Float64(y * expm1(z))) + Float64(t * 0.5)))); else tmp = Float64(x - Float64(log1p(Float64(Float64(y * z) + Float64(Float64(y * 0.5) * Float64(z * z)))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -12500.0], N[(x + N[(-1.0 / N[(N[(t / N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(N[(y * z), $MachinePrecision] + N[(N[(y * 0.5), $MachinePrecision] * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -12500:\\
\;\;\;\;x + \frac{-1}{\frac{t}{y \cdot \mathsf{expm1}\left(z\right)} + t \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z + \left(y \cdot 0.5\right) \cdot \left(z \cdot z\right)\right)}{t}\\
\end{array}
\end{array}
if z < -12500Initial program 78.3%
sub-neg78.3%
associate-+l+78.3%
cancel-sign-sub78.3%
log1p-def99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-def99.9%
Simplified99.9%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 91.0%
expm1-def91.0%
*-commutative91.0%
Simplified91.0%
if -12500 < z Initial program 46.2%
sub-neg46.2%
associate-+l+65.9%
cancel-sign-sub65.9%
log1p-def66.3%
cancel-sign-sub66.3%
+-commutative66.3%
unsub-neg66.3%
*-rgt-identity66.3%
distribute-lft-out--66.3%
expm1-def98.8%
Simplified98.8%
Taylor expanded in z around 0 98.5%
Taylor expanded in z around 0 98.5%
associate-*r*98.5%
unpow298.5%
*-commutative98.5%
Simplified98.5%
Final simplification96.8%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (+ (/ t (* y (expm1 z))) (* t 0.5)))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t / (y * expm1(z))) + (t * 0.5)));
}
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t / (y * Math.expm1(z))) + (t * 0.5)));
}
def code(x, y, z, t): return x + (-1.0 / ((t / (y * math.expm1(z))) + (t * 0.5)))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(Float64(t / Float64(y * expm1(z))) + Float64(t * 0.5)))) end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(N[(t / N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{\frac{t}{y \cdot \mathsf{expm1}\left(z\right)} + t \cdot 0.5}
\end{array}
Initial program 53.4%
sub-neg53.4%
associate-+l+68.7%
cancel-sign-sub68.7%
log1p-def73.9%
cancel-sign-sub73.9%
+-commutative73.9%
unsub-neg73.9%
*-rgt-identity73.9%
distribute-lft-out--73.9%
expm1-def99.1%
Simplified99.1%
clear-num99.0%
inv-pow99.0%
Applied egg-rr99.0%
unpow-199.0%
Applied egg-rr99.0%
Taylor expanded in y around 0 71.6%
expm1-def90.9%
*-commutative90.9%
Simplified90.9%
Final simplification90.9%
(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 53.4%
sub-neg53.4%
associate-+l+68.7%
cancel-sign-sub68.7%
log1p-def73.9%
cancel-sign-sub73.9%
+-commutative73.9%
unsub-neg73.9%
*-rgt-identity73.9%
distribute-lft-out--73.9%
expm1-def99.1%
Simplified99.1%
Taylor expanded in y around 0 69.0%
associate-/l*68.0%
expm1-def83.5%
Simplified83.5%
associate-/r/87.4%
Applied egg-rr87.4%
Final simplification87.4%
(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(Float64(y * expm1(z)) / t)) end
code[x_, y_, z_, t_] := N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}
\end{array}
Initial program 53.4%
sub-neg53.4%
associate-+l+68.7%
cancel-sign-sub68.7%
log1p-def73.9%
cancel-sign-sub73.9%
+-commutative73.9%
unsub-neg73.9%
*-rgt-identity73.9%
distribute-lft-out--73.9%
expm1-def99.1%
Simplified99.1%
Taylor expanded in y around 0 69.0%
expm1-def87.5%
Simplified87.5%
Final simplification87.5%
(FPCore (x y z t) :precision binary64 (if (<= t 1.6e-289) x (if (<= t 1.05e-195) (* z (- (/ y t))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.6e-289) {
tmp = x;
} else if (t <= 1.05e-195) {
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.6d-289) then
tmp = x
else if (t <= 1.05d-195) 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.6e-289) {
tmp = x;
} else if (t <= 1.05e-195) {
tmp = z * -(y / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= 1.6e-289: tmp = x elif t <= 1.05e-195: tmp = z * -(y / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= 1.6e-289) tmp = x; elseif (t <= 1.05e-195) 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.6e-289) tmp = x; elseif (t <= 1.05e-195) tmp = z * -(y / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, 1.6e-289], x, If[LessEqual[t, 1.05e-195], N[(z * (-N[(y / t), $MachinePrecision])), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.6 \cdot 10^{-289}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 1.05 \cdot 10^{-195}:\\
\;\;\;\;z \cdot \left(-\frac{y}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < 1.6000000000000001e-289 or 1.05e-195 < t Initial program 56.5%
sub-neg56.5%
associate-+l+73.1%
cancel-sign-sub73.1%
log1p-def77.4%
cancel-sign-sub77.4%
+-commutative77.4%
unsub-neg77.4%
*-rgt-identity77.4%
distribute-lft-out--77.4%
expm1-def99.4%
Simplified99.4%
Taylor expanded in x around inf 70.6%
if 1.6000000000000001e-289 < t < 1.05e-195Initial program 17.1%
sub-neg17.1%
associate-+l+17.4%
cancel-sign-sub17.4%
log1p-def32.0%
cancel-sign-sub32.0%
+-commutative32.0%
unsub-neg32.0%
*-rgt-identity32.0%
distribute-lft-out--32.0%
expm1-def94.8%
Simplified94.8%
Taylor expanded in z around 0 62.3%
associate-/l*67.1%
associate-/r/62.3%
Simplified62.3%
Taylor expanded in x around 0 52.8%
mul-1-neg52.8%
*-commutative52.8%
associate-*r/53.0%
distribute-rgt-neg-in53.0%
distribute-neg-frac53.0%
Simplified53.0%
Final simplification69.2%
(FPCore (x y z t) :precision binary64 (if (<= t -5.2e-167) x (if (<= t 1.4e-195) (* y (/ (- z) t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -5.2e-167) {
tmp = x;
} else if (t <= 1.4e-195) {
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 <= (-5.2d-167)) then
tmp = x
else if (t <= 1.4d-195) 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 <= -5.2e-167) {
tmp = x;
} else if (t <= 1.4e-195) {
tmp = y * (-z / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -5.2e-167: tmp = x elif t <= 1.4e-195: tmp = y * (-z / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -5.2e-167) tmp = x; elseif (t <= 1.4e-195) 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 <= -5.2e-167) tmp = x; elseif (t <= 1.4e-195) tmp = y * (-z / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -5.2e-167], x, If[LessEqual[t, 1.4e-195], N[(y * N[((-z) / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.2 \cdot 10^{-167}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 1.4 \cdot 10^{-195}:\\
\;\;\;\;y \cdot \frac{-z}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -5.1999999999999998e-167 or 1.40000000000000002e-195 < t Initial program 60.4%
sub-neg60.4%
associate-+l+78.9%
cancel-sign-sub78.9%
log1p-def82.6%
cancel-sign-sub82.6%
+-commutative82.6%
unsub-neg82.6%
*-rgt-identity82.6%
distribute-lft-out--82.5%
expm1-def99.4%
Simplified99.4%
Taylor expanded in x around inf 76.6%
if -5.1999999999999998e-167 < t < 1.40000000000000002e-195Initial program 25.4%
sub-neg25.4%
associate-+l+27.7%
cancel-sign-sub27.7%
log1p-def39.1%
cancel-sign-sub39.1%
+-commutative39.1%
unsub-neg39.1%
*-rgt-identity39.1%
distribute-lft-out--39.1%
expm1-def97.7%
Simplified97.7%
Taylor expanded in z around 0 70.3%
associate-/l*72.1%
associate-/r/57.5%
Simplified57.5%
Taylor expanded in x around 0 48.5%
mul-1-neg48.5%
*-commutative48.5%
associate-*r/35.7%
distribute-rgt-neg-in35.7%
distribute-neg-frac35.7%
Simplified35.7%
Taylor expanded in z around 0 48.5%
mul-1-neg48.5%
*-commutative48.5%
associate-/l*35.8%
distribute-neg-frac35.8%
Simplified35.8%
associate-/r/50.5%
Applied egg-rr50.5%
Final simplification71.4%
(FPCore (x y z t) :precision binary64 (if (<= z -1.72e+33) x (- x (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.72e+33) {
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 <= (-1.72d+33)) 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 <= -1.72e+33) {
tmp = x;
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.72e+33: tmp = x else: tmp = x - (z * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.72e+33) 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 <= -1.72e+33) tmp = x; else tmp = x - (z * (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.72e+33], x, N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.72 \cdot 10^{+33}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -1.7199999999999999e33Initial program 80.3%
sub-neg80.3%
associate-+l+80.3%
cancel-sign-sub80.3%
log1p-def99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 71.4%
if -1.7199999999999999e33 < z Initial program 46.3%
sub-neg46.3%
associate-+l+65.6%
cancel-sign-sub65.6%
log1p-def66.9%
cancel-sign-sub66.9%
+-commutative66.9%
unsub-neg66.9%
*-rgt-identity66.9%
distribute-lft-out--66.9%
expm1-def98.9%
Simplified98.9%
Taylor expanded in z around 0 88.3%
associate-/l*87.7%
associate-/r/83.3%
Simplified83.3%
Final simplification80.8%
(FPCore (x y z t) :precision binary64 (if (<= z -3.45e+34) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.45e+34) {
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 <= (-3.45d+34)) 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 <= -3.45e+34) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.45e+34: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.45e+34) 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 <= -3.45e+34) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.45e+34], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.45 \cdot 10^{+34}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -3.45000000000000019e34Initial program 80.3%
sub-neg80.3%
associate-+l+80.3%
cancel-sign-sub80.3%
log1p-def99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 71.4%
if -3.45000000000000019e34 < z Initial program 46.3%
sub-neg46.3%
associate-+l+65.6%
cancel-sign-sub65.6%
log1p-def66.9%
cancel-sign-sub66.9%
+-commutative66.9%
unsub-neg66.9%
*-rgt-identity66.9%
distribute-lft-out--66.9%
expm1-def98.9%
Simplified98.9%
Taylor expanded in z around 0 88.3%
associate-/l*87.7%
Simplified87.7%
Final simplification84.3%
(FPCore (x y z t) :precision binary64 (if (<= z -8.8e+42) x (- x (/ (* y z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.8e+42) {
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.8d+42)) 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.8e+42) {
tmp = x;
} else {
tmp = x - ((y * z) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.8e+42: tmp = x else: tmp = x - ((y * z) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.8e+42) 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 <= -8.8e+42) tmp = x; else tmp = x - ((y * z) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.8e+42], x, N[(x - N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.8 \cdot 10^{+42}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot z}{t}\\
\end{array}
\end{array}
if z < -8.8000000000000005e42Initial program 80.3%
sub-neg80.3%
associate-+l+80.3%
cancel-sign-sub80.3%
log1p-def99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 71.4%
if -8.8000000000000005e42 < z Initial program 46.3%
sub-neg46.3%
associate-+l+65.6%
cancel-sign-sub65.6%
log1p-def66.9%
cancel-sign-sub66.9%
+-commutative66.9%
unsub-neg66.9%
*-rgt-identity66.9%
distribute-lft-out--66.9%
expm1-def98.9%
Simplified98.9%
Taylor expanded in z around 0 88.3%
*-commutative88.3%
Simplified88.3%
Final simplification84.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 53.4%
sub-neg53.4%
associate-+l+68.7%
cancel-sign-sub68.7%
log1p-def73.9%
cancel-sign-sub73.9%
+-commutative73.9%
unsub-neg73.9%
*-rgt-identity73.9%
distribute-lft-out--73.9%
expm1-def99.1%
Simplified99.1%
Taylor expanded in x around inf 66.1%
Final simplification66.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 2023274
(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)))