
(FPCore (x y z) :precision binary64 (exp (- (+ x (* y (log y))) z)))
double code(double x, double y, double z) {
return exp(((x + (y * log(y))) - z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = exp(((x + (y * log(y))) - z))
end function
public static double code(double x, double y, double z) {
return Math.exp(((x + (y * Math.log(y))) - z));
}
def code(x, y, z): return math.exp(((x + (y * math.log(y))) - z))
function code(x, y, z) return exp(Float64(Float64(x + Float64(y * log(y))) - z)) end
function tmp = code(x, y, z) tmp = exp(((x + (y * log(y))) - z)); end
code[x_, y_, z_] := N[Exp[N[(N[(x + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(x + y \cdot \log y\right) - z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (exp (- (+ x (* y (log y))) z)))
double code(double x, double y, double z) {
return exp(((x + (y * log(y))) - z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = exp(((x + (y * log(y))) - z))
end function
public static double code(double x, double y, double z) {
return Math.exp(((x + (y * Math.log(y))) - z));
}
def code(x, y, z): return math.exp(((x + (y * math.log(y))) - z))
function code(x, y, z) return exp(Float64(Float64(x + Float64(y * log(y))) - z)) end
function tmp = code(x, y, z) tmp = exp(((x + (y * log(y))) - z)); end
code[x_, y_, z_] := N[Exp[N[(N[(x + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(x + y \cdot \log y\right) - z}
\end{array}
(FPCore (x y z) :precision binary64 (exp (- (+ x (* y (log y))) z)))
double code(double x, double y, double z) {
return exp(((x + (y * log(y))) - z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = exp(((x + (y * log(y))) - z))
end function
public static double code(double x, double y, double z) {
return Math.exp(((x + (y * Math.log(y))) - z));
}
def code(x, y, z): return math.exp(((x + (y * math.log(y))) - z))
function code(x, y, z) return exp(Float64(Float64(x + Float64(y * log(y))) - z)) end
function tmp = code(x, y, z) tmp = exp(((x + (y * log(y))) - z)); end
code[x_, y_, z_] := N[Exp[N[(N[(x + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(x + y \cdot \log y\right) - z}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* y (log y)))) (if (<= t_0 5e+63) (exp (- x z)) (exp (- t_0 z)))))
double code(double x, double y, double z) {
double t_0 = y * log(y);
double tmp;
if (t_0 <= 5e+63) {
tmp = exp((x - z));
} else {
tmp = exp((t_0 - z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y * log(y)
if (t_0 <= 5d+63) then
tmp = exp((x - z))
else
tmp = exp((t_0 - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * Math.log(y);
double tmp;
if (t_0 <= 5e+63) {
tmp = Math.exp((x - z));
} else {
tmp = Math.exp((t_0 - z));
}
return tmp;
}
def code(x, y, z): t_0 = y * math.log(y) tmp = 0 if t_0 <= 5e+63: tmp = math.exp((x - z)) else: tmp = math.exp((t_0 - z)) return tmp
function code(x, y, z) t_0 = Float64(y * log(y)) tmp = 0.0 if (t_0 <= 5e+63) tmp = exp(Float64(x - z)); else tmp = exp(Float64(t_0 - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * log(y); tmp = 0.0; if (t_0 <= 5e+63) tmp = exp((x - z)); else tmp = exp((t_0 - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+63], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Exp[N[(t$95$0 - z), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \log y\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{+63}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - z}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 5.00000000000000011e63Initial program 100.0%
Taylor expanded in x around inf 97.5%
if 5.00000000000000011e63 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in x around 0 97.3%
Final simplification97.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (exp (- z))))
(if (<= z -12500000000000.0)
t_0
(if (<= z -1.3e-132) (exp x) (if (<= z 1.1e+41) (pow y y) t_0)))))
double code(double x, double y, double z) {
double t_0 = exp(-z);
double tmp;
if (z <= -12500000000000.0) {
tmp = t_0;
} else if (z <= -1.3e-132) {
tmp = exp(x);
} else if (z <= 1.1e+41) {
tmp = pow(y, y);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-z)
if (z <= (-12500000000000.0d0)) then
tmp = t_0
else if (z <= (-1.3d-132)) then
tmp = exp(x)
else if (z <= 1.1d+41) then
tmp = y ** y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.exp(-z);
double tmp;
if (z <= -12500000000000.0) {
tmp = t_0;
} else if (z <= -1.3e-132) {
tmp = Math.exp(x);
} else if (z <= 1.1e+41) {
tmp = Math.pow(y, y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.exp(-z) tmp = 0 if z <= -12500000000000.0: tmp = t_0 elif z <= -1.3e-132: tmp = math.exp(x) elif z <= 1.1e+41: tmp = math.pow(y, y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = exp(Float64(-z)) tmp = 0.0 if (z <= -12500000000000.0) tmp = t_0; elseif (z <= -1.3e-132) tmp = exp(x); elseif (z <= 1.1e+41) tmp = y ^ y; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = exp(-z); tmp = 0.0; if (z <= -12500000000000.0) tmp = t_0; elseif (z <= -1.3e-132) tmp = exp(x); elseif (z <= 1.1e+41) tmp = y ^ y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Exp[(-z)], $MachinePrecision]}, If[LessEqual[z, -12500000000000.0], t$95$0, If[LessEqual[z, -1.3e-132], N[Exp[x], $MachinePrecision], If[LessEqual[z, 1.1e+41], N[Power[y, y], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-z}\\
\mathbf{if}\;z \leq -12500000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.3 \cdot 10^{-132}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{+41}:\\
\;\;\;\;{y}^{y}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -1.25e13 or 1.09999999999999995e41 < z Initial program 100.0%
Taylor expanded in x around 0 97.4%
Taylor expanded in y around 0 90.5%
neg-mul-190.5%
Simplified90.5%
if -1.25e13 < z < -1.3e-132Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum85.7%
*-commutative85.7%
exp-to-pow85.7%
Simplified85.7%
Taylor expanded in z around 0 83.7%
*-commutative83.7%
Simplified83.7%
Taylor expanded in y around 0 70.0%
if -1.3e-132 < z < 1.09999999999999995e41Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum85.0%
*-commutative85.0%
exp-to-pow85.0%
Simplified85.0%
Taylor expanded in z around 0 85.1%
*-commutative85.1%
Simplified85.1%
Taylor expanded in x around 0 74.6%
Final simplification81.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -12500000000000.0) (not (<= z 9.5e+39))) (exp (- z)) (exp x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -12500000000000.0) || !(z <= 9.5e+39)) {
tmp = exp(-z);
} else {
tmp = exp(x);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-12500000000000.0d0)) .or. (.not. (z <= 9.5d+39))) then
tmp = exp(-z)
else
tmp = exp(x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -12500000000000.0) || !(z <= 9.5e+39)) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -12500000000000.0) or not (z <= 9.5e+39): tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -12500000000000.0) || !(z <= 9.5e+39)) tmp = exp(Float64(-z)); else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -12500000000000.0) || ~((z <= 9.5e+39))) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -12500000000000.0], N[Not[LessEqual[z, 9.5e+39]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -12500000000000 \lor \neg \left(z \leq 9.5 \cdot 10^{+39}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if z < -1.25e13 or 9.50000000000000011e39 < z Initial program 100.0%
Taylor expanded in x around 0 97.4%
Taylor expanded in y around 0 90.5%
neg-mul-190.5%
Simplified90.5%
if -1.25e13 < z < 9.50000000000000011e39Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum85.2%
*-commutative85.2%
exp-to-pow85.2%
Simplified85.2%
Taylor expanded in z around 0 84.7%
*-commutative84.7%
Simplified84.7%
Taylor expanded in y around 0 65.9%
Final simplification76.8%
(FPCore (x y z) :precision binary64 (if (<= y 2.8e+64) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.8e+64) {
tmp = exp((x - z));
} else {
tmp = pow(y, y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 2.8d+64) then
tmp = exp((x - z))
else
tmp = y ** y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.8e+64) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.8e+64: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.8e+64) tmp = exp(Float64(x - z)); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.8e+64) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.8e+64], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{+64}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 2.80000000000000024e64Initial program 100.0%
Taylor expanded in x around inf 96.9%
if 2.80000000000000024e64 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum66.7%
*-commutative66.7%
exp-to-pow66.7%
Simplified66.7%
Taylor expanded in z around 0 72.5%
*-commutative72.5%
Simplified72.5%
Taylor expanded in x around 0 88.8%
Final simplification93.6%
(FPCore (x y z) :precision binary64 (exp x))
double code(double x, double y, double z) {
return exp(x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = exp(x)
end function
public static double code(double x, double y, double z) {
return Math.exp(x);
}
def code(x, y, z): return math.exp(x)
function code(x, y, z) return exp(x) end
function tmp = code(x, y, z) tmp = exp(x); end
code[x_, y_, z_] := N[Exp[x], $MachinePrecision]
\begin{array}{l}
\\
e^{x}
\end{array}
Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum81.3%
*-commutative81.3%
exp-to-pow81.3%
Simplified81.3%
Taylor expanded in z around 0 67.8%
*-commutative67.8%
Simplified67.8%
Taylor expanded in y around 0 50.3%
Final simplification50.3%
(FPCore (x y z) :precision binary64 (exp (+ (- x z) (* (log y) y))))
double code(double x, double y, double z) {
return exp(((x - z) + (log(y) * y)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = exp(((x - z) + (log(y) * y)))
end function
public static double code(double x, double y, double z) {
return Math.exp(((x - z) + (Math.log(y) * y)));
}
def code(x, y, z): return math.exp(((x - z) + (math.log(y) * y)))
function code(x, y, z) return exp(Float64(Float64(x - z) + Float64(log(y) * y))) end
function tmp = code(x, y, z) tmp = exp(((x - z) + (log(y) * y))); end
code[x_, y_, z_] := N[Exp[N[(N[(x - z), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(x - z\right) + \log y \cdot y}
\end{array}
herbie shell --seed 2023308
(FPCore (x y z)
:name "Statistics.Distribution.Poisson.Internal:probability from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(exp (+ (- x z) (* (log y) y)))
(exp (- (+ x (* y (log y))) z)))