
(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 9 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 (<= z -4.6e+56) (not (<= z 3.7e+77))) (exp (- z)) (exp (+ x (* y (log y))))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.6e+56) || !(z <= 3.7e+77)) {
tmp = exp(-z);
} else {
tmp = exp((x + (y * log(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 ((z <= (-4.6d+56)) .or. (.not. (z <= 3.7d+77))) then
tmp = exp(-z)
else
tmp = exp((x + (y * log(y))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.6e+56) || !(z <= 3.7e+77)) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp((x + (y * Math.log(y))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.6e+56) or not (z <= 3.7e+77): tmp = math.exp(-z) else: tmp = math.exp((x + (y * math.log(y)))) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.6e+56) || !(z <= 3.7e+77)) tmp = exp(Float64(-z)); else tmp = exp(Float64(x + Float64(y * log(y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.6e+56) || ~((z <= 3.7e+77))) tmp = exp(-z); else tmp = exp((x + (y * log(y)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.6e+56], N[Not[LessEqual[z, 3.7e+77]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[Exp[N[(x + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{+56} \lor \neg \left(z \leq 3.7 \cdot 10^{+77}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x + y \cdot \log y}\\
\end{array}
\end{array}
if z < -4.60000000000000029e56 or 3.69999999999999995e77 < z Initial program 100.0%
Taylor expanded in z around inf 92.4%
neg-mul-192.4%
Simplified92.4%
if -4.60000000000000029e56 < z < 3.69999999999999995e77Initial program 100.0%
Taylor expanded in z around 0 94.8%
Final simplification93.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.4e+47) (not (<= z 3.1e+75))) (exp (- z)) (* (pow y y) (exp x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.4e+47) || !(z <= 3.1e+75)) {
tmp = exp(-z);
} else {
tmp = pow(y, y) * 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 <= (-3.4d+47)) .or. (.not. (z <= 3.1d+75))) then
tmp = exp(-z)
else
tmp = (y ** y) * exp(x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3.4e+47) || !(z <= 3.1e+75)) {
tmp = Math.exp(-z);
} else {
tmp = Math.pow(y, y) * Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.4e+47) or not (z <= 3.1e+75): tmp = math.exp(-z) else: tmp = math.pow(y, y) * math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.4e+47) || !(z <= 3.1e+75)) tmp = exp(Float64(-z)); else tmp = Float64((y ^ y) * exp(x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.4e+47) || ~((z <= 3.1e+75))) tmp = exp(-z); else tmp = (y ^ y) * exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.4e+47], N[Not[LessEqual[z, 3.1e+75]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[(N[Power[y, y], $MachinePrecision] * N[Exp[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{+47} \lor \neg \left(z \leq 3.1 \cdot 10^{+75}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y} \cdot e^{x}\\
\end{array}
\end{array}
if z < -3.3999999999999998e47 or 3.1000000000000001e75 < z Initial program 100.0%
Taylor expanded in z around inf 91.6%
neg-mul-191.6%
Simplified91.6%
if -3.3999999999999998e47 < z < 3.1000000000000001e75Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum84.1%
*-commutative84.1%
exp-to-pow84.1%
Simplified84.1%
Taylor expanded in z around 0 80.8%
*-commutative80.8%
Simplified80.8%
Final simplification85.2%
(FPCore (x y z) :precision binary64 (if (<= x -6.3e+25) (exp x) (if (<= x 370.0) (/ (pow y y) (exp z)) (* (pow y y) (exp x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6.3e+25) {
tmp = exp(x);
} else if (x <= 370.0) {
tmp = pow(y, y) / exp(z);
} else {
tmp = pow(y, y) * 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 <= (-6.3d+25)) then
tmp = exp(x)
else if (x <= 370.0d0) then
tmp = (y ** y) / exp(z)
else
tmp = (y ** y) * exp(x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -6.3e+25) {
tmp = Math.exp(x);
} else if (x <= 370.0) {
tmp = Math.pow(y, y) / Math.exp(z);
} else {
tmp = Math.pow(y, y) * Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -6.3e+25: tmp = math.exp(x) elif x <= 370.0: tmp = math.pow(y, y) / math.exp(z) else: tmp = math.pow(y, y) * math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -6.3e+25) tmp = exp(x); elseif (x <= 370.0) tmp = Float64((y ^ y) / exp(z)); else tmp = Float64((y ^ y) * exp(x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -6.3e+25) tmp = exp(x); elseif (x <= 370.0) tmp = (y ^ y) / exp(z); else tmp = (y ^ y) * exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -6.3e+25], N[Exp[x], $MachinePrecision], If[LessEqual[x, 370.0], N[(N[Power[y, y], $MachinePrecision] / N[Exp[z], $MachinePrecision]), $MachinePrecision], N[(N[Power[y, y], $MachinePrecision] * N[Exp[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.3 \cdot 10^{+25}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;x \leq 370:\\
\;\;\;\;\frac{{y}^{y}}{e^{z}}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y} \cdot e^{x}\\
\end{array}
\end{array}
if x < -6.29999999999999973e25Initial program 100.0%
Taylor expanded in x around inf 72.1%
if -6.29999999999999973e25 < x < 370Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum88.3%
*-commutative88.3%
exp-to-pow88.3%
Simplified88.3%
Taylor expanded in x around 0 88.5%
rec-exp88.5%
associate-*l/88.5%
*-lft-identity88.5%
Simplified88.5%
if 370 < x Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum97.0%
*-commutative97.0%
exp-to-pow97.0%
Simplified97.0%
Taylor expanded in z around 0 88.2%
*-commutative88.2%
Simplified88.2%
Final simplification84.6%
(FPCore (x y z) :precision binary64 (if (<= y 0.0003) (* (pow y y) (exp (- x z))) (exp (+ x (* y (log y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.0003) {
tmp = pow(y, y) * exp((x - z));
} else {
tmp = exp((x + (y * log(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 <= 0.0003d0) then
tmp = (y ** y) * exp((x - z))
else
tmp = exp((x + (y * log(y))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 0.0003) {
tmp = Math.pow(y, y) * Math.exp((x - z));
} else {
tmp = Math.exp((x + (y * Math.log(y))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 0.0003: tmp = math.pow(y, y) * math.exp((x - z)) else: tmp = math.exp((x + (y * math.log(y)))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 0.0003) tmp = Float64((y ^ y) * exp(Float64(x - z))); else tmp = exp(Float64(x + Float64(y * log(y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 0.0003) tmp = (y ^ y) * exp((x - z)); else tmp = exp((x + (y * log(y)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 0.0003], N[(N[Power[y, y], $MachinePrecision] * N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(x + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.0003:\\
\;\;\;\;{y}^{y} \cdot e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{x + y \cdot \log y}\\
\end{array}
\end{array}
if y < 2.99999999999999974e-4Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum100.0%
*-commutative100.0%
exp-to-pow100.0%
Simplified100.0%
if 2.99999999999999974e-4 < y Initial program 100.0%
Taylor expanded in z around 0 88.8%
Final simplification94.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (exp (- z))))
(if (<= z -4200000000.0)
t_0
(if (<= z 3.1e-282) (pow y y) (if (<= z 1.6e+68) (exp x) t_0)))))
double code(double x, double y, double z) {
double t_0 = exp(-z);
double tmp;
if (z <= -4200000000.0) {
tmp = t_0;
} else if (z <= 3.1e-282) {
tmp = pow(y, y);
} else if (z <= 1.6e+68) {
tmp = exp(x);
} 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 <= (-4200000000.0d0)) then
tmp = t_0
else if (z <= 3.1d-282) then
tmp = y ** y
else if (z <= 1.6d+68) then
tmp = exp(x)
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 <= -4200000000.0) {
tmp = t_0;
} else if (z <= 3.1e-282) {
tmp = Math.pow(y, y);
} else if (z <= 1.6e+68) {
tmp = Math.exp(x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.exp(-z) tmp = 0 if z <= -4200000000.0: tmp = t_0 elif z <= 3.1e-282: tmp = math.pow(y, y) elif z <= 1.6e+68: tmp = math.exp(x) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = exp(Float64(-z)) tmp = 0.0 if (z <= -4200000000.0) tmp = t_0; elseif (z <= 3.1e-282) tmp = y ^ y; elseif (z <= 1.6e+68) tmp = exp(x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = exp(-z); tmp = 0.0; if (z <= -4200000000.0) tmp = t_0; elseif (z <= 3.1e-282) tmp = y ^ y; elseif (z <= 1.6e+68) tmp = exp(x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Exp[(-z)], $MachinePrecision]}, If[LessEqual[z, -4200000000.0], t$95$0, If[LessEqual[z, 3.1e-282], N[Power[y, y], $MachinePrecision], If[LessEqual[z, 1.6e+68], N[Exp[x], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-z}\\
\mathbf{if}\;z \leq -4200000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 3.1 \cdot 10^{-282}:\\
\;\;\;\;{y}^{y}\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+68}:\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -4.2e9 or 1.59999999999999997e68 < z Initial program 100.0%
Taylor expanded in z around inf 89.8%
neg-mul-189.8%
Simplified89.8%
if -4.2e9 < z < 3.10000000000000013e-282Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum82.3%
*-commutative82.3%
exp-to-pow82.3%
Simplified82.3%
Taylor expanded in z around 0 81.6%
*-commutative81.6%
Simplified81.6%
Taylor expanded in x around 0 70.7%
if 3.10000000000000013e-282 < z < 1.59999999999999997e68Initial program 100.0%
Taylor expanded in x around inf 69.8%
Final simplification79.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -450000000000.0) (not (<= z 1.8e+66))) (exp (- z)) (exp x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -450000000000.0) || !(z <= 1.8e+66)) {
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 <= (-450000000000.0d0)) .or. (.not. (z <= 1.8d+66))) 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 <= -450000000000.0) || !(z <= 1.8e+66)) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -450000000000.0) or not (z <= 1.8e+66): tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -450000000000.0) || !(z <= 1.8e+66)) tmp = exp(Float64(-z)); else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -450000000000.0) || ~((z <= 1.8e+66))) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -450000000000.0], N[Not[LessEqual[z, 1.8e+66]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -450000000000 \lor \neg \left(z \leq 1.8 \cdot 10^{+66}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if z < -4.5e11 or 1.8e66 < z Initial program 100.0%
Taylor expanded in z around inf 90.5%
neg-mul-190.5%
Simplified90.5%
if -4.5e11 < z < 1.8e66Initial program 100.0%
Taylor expanded in x around inf 65.7%
Final simplification76.8%
(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%
Taylor expanded in x around inf 52.9%
Final simplification52.9%
(FPCore (x y z) :precision binary64 (+ x 1.0))
double code(double x, double y, double z) {
return x + 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + 1.0d0
end function
public static double code(double x, double y, double z) {
return x + 1.0;
}
def code(x, y, z): return x + 1.0
function code(x, y, z) return Float64(x + 1.0) end
function tmp = code(x, y, z) tmp = x + 1.0; end
code[x_, y_, z_] := N[(x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
x + 1
\end{array}
Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum82.8%
*-commutative82.8%
exp-to-pow82.8%
Simplified82.8%
Taylor expanded in z around 0 66.1%
*-commutative66.1%
Simplified66.1%
Taylor expanded in x around 0 33.6%
distribute-lft1-in43.1%
*-commutative43.1%
Simplified43.1%
Taylor expanded in y around 0 14.0%
Final simplification14.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 2023293
(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)))