
(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 7 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 (if (or (<= x -36000000.0) (not (<= x 4.3e-62))) (exp (- x z)) (/ (pow y y) (exp z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -36000000.0) || !(x <= 4.3e-62)) {
tmp = exp((x - z));
} else {
tmp = pow(y, y) / exp(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) :: tmp
if ((x <= (-36000000.0d0)) .or. (.not. (x <= 4.3d-62))) then
tmp = exp((x - z))
else
tmp = (y ** y) / exp(z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -36000000.0) || !(x <= 4.3e-62)) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y) / Math.exp(z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -36000000.0) or not (x <= 4.3e-62): tmp = math.exp((x - z)) else: tmp = math.pow(y, y) / math.exp(z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -36000000.0) || !(x <= 4.3e-62)) tmp = exp(Float64(x - z)); else tmp = Float64((y ^ y) / exp(z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -36000000.0) || ~((x <= 4.3e-62))) tmp = exp((x - z)); else tmp = (y ^ y) / exp(z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -36000000.0], N[Not[LessEqual[x, 4.3e-62]], $MachinePrecision]], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[(N[Power[y, y], $MachinePrecision] / N[Exp[z], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -36000000 \lor \neg \left(x \leq 4.3 \cdot 10^{-62}\right):\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{{y}^{y}}{e^{z}}\\
\end{array}
\end{array}
if x < -3.6e7 or 4.2999999999999997e-62 < x Initial program 100.0%
Taylor expanded in x around inf 91.5%
if -3.6e7 < x < 4.2999999999999997e-62Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum87.3%
*-commutative87.3%
exp-to-pow87.3%
Simplified87.3%
Taylor expanded in x around 0 87.4%
exp-neg87.4%
associate-*l/87.4%
*-lft-identity87.4%
Simplified87.4%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (exp (- x z)))) (if (<= y 1.05e+72) (* (pow y y) t_0) (if (<= y 1e+242) t_0 (pow y y)))))
double code(double x, double y, double z) {
double t_0 = exp((x - z));
double tmp;
if (y <= 1.05e+72) {
tmp = pow(y, y) * t_0;
} else if (y <= 1e+242) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = exp((x - z))
if (y <= 1.05d+72) then
tmp = (y ** y) * t_0
else if (y <= 1d+242) then
tmp = t_0
else
tmp = y ** y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.exp((x - z));
double tmp;
if (y <= 1.05e+72) {
tmp = Math.pow(y, y) * t_0;
} else if (y <= 1e+242) {
tmp = t_0;
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): t_0 = math.exp((x - z)) tmp = 0 if y <= 1.05e+72: tmp = math.pow(y, y) * t_0 elif y <= 1e+242: tmp = t_0 else: tmp = math.pow(y, y) return tmp
function code(x, y, z) t_0 = exp(Float64(x - z)) tmp = 0.0 if (y <= 1.05e+72) tmp = Float64((y ^ y) * t_0); elseif (y <= 1e+242) tmp = t_0; else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) t_0 = exp((x - z)); tmp = 0.0; if (y <= 1.05e+72) tmp = (y ^ y) * t_0; elseif (y <= 1e+242) tmp = t_0; else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 1.05e+72], N[(N[Power[y, y], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[y, 1e+242], t$95$0, N[Power[y, y], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{x - z}\\
\mathbf{if}\;y \leq 1.05 \cdot 10^{+72}:\\
\;\;\;\;{y}^{y} \cdot t_0\\
\mathbf{elif}\;y \leq 10^{+242}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 1.0500000000000001e72Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum97.7%
*-commutative97.7%
exp-to-pow97.7%
Simplified97.7%
if 1.0500000000000001e72 < y < 1.00000000000000005e242Initial program 100.0%
Taylor expanded in x around inf 74.0%
if 1.00000000000000005e242 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum52.6%
*-commutative52.6%
exp-to-pow52.6%
Simplified52.6%
Taylor expanded in z around 0 73.8%
Taylor expanded in x around 0 94.8%
Final simplification91.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (exp (- z))))
(if (<= x -20.0)
(exp x)
(if (<= x 1.25e-279)
t_0
(if (<= x 8.5e-102) (pow y y) (if (<= x 9.6e+74) t_0 (exp x)))))))
double code(double x, double y, double z) {
double t_0 = exp(-z);
double tmp;
if (x <= -20.0) {
tmp = exp(x);
} else if (x <= 1.25e-279) {
tmp = t_0;
} else if (x <= 8.5e-102) {
tmp = pow(y, y);
} else if (x <= 9.6e+74) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = exp(-z)
if (x <= (-20.0d0)) then
tmp = exp(x)
else if (x <= 1.25d-279) then
tmp = t_0
else if (x <= 8.5d-102) then
tmp = y ** y
else if (x <= 9.6d+74) then
tmp = t_0
else
tmp = exp(x)
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 (x <= -20.0) {
tmp = Math.exp(x);
} else if (x <= 1.25e-279) {
tmp = t_0;
} else if (x <= 8.5e-102) {
tmp = Math.pow(y, y);
} else if (x <= 9.6e+74) {
tmp = t_0;
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): t_0 = math.exp(-z) tmp = 0 if x <= -20.0: tmp = math.exp(x) elif x <= 1.25e-279: tmp = t_0 elif x <= 8.5e-102: tmp = math.pow(y, y) elif x <= 9.6e+74: tmp = t_0 else: tmp = math.exp(x) return tmp
function code(x, y, z) t_0 = exp(Float64(-z)) tmp = 0.0 if (x <= -20.0) tmp = exp(x); elseif (x <= 1.25e-279) tmp = t_0; elseif (x <= 8.5e-102) tmp = y ^ y; elseif (x <= 9.6e+74) tmp = t_0; else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = exp(-z); tmp = 0.0; if (x <= -20.0) tmp = exp(x); elseif (x <= 1.25e-279) tmp = t_0; elseif (x <= 8.5e-102) tmp = y ^ y; elseif (x <= 9.6e+74) tmp = t_0; else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Exp[(-z)], $MachinePrecision]}, If[LessEqual[x, -20.0], N[Exp[x], $MachinePrecision], If[LessEqual[x, 1.25e-279], t$95$0, If[LessEqual[x, 8.5e-102], N[Power[y, y], $MachinePrecision], If[LessEqual[x, 9.6e+74], t$95$0, N[Exp[x], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-z}\\
\mathbf{if}\;x \leq -20:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-279}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-102}:\\
\;\;\;\;{y}^{y}\\
\mathbf{elif}\;x \leq 9.6 \cdot 10^{+74}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if x < -20 or 9.60000000000000034e74 < x Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum74.8%
*-commutative74.8%
exp-to-pow74.8%
Simplified74.8%
Taylor expanded in z around 0 68.4%
Taylor expanded in y around 0 84.0%
if -20 < x < 1.24999999999999992e-279 or 8.49999999999999973e-102 < x < 9.60000000000000034e74Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum88.7%
*-commutative88.7%
exp-to-pow88.7%
Simplified88.7%
Taylor expanded in x around 0 87.7%
exp-neg87.7%
associate-*l/87.7%
*-lft-identity87.7%
Simplified87.7%
Taylor expanded in y around 0 80.7%
rec-exp80.7%
Simplified80.7%
if 1.24999999999999992e-279 < x < 8.49999999999999973e-102Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum80.6%
*-commutative80.6%
exp-to-pow80.6%
Simplified80.6%
Taylor expanded in z around 0 79.8%
Taylor expanded in x around 0 79.8%
Final simplification82.1%
(FPCore (x y z) :precision binary64 (if (or (<= y 3.4e+19) (and (not (<= y 1.2e+70)) (<= y 1e+242))) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= 3.4e+19) || (!(y <= 1.2e+70) && (y <= 1e+242))) {
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 <= 3.4d+19) .or. (.not. (y <= 1.2d+70)) .and. (y <= 1d+242)) 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 <= 3.4e+19) || (!(y <= 1.2e+70) && (y <= 1e+242))) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= 3.4e+19) or (not (y <= 1.2e+70) and (y <= 1e+242)): tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= 3.4e+19) || (!(y <= 1.2e+70) && (y <= 1e+242))) 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 <= 3.4e+19) || (~((y <= 1.2e+70)) && (y <= 1e+242))) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, 3.4e+19], And[N[Not[LessEqual[y, 1.2e+70]], $MachinePrecision], LessEqual[y, 1e+242]]], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.4 \cdot 10^{+19} \lor \neg \left(y \leq 1.2 \cdot 10^{+70}\right) \land y \leq 10^{+242}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 3.4e19 or 1.19999999999999993e70 < y < 1.00000000000000005e242Initial program 100.0%
Taylor expanded in x around inf 91.0%
if 3.4e19 < y < 1.19999999999999993e70 or 1.00000000000000005e242 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum71.4%
*-commutative71.4%
exp-to-pow71.4%
Simplified71.4%
Taylor expanded in z around 0 78.6%
Taylor expanded in x around 0 90.6%
Final simplification90.9%
(FPCore (x y z) :precision binary64 (if (<= x -10.2) (exp x) (if (<= x 5e+64) (exp (- z)) (exp x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -10.2) {
tmp = exp(x);
} else if (x <= 5e+64) {
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 (x <= (-10.2d0)) then
tmp = exp(x)
else if (x <= 5d+64) 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 (x <= -10.2) {
tmp = Math.exp(x);
} else if (x <= 5e+64) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -10.2: tmp = math.exp(x) elif x <= 5e+64: tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -10.2) tmp = exp(x); elseif (x <= 5e+64) tmp = exp(Float64(-z)); else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -10.2) tmp = exp(x); elseif (x <= 5e+64) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -10.2], N[Exp[x], $MachinePrecision], If[LessEqual[x, 5e+64], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10.2:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+64}:\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if x < -10.199999999999999 or 5e64 < x Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum74.8%
*-commutative74.8%
exp-to-pow74.8%
Simplified74.8%
Taylor expanded in z around 0 68.4%
Taylor expanded in y around 0 84.0%
if -10.199999999999999 < x < 5e64Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum86.5%
*-commutative86.5%
exp-to-pow86.5%
Simplified86.5%
Taylor expanded in x around 0 85.7%
exp-neg85.7%
associate-*l/85.7%
*-lft-identity85.7%
Simplified85.7%
Taylor expanded in y around 0 75.4%
rec-exp75.4%
Simplified75.4%
Final simplification79.5%
(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-sum80.9%
*-commutative80.9%
exp-to-pow80.9%
Simplified80.9%
Taylor expanded in z around 0 67.9%
Taylor expanded in y around 0 57.0%
Final simplification57.0%
(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 2023192
(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)))