
(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 10 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.4%
associate-+l-75.8%
sub-neg75.8%
log1p-def81.6%
neg-sub081.6%
associate-+l-81.6%
neg-sub081.6%
neg-mul-181.6%
*-commutative81.6%
distribute-rgt-out81.6%
+-commutative81.6%
metadata-eval81.6%
sub-neg81.6%
expm1-def99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y (expm1 z)))))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t * 0.5) + (t / (y * expm1(z)))));
}
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t * 0.5) + (t / (y * Math.expm1(z)))));
}
def code(x, y, z, t): return x + (-1.0 / ((t * 0.5) + (t / (y * math.expm1(z)))))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * expm1(z)))))) end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot \mathsf{expm1}\left(z\right)}}
\end{array}
Initial program 58.4%
associate-+l-75.8%
sub-neg75.8%
log1p-def81.6%
neg-sub081.6%
associate-+l-81.6%
neg-sub081.6%
neg-mul-181.6%
*-commutative81.6%
distribute-rgt-out81.6%
+-commutative81.6%
metadata-eval81.6%
sub-neg81.6%
expm1-def99.0%
Simplified99.0%
clear-num99.0%
associate-/r/99.0%
Applied egg-rr99.0%
associate-*l/99.0%
associate-/l*99.0%
Applied egg-rr99.0%
Taylor expanded in y around 0 76.4%
expm1-def87.6%
*-commutative87.6%
*-commutative87.6%
Simplified87.6%
Final simplification87.6%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (+ (/ (/ t (expm1 z)) y) (* t 0.5)))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / (((t / expm1(z)) / y) + (t * 0.5)));
}
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / (((t / Math.expm1(z)) / y) + (t * 0.5)));
}
def code(x, y, z, t): return x + (-1.0 / (((t / math.expm1(z)) / y) + (t * 0.5)))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(Float64(Float64(t / expm1(z)) / y) + Float64(t * 0.5)))) end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(N[(N[(t / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] + N[(t * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{\frac{\frac{t}{\mathsf{expm1}\left(z\right)}}{y} + t \cdot 0.5}
\end{array}
Initial program 58.4%
associate-+l-75.8%
sub-neg75.8%
log1p-def81.6%
neg-sub081.6%
associate-+l-81.6%
neg-sub081.6%
neg-mul-181.6%
*-commutative81.6%
distribute-rgt-out81.6%
+-commutative81.6%
metadata-eval81.6%
sub-neg81.6%
expm1-def99.0%
Simplified99.0%
clear-num99.0%
associate-/r/99.0%
Applied egg-rr99.0%
associate-*l/99.0%
associate-/l*99.0%
Applied egg-rr99.0%
Taylor expanded in y around 0 76.4%
expm1-def87.6%
*-commutative87.6%
*-commutative87.6%
Simplified87.6%
Taylor expanded in t around 0 76.4%
associate-/r*76.4%
expm1-def88.1%
Simplified88.1%
Final simplification88.1%
(FPCore (x y z t) :precision binary64 (if (<= y -6.6e+19) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (- x (* y (/ (expm1 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -6.6e+19) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} 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 <= -6.6e+19) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (y * (Math.expm1(z) / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -6.6e+19: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) else: tmp = x - (y * (math.expm1(z) / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -6.6e+19) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); else tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -6.6e+19], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.6 \cdot 10^{+19}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -6.6e19Initial program 42.9%
associate-+l-74.2%
sub-neg74.2%
log1p-def74.2%
neg-sub074.2%
associate-+l-74.2%
neg-sub074.2%
neg-mul-174.2%
*-commutative74.2%
distribute-rgt-out74.2%
+-commutative74.2%
metadata-eval74.2%
sub-neg74.2%
expm1-def99.9%
Simplified99.9%
clear-num99.7%
associate-/r/99.8%
Applied egg-rr99.8%
associate-*l/99.9%
associate-/l*99.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 54.8%
expm1-def67.6%
*-commutative67.6%
*-commutative67.6%
Simplified67.6%
Taylor expanded in z around 0 67.6%
*-commutative67.6%
Simplified67.6%
if -6.6e19 < y Initial program 63.1%
associate-+l-76.3%
sub-neg76.3%
log1p-def83.8%
neg-sub083.8%
associate-+l-83.8%
neg-sub083.8%
neg-mul-183.8%
*-commutative83.8%
distribute-rgt-out83.8%
+-commutative83.8%
metadata-eval83.8%
sub-neg83.8%
expm1-def98.8%
Simplified98.8%
Taylor expanded in y around 0 83.3%
associate-/l*82.4%
associate-/r/83.3%
expm1-def94.0%
Simplified94.0%
Final simplification87.9%
(FPCore (x y z t) :precision binary64 (if (<= z -1e-194) (+ x (/ -1.0 (- (+ (* t 0.5) (/ t (* y z))) (* 0.5 (/ t y))))) (- x (+ (/ (* (* y 0.5) (* z z)) t) (* y (/ z t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1e-194) {
tmp = x + (-1.0 / (((t * 0.5) + (t / (y * z))) - (0.5 * (t / y))));
} else {
tmp = x - ((((y * 0.5) * (z * z)) / t) + (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 <= (-1d-194)) then
tmp = x + ((-1.0d0) / (((t * 0.5d0) + (t / (y * z))) - (0.5d0 * (t / y))))
else
tmp = x - ((((y * 0.5d0) * (z * z)) / t) + (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 <= -1e-194) {
tmp = x + (-1.0 / (((t * 0.5) + (t / (y * z))) - (0.5 * (t / y))));
} else {
tmp = x - ((((y * 0.5) * (z * z)) / t) + (y * (z / t)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1e-194: tmp = x + (-1.0 / (((t * 0.5) + (t / (y * z))) - (0.5 * (t / y)))) else: tmp = x - ((((y * 0.5) * (z * z)) / t) + (y * (z / t))) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1e-194) tmp = Float64(x + Float64(-1.0 / Float64(Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))) - Float64(0.5 * Float64(t / y))))); else tmp = Float64(x - Float64(Float64(Float64(Float64(y * 0.5) * Float64(z * z)) / t) + Float64(y * Float64(z / t)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1e-194) tmp = x + (-1.0 / (((t * 0.5) + (t / (y * z))) - (0.5 * (t / y)))); else tmp = x - ((((y * 0.5) * (z * z)) / t) + (y * (z / t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1e-194], N[(x + N[(-1.0 / N[(N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(N[(N[(y * 0.5), $MachinePrecision] * N[(z * z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-194}:\\
\;\;\;\;x + \frac{-1}{\left(t \cdot 0.5 + \frac{t}{y \cdot z}\right) - 0.5 \cdot \frac{t}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - \left(\frac{\left(y \cdot 0.5\right) \cdot \left(z \cdot z\right)}{t} + y \cdot \frac{z}{t}\right)\\
\end{array}
\end{array}
if z < -1.00000000000000002e-194Initial program 64.3%
associate-+l-75.4%
sub-neg75.4%
log1p-def87.3%
neg-sub087.3%
associate-+l-87.3%
neg-sub087.3%
neg-mul-187.3%
*-commutative87.3%
distribute-rgt-out87.3%
+-commutative87.3%
metadata-eval87.3%
sub-neg87.3%
expm1-def99.9%
Simplified99.9%
clear-num99.8%
associate-/r/99.9%
Applied egg-rr99.9%
associate-*l/99.9%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 78.0%
expm1-def83.5%
*-commutative83.5%
*-commutative83.5%
Simplified83.5%
Taylor expanded in z around 0 73.4%
if -1.00000000000000002e-194 < z Initial program 53.0%
associate-+l-76.2%
sub-neg76.2%
log1p-def76.2%
neg-sub076.2%
associate-+l-76.2%
neg-sub076.2%
neg-mul-176.2%
*-commutative76.2%
distribute-rgt-out76.2%
+-commutative76.2%
metadata-eval76.2%
sub-neg76.2%
expm1-def98.2%
Simplified98.2%
Taylor expanded in y around 0 75.6%
expm1-def90.9%
Simplified90.9%
Taylor expanded in z around 0 90.9%
associate-*r/91.9%
+-commutative91.9%
associate-*r/91.9%
associate-*r*91.9%
unpow291.9%
Simplified91.9%
Final simplification83.0%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t * 0.5) + (t / (y * z))));
}
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 * 0.5d0) + (t / (y * z))))
end function
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t * 0.5) + (t / (y * z))));
}
def code(x, y, z, t): return x + (-1.0 / ((t * 0.5) + (t / (y * z))))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))) end
function tmp = code(x, y, z, t) tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))); end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}
\end{array}
Initial program 58.4%
associate-+l-75.8%
sub-neg75.8%
log1p-def81.6%
neg-sub081.6%
associate-+l-81.6%
neg-sub081.6%
neg-mul-181.6%
*-commutative81.6%
distribute-rgt-out81.6%
+-commutative81.6%
metadata-eval81.6%
sub-neg81.6%
expm1-def99.0%
Simplified99.0%
clear-num99.0%
associate-/r/99.0%
Applied egg-rr99.0%
associate-*l/99.0%
associate-/l*99.0%
Applied egg-rr99.0%
Taylor expanded in y around 0 76.4%
expm1-def87.6%
*-commutative87.6%
*-commutative87.6%
Simplified87.6%
Taylor expanded in z around 0 80.3%
*-commutative80.3%
Simplified80.3%
Final simplification80.3%
(FPCore (x y z t) :precision binary64 (if (<= z -1.45e+20) x (- x (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.45e+20) {
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.45d+20)) 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.45e+20) {
tmp = x;
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.45e+20: tmp = x else: tmp = x - (z * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.45e+20) 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.45e+20) tmp = x; else tmp = x - (z * (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.45e+20], x, N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{+20}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -1.45e20Initial program 80.4%
associate-+l-80.4%
sub-neg80.4%
log1p-def100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
neg-mul-1100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
metadata-eval100.0%
sub-neg100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in z around 0 11.8%
fma-def11.8%
associate-/l*11.4%
associate-/r/8.8%
unpow28.8%
+-commutative8.8%
mul-1-neg8.8%
unsub-neg8.8%
unpow28.8%
associate-/l*8.6%
associate-/r/8.9%
Simplified8.9%
Taylor expanded in z around inf 12.1%
unpow212.1%
*-commutative12.1%
associate-/l*11.7%
unpow211.7%
associate-/l*24.7%
associate-*r/24.7%
associate-/r*21.8%
*-commutative21.8%
associate-/r*21.8%
Simplified21.8%
Taylor expanded in y around 0 12.2%
associate-*r/12.2%
associate-*r*12.2%
unpow212.2%
Simplified12.2%
Taylor expanded in x around inf 62.2%
if -1.45e20 < z Initial program 50.3%
associate-+l-74.2%
sub-neg74.2%
log1p-def74.8%
neg-sub074.8%
associate-+l-74.8%
neg-sub074.8%
neg-mul-174.8%
*-commutative74.8%
distribute-rgt-out74.8%
+-commutative74.8%
metadata-eval74.8%
sub-neg74.8%
expm1-def98.7%
Simplified98.7%
Taylor expanded in z around 0 86.1%
associate-/l*87.3%
associate-/r/81.4%
Simplified81.4%
Final simplification76.2%
(FPCore (x y z t) :precision binary64 (if (<= z -1.25e+16) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.25e+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 <= (-1.25d+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 <= -1.25e+16) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.25e+16: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.25e+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 <= -1.25e+16) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.25e+16], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+16}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -1.25e16Initial program 80.4%
associate-+l-80.4%
sub-neg80.4%
log1p-def100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
neg-mul-1100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
metadata-eval100.0%
sub-neg100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in z around 0 11.8%
fma-def11.8%
associate-/l*11.4%
associate-/r/8.8%
unpow28.8%
+-commutative8.8%
mul-1-neg8.8%
unsub-neg8.8%
unpow28.8%
associate-/l*8.6%
associate-/r/8.9%
Simplified8.9%
Taylor expanded in z around inf 12.1%
unpow212.1%
*-commutative12.1%
associate-/l*11.7%
unpow211.7%
associate-/l*24.7%
associate-*r/24.7%
associate-/r*21.8%
*-commutative21.8%
associate-/r*21.8%
Simplified21.8%
Taylor expanded in y around 0 12.2%
associate-*r/12.2%
associate-*r*12.2%
unpow212.2%
Simplified12.2%
Taylor expanded in x around inf 62.2%
if -1.25e16 < z Initial program 50.3%
associate-+l-74.2%
sub-neg74.2%
log1p-def74.8%
neg-sub074.8%
associate-+l-74.8%
neg-sub074.8%
neg-mul-174.8%
*-commutative74.8%
distribute-rgt-out74.8%
+-commutative74.8%
metadata-eval74.8%
sub-neg74.8%
expm1-def98.7%
Simplified98.7%
Taylor expanded in y around 0 74.0%
associate-/l*71.8%
associate-/r/74.0%
expm1-def87.7%
Simplified87.7%
Taylor expanded in z around 0 87.3%
Final simplification80.5%
(FPCore (x y z t) :precision binary64 (if (<= z -7e+18) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7e+18) {
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 <= (-7d+18)) 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 <= -7e+18) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7e+18: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7e+18) 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 <= -7e+18) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -7e+18], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7 \cdot 10^{+18}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -7e18Initial program 80.4%
associate-+l-80.4%
sub-neg80.4%
log1p-def100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
neg-mul-1100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
metadata-eval100.0%
sub-neg100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in z around 0 11.8%
fma-def11.8%
associate-/l*11.4%
associate-/r/8.8%
unpow28.8%
+-commutative8.8%
mul-1-neg8.8%
unsub-neg8.8%
unpow28.8%
associate-/l*8.6%
associate-/r/8.9%
Simplified8.9%
Taylor expanded in z around inf 12.1%
unpow212.1%
*-commutative12.1%
associate-/l*11.7%
unpow211.7%
associate-/l*24.7%
associate-*r/24.7%
associate-/r*21.8%
*-commutative21.8%
associate-/r*21.8%
Simplified21.8%
Taylor expanded in y around 0 12.2%
associate-*r/12.2%
associate-*r*12.2%
unpow212.2%
Simplified12.2%
Taylor expanded in x around inf 62.2%
if -7e18 < z Initial program 50.3%
associate-+l-74.2%
sub-neg74.2%
log1p-def74.8%
neg-sub074.8%
associate-+l-74.8%
neg-sub074.8%
neg-mul-174.8%
*-commutative74.8%
distribute-rgt-out74.8%
+-commutative74.8%
metadata-eval74.8%
sub-neg74.8%
expm1-def98.7%
Simplified98.7%
Taylor expanded in z around 0 86.1%
associate-/l*87.3%
associate-/r/81.4%
Simplified81.4%
associate-*l/86.1%
associate-/l*87.3%
Applied egg-rr87.3%
Final simplification80.5%
(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.4%
associate-+l-75.8%
sub-neg75.8%
log1p-def81.6%
neg-sub081.6%
associate-+l-81.6%
neg-sub081.6%
neg-mul-181.6%
*-commutative81.6%
distribute-rgt-out81.6%
+-commutative81.6%
metadata-eval81.6%
sub-neg81.6%
expm1-def99.0%
Simplified99.0%
Taylor expanded in z around 0 57.7%
fma-def57.7%
associate-/l*52.4%
associate-/r/56.9%
unpow256.9%
+-commutative56.9%
mul-1-neg56.9%
unsub-neg56.9%
unpow256.9%
associate-/l*57.4%
associate-/r/55.3%
Simplified55.3%
Taylor expanded in z around inf 49.2%
unpow249.2%
*-commutative49.2%
associate-/l*47.1%
unpow247.1%
associate-/l*50.9%
associate-*r/50.9%
associate-/r*52.0%
*-commutative52.0%
associate-/r*52.0%
Simplified52.0%
Taylor expanded in y around 0 56.3%
associate-*r/56.3%
associate-*r*56.3%
unpow256.3%
Simplified56.3%
Taylor expanded in x around inf 69.9%
Final simplification69.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 2023238
(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)))