
(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 61.5%
associate-+l-79.2%
sub-neg79.2%
log1p-define83.6%
neg-sub083.6%
associate-+l-83.6%
neg-sub083.6%
+-commutative83.6%
unsub-neg83.6%
*-rgt-identity83.6%
distribute-lft-out--83.6%
expm1-define98.4%
Simplified98.4%
(FPCore (x y z t)
:precision binary64
(if (<= (exp z) 0.0)
(+ x (/ y (* t (+ (* y -0.5) (/ -1.0 (expm1 z))))))
(-
x
(/
(log1p (* y (* z (+ 1.0 (* z (+ 0.5 (* z 0.16666666666666666)))))))
t))))
double code(double x, double y, double z, double t) {
double tmp;
if (exp(z) <= 0.0) {
tmp = x + (y / (t * ((y * -0.5) + (-1.0 / expm1(z)))));
} else {
tmp = x - (log1p((y * (z * (1.0 + (z * (0.5 + (z * 0.16666666666666666))))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (Math.exp(z) <= 0.0) {
tmp = x + (y / (t * ((y * -0.5) + (-1.0 / Math.expm1(z)))));
} else {
tmp = x - (Math.log1p((y * (z * (1.0 + (z * (0.5 + (z * 0.16666666666666666))))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if math.exp(z) <= 0.0: tmp = x + (y / (t * ((y * -0.5) + (-1.0 / math.expm1(z))))) else: tmp = x - (math.log1p((y * (z * (1.0 + (z * (0.5 + (z * 0.16666666666666666))))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (exp(z) <= 0.0) tmp = Float64(x + Float64(y / Float64(t * Float64(Float64(y * -0.5) + Float64(-1.0 / expm1(z)))))); else tmp = Float64(x - Float64(log1p(Float64(y * Float64(z * Float64(1.0 + Float64(z * Float64(0.5 + Float64(z * 0.16666666666666666))))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 0.0], N[(x + N[(y / N[(t * N[(N[(y * -0.5), $MachinePrecision] + N[(-1.0 / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(y * N[(z * N[(1.0 + N[(z * N[(0.5 + N[(z * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 0:\\
\;\;\;\;x + \frac{y}{t \cdot \left(y \cdot -0.5 + \frac{-1}{\mathsf{expm1}\left(z\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \left(z \cdot \left(1 + z \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\right)\right)\right)}{t}\\
\end{array}
\end{array}
if (exp.f64 z) < 0.0Initial program 87.1%
associate-+l-87.1%
sub-neg87.1%
log1p-define99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-define99.9%
Simplified99.9%
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 85.5%
Taylor expanded in t around -inf 85.5%
associate-*r/85.5%
mul-1-neg85.5%
*-commutative85.5%
expm1-define85.5%
Simplified85.5%
if 0.0 < (exp.f64 z) Initial program 49.2%
associate-+l-75.3%
sub-neg75.3%
log1p-define75.8%
neg-sub075.8%
associate-+l-75.8%
neg-sub075.8%
+-commutative75.8%
unsub-neg75.8%
*-rgt-identity75.8%
distribute-lft-out--75.8%
expm1-define97.6%
Simplified97.6%
Taylor expanded in z around 0 97.6%
*-commutative97.6%
Simplified97.6%
Final simplification93.7%
(FPCore (x y z t) :precision binary64 (if (<= (exp z) 0.0) (+ x (/ y (* t (+ (* y -0.5) (/ -1.0 (expm1 z)))))) (- x (/ (log1p (* z (+ y (* 0.5 (* y z))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (exp(z) <= 0.0) {
tmp = x + (y / (t * ((y * -0.5) + (-1.0 / expm1(z)))));
} else {
tmp = x - (log1p((z * (y + (0.5 * (y * z))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (Math.exp(z) <= 0.0) {
tmp = x + (y / (t * ((y * -0.5) + (-1.0 / Math.expm1(z)))));
} else {
tmp = x - (Math.log1p((z * (y + (0.5 * (y * z))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if math.exp(z) <= 0.0: tmp = x + (y / (t * ((y * -0.5) + (-1.0 / math.expm1(z))))) else: tmp = x - (math.log1p((z * (y + (0.5 * (y * z))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (exp(z) <= 0.0) tmp = Float64(x + Float64(y / Float64(t * Float64(Float64(y * -0.5) + Float64(-1.0 / expm1(z)))))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(0.5 * Float64(y * z))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 0.0], N[(x + N[(y / N[(t * N[(N[(y * -0.5), $MachinePrecision] + N[(-1.0 / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(0.5 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 0:\\
\;\;\;\;x + \frac{y}{t \cdot \left(y \cdot -0.5 + \frac{-1}{\mathsf{expm1}\left(z\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + 0.5 \cdot \left(y \cdot z\right)\right)\right)}{t}\\
\end{array}
\end{array}
if (exp.f64 z) < 0.0Initial program 87.1%
associate-+l-87.1%
sub-neg87.1%
log1p-define99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-define99.9%
Simplified99.9%
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 85.5%
Taylor expanded in t around -inf 85.5%
associate-*r/85.5%
mul-1-neg85.5%
*-commutative85.5%
expm1-define85.5%
Simplified85.5%
if 0.0 < (exp.f64 z) Initial program 49.2%
associate-+l-75.3%
sub-neg75.3%
log1p-define75.8%
neg-sub075.8%
associate-+l-75.8%
neg-sub075.8%
+-commutative75.8%
unsub-neg75.8%
*-rgt-identity75.8%
distribute-lft-out--75.8%
expm1-define97.6%
Simplified97.6%
Taylor expanded in z around 0 96.9%
Final simplification93.2%
(FPCore (x y z t) :precision binary64 (if (<= z -30.5) (- x (/ (* y (expm1 z)) t)) (- x (/ (log1p (* z (+ y (* 0.5 (* y z))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -30.5) {
tmp = x - ((y * expm1(z)) / t);
} else {
tmp = x - (log1p((z * (y + (0.5 * (y * z))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -30.5) {
tmp = x - ((y * Math.expm1(z)) / t);
} else {
tmp = x - (Math.log1p((z * (y + (0.5 * (y * z))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -30.5: tmp = x - ((y * math.expm1(z)) / t) else: tmp = x - (math.log1p((z * (y + (0.5 * (y * z))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -30.5) tmp = Float64(x - Float64(Float64(y * expm1(z)) / t)); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(0.5 * Float64(y * z))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -30.5], N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(0.5 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -30.5:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + 0.5 \cdot \left(y \cdot z\right)\right)\right)}{t}\\
\end{array}
\end{array}
if z < -30.5Initial program 87.1%
associate-+l-87.1%
sub-neg87.1%
log1p-define99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-define99.9%
Simplified99.9%
Taylor expanded in y around 0 76.2%
expm1-define76.2%
Simplified76.2%
if -30.5 < z Initial program 49.2%
associate-+l-75.3%
sub-neg75.3%
log1p-define75.8%
neg-sub075.8%
associate-+l-75.8%
neg-sub075.8%
+-commutative75.8%
unsub-neg75.8%
*-rgt-identity75.8%
distribute-lft-out--75.8%
expm1-define97.6%
Simplified97.6%
Taylor expanded in z around 0 96.9%
(FPCore (x y z t) :precision binary64 (if (<= z -4.5e+25) (- x (/ (* y (expm1 z)) t)) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.5e+25) {
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 <= -4.5e+25) {
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 <= -4.5e+25: 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 <= -4.5e+25) 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, -4.5e+25], 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 -4.5 \cdot 10^{+25}:\\
\;\;\;\;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 < -4.5000000000000003e25Initial program 87.8%
associate-+l-87.8%
sub-neg87.8%
log1p-define99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-define99.9%
Simplified99.9%
Taylor expanded in y around 0 76.4%
expm1-define76.4%
Simplified76.4%
if -4.5000000000000003e25 < z Initial program 49.5%
associate-+l-75.2%
sub-neg75.2%
log1p-define76.2%
neg-sub076.2%
associate-+l-76.2%
neg-sub076.2%
+-commutative76.2%
unsub-neg76.2%
*-rgt-identity76.2%
distribute-lft-out--76.2%
expm1-define97.7%
Simplified97.7%
Taylor expanded in z around 0 96.1%
(FPCore (x y z t) :precision binary64 (if (<= z -360.0) (+ x (/ -1.0 (/ (+ (/ t y) (* z (- (* t 0.5) (* 0.5 (/ t y))))) z))) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -360.0) {
tmp = x + (-1.0 / (((t / y) + (z * ((t * 0.5) - (0.5 * (t / y))))) / z));
} 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 <= -360.0) {
tmp = x + (-1.0 / (((t / y) + (z * ((t * 0.5) - (0.5 * (t / y))))) / z));
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -360.0: tmp = x + (-1.0 / (((t / y) + (z * ((t * 0.5) - (0.5 * (t / y))))) / z)) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -360.0) tmp = Float64(x + Float64(-1.0 / Float64(Float64(Float64(t / y) + Float64(z * Float64(Float64(t * 0.5) - Float64(0.5 * Float64(t / y))))) / z))); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -360.0], N[(x + N[(-1.0 / N[(N[(N[(t / y), $MachinePrecision] + N[(z * N[(N[(t * 0.5), $MachinePrecision] - N[(0.5 * N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $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 -360:\\
\;\;\;\;x + \frac{-1}{\frac{\frac{t}{y} + z \cdot \left(t \cdot 0.5 - 0.5 \cdot \frac{t}{y}\right)}{z}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if z < -360Initial program 87.1%
associate-+l-87.1%
sub-neg87.1%
log1p-define99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-define99.9%
Simplified99.9%
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 85.5%
Taylor expanded in z around 0 74.6%
if -360 < z Initial program 49.2%
associate-+l-75.3%
sub-neg75.3%
log1p-define75.8%
neg-sub075.8%
associate-+l-75.8%
neg-sub075.8%
+-commutative75.8%
unsub-neg75.8%
*-rgt-identity75.8%
distribute-lft-out--75.8%
expm1-define97.6%
Simplified97.6%
Taylor expanded in z around 0 96.5%
Final simplification89.4%
(FPCore (x y z t) :precision binary64 (if (<= z -2.7e+47) x (+ x (/ -1.0 (/ (+ (* 0.5 (* y t)) (/ t z)) y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.7e+47) {
tmp = x;
} else {
tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y));
}
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.7d+47)) then
tmp = x
else
tmp = x + ((-1.0d0) / (((0.5d0 * (y * t)) + (t / z)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.7e+47) {
tmp = x;
} else {
tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.7e+47: tmp = x else: tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.7e+47) tmp = x; else tmp = Float64(x + Float64(-1.0 / Float64(Float64(Float64(0.5 * Float64(y * t)) + Float64(t / z)) / y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -2.7e+47) tmp = x; else tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.7e+47], x, N[(x + N[(-1.0 / N[(N[(N[(0.5 * N[(y * t), $MachinePrecision]), $MachinePrecision] + N[(t / z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{+47}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{\frac{0.5 \cdot \left(y \cdot t\right) + \frac{t}{z}}{y}}\\
\end{array}
\end{array}
if z < -2.69999999999999996e47Initial program 91.8%
associate-+l-91.8%
sub-neg91.8%
log1p-define99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.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 74.0%
if -2.69999999999999996e47 < z Initial program 49.8%
associate-+l-74.3%
sub-neg74.3%
log1p-define77.4%
neg-sub077.4%
associate-+l-77.4%
neg-sub077.4%
+-commutative77.4%
unsub-neg77.4%
*-rgt-identity77.4%
distribute-lft-out--77.3%
expm1-define97.8%
Simplified97.8%
clear-num97.7%
associate-/r/97.7%
Applied egg-rr97.7%
associate-/r/97.7%
Applied egg-rr97.7%
Taylor expanded in y around 0 71.4%
Taylor expanded in z around 0 87.5%
Final simplification83.8%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (/ (/ (+ t (* z (* 0.5 (- (* y t) t)))) z) y))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / (((t + (z * (0.5 * ((y * t) - t)))) / z) / y));
}
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 + ((-1.0d0) / (((t + (z * (0.5d0 * ((y * t) - t)))) / z) / y))
end function
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / (((t + (z * (0.5 * ((y * t) - t)))) / z) / y));
}
def code(x, y, z, t): return x + (-1.0 / (((t + (z * (0.5 * ((y * t) - t)))) / z) / y))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(Float64(Float64(t + Float64(z * Float64(0.5 * Float64(Float64(y * t) - t)))) / z) / y))) end
function tmp = code(x, y, z, t) tmp = x + (-1.0 / (((t + (z * (0.5 * ((y * t) - t)))) / z) / y)); end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(N[(N[(t + N[(z * N[(0.5 * N[(N[(y * t), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{\frac{\frac{t + z \cdot \left(0.5 \cdot \left(y \cdot t - t\right)\right)}{z}}{y}}
\end{array}
Initial program 61.5%
associate-+l-79.2%
sub-neg79.2%
log1p-define83.6%
neg-sub083.6%
associate-+l-83.6%
neg-sub083.6%
+-commutative83.6%
unsub-neg83.6%
*-rgt-identity83.6%
distribute-lft-out--83.6%
expm1-define98.4%
Simplified98.4%
clear-num98.3%
associate-/r/98.3%
Applied egg-rr98.3%
associate-/r/98.3%
Applied egg-rr98.3%
Taylor expanded in y around 0 75.0%
Taylor expanded in z around 0 85.8%
distribute-lft-out--85.8%
*-commutative85.8%
Simplified85.8%
Final simplification85.8%
(FPCore (x y z t) :precision binary64 (if (<= t -4e-229) x (if (<= t 8.2e-235) (* y (/ z (- t))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -4e-229) {
tmp = x;
} else if (t <= 8.2e-235) {
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 <= (-4d-229)) then
tmp = x
else if (t <= 8.2d-235) 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 <= -4e-229) {
tmp = x;
} else if (t <= 8.2e-235) {
tmp = y * (z / -t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -4e-229: tmp = x elif t <= 8.2e-235: tmp = y * (z / -t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -4e-229) tmp = x; elseif (t <= 8.2e-235) tmp = Float64(y * Float64(z / Float64(-t))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -4e-229) tmp = x; elseif (t <= 8.2e-235) tmp = y * (z / -t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -4e-229], x, If[LessEqual[t, 8.2e-235], N[(y * N[(z / (-t)), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4 \cdot 10^{-229}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 8.2 \cdot 10^{-235}:\\
\;\;\;\;y \cdot \frac{z}{-t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -4.00000000000000028e-229 or 8.19999999999999993e-235 < t Initial program 65.3%
associate-+l-85.8%
sub-neg85.8%
log1p-define89.2%
neg-sub089.2%
associate-+l-89.2%
neg-sub089.2%
+-commutative89.2%
unsub-neg89.2%
*-rgt-identity89.2%
distribute-lft-out--89.2%
expm1-define99.5%
Simplified99.5%
Taylor expanded in x around inf 81.8%
if -4.00000000000000028e-229 < t < 8.19999999999999993e-235Initial program 37.3%
associate-+l-37.4%
sub-neg37.4%
log1p-define48.6%
neg-sub048.6%
associate-+l-48.6%
neg-sub048.6%
+-commutative48.6%
unsub-neg48.6%
*-rgt-identity48.6%
distribute-lft-out--48.4%
expm1-define91.1%
Simplified91.1%
Taylor expanded in z around 0 43.0%
associate-/l*54.2%
Simplified54.2%
Taylor expanded in x around 0 37.3%
neg-mul-137.3%
associate-/l*48.7%
distribute-lft-neg-out48.7%
*-commutative48.7%
Simplified48.7%
Final simplification77.3%
(FPCore (x y z t) :precision binary64 (if (<= z -6.2e+16) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6.2e+16) {
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 <= (-6.2d+16)) 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 <= -6.2e+16) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -6.2e+16: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -6.2e+16) 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 <= -6.2e+16) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -6.2e+16], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{+16}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -6.2e16Initial program 88.0%
associate-+l-88.0%
sub-neg88.0%
log1p-define99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.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 71.2%
if -6.2e16 < z Initial program 49.2%
associate-+l-75.1%
sub-neg75.1%
log1p-define76.1%
neg-sub076.1%
associate-+l-76.1%
neg-sub076.1%
+-commutative76.1%
unsub-neg76.1%
*-rgt-identity76.1%
distribute-lft-out--76.0%
expm1-define97.6%
Simplified97.6%
Taylor expanded in z around 0 85.6%
associate-/l*87.8%
Simplified87.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 61.5%
associate-+l-79.2%
sub-neg79.2%
log1p-define83.6%
neg-sub083.6%
associate-+l-83.6%
neg-sub083.6%
+-commutative83.6%
unsub-neg83.6%
*-rgt-identity83.6%
distribute-lft-out--83.6%
expm1-define98.4%
Simplified98.4%
Taylor expanded in x around inf 72.9%
(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 2024172
(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)))