
(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
(let* ((t_0 (* y (log y))) (t_1 (exp (- x z))))
(if (<= t_0 400000000000.0)
(* (pow y y) t_1)
(if (<= t_0 2e+84) t_1 (exp (- t_0 z))))))
double code(double x, double y, double z) {
double t_0 = y * log(y);
double t_1 = exp((x - z));
double tmp;
if (t_0 <= 400000000000.0) {
tmp = pow(y, y) * t_1;
} else if (t_0 <= 2e+84) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = y * log(y)
t_1 = exp((x - z))
if (t_0 <= 400000000000.0d0) then
tmp = (y ** y) * t_1
else if (t_0 <= 2d+84) then
tmp = t_1
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 t_1 = Math.exp((x - z));
double tmp;
if (t_0 <= 400000000000.0) {
tmp = Math.pow(y, y) * t_1;
} else if (t_0 <= 2e+84) {
tmp = t_1;
} else {
tmp = Math.exp((t_0 - z));
}
return tmp;
}
def code(x, y, z): t_0 = y * math.log(y) t_1 = math.exp((x - z)) tmp = 0 if t_0 <= 400000000000.0: tmp = math.pow(y, y) * t_1 elif t_0 <= 2e+84: tmp = t_1 else: tmp = math.exp((t_0 - z)) return tmp
function code(x, y, z) t_0 = Float64(y * log(y)) t_1 = exp(Float64(x - z)) tmp = 0.0 if (t_0 <= 400000000000.0) tmp = Float64((y ^ y) * t_1); elseif (t_0 <= 2e+84) tmp = t_1; else tmp = exp(Float64(t_0 - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * log(y); t_1 = exp((x - z)); tmp = 0.0; if (t_0 <= 400000000000.0) tmp = (y ^ y) * t_1; elseif (t_0 <= 2e+84) tmp = t_1; 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]}, Block[{t$95$1 = N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 400000000000.0], N[(N[Power[y, y], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 2e+84], t$95$1, N[Exp[N[(t$95$0 - z), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \log y\\
t_1 := e^{x - z}\\
\mathbf{if}\;t_0 \leq 400000000000:\\
\;\;\;\;{y}^{y} \cdot t_1\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+84}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - z}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 4e11Initial program 100.0%
exp-diff87.2%
+-commutative87.2%
exp-sum87.2%
associate-*r/87.2%
*-commutative87.2%
exp-to-pow87.2%
exp-diff100.0%
Simplified100.0%
if 4e11 < (*.f64 y (log.f64 y)) < 2.00000000000000012e84Initial program 100.0%
Taylor expanded in x around inf 92.8%
if 2.00000000000000012e84 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in x around 0 92.7%
Final simplification96.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -32000000.0) (not (<= x 5.2e-7))) (exp (- x z)) (exp (- (* y (log y)) z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -32000000.0) || !(x <= 5.2e-7)) {
tmp = exp((x - z));
} else {
tmp = exp(((y * log(y)) - 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 <= (-32000000.0d0)) .or. (.not. (x <= 5.2d-7))) then
tmp = exp((x - z))
else
tmp = exp(((y * log(y)) - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -32000000.0) || !(x <= 5.2e-7)) {
tmp = Math.exp((x - z));
} else {
tmp = Math.exp(((y * Math.log(y)) - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -32000000.0) or not (x <= 5.2e-7): tmp = math.exp((x - z)) else: tmp = math.exp(((y * math.log(y)) - z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -32000000.0) || !(x <= 5.2e-7)) tmp = exp(Float64(x - z)); else tmp = exp(Float64(Float64(y * log(y)) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -32000000.0) || ~((x <= 5.2e-7))) tmp = exp((x - z)); else tmp = exp(((y * log(y)) - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -32000000.0], N[Not[LessEqual[x, 5.2e-7]], $MachinePrecision]], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -32000000 \lor \neg \left(x \leq 5.2 \cdot 10^{-7}\right):\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{y \cdot \log y - z}\\
\end{array}
\end{array}
if x < -3.2e7 or 5.19999999999999998e-7 < x Initial program 100.0%
Taylor expanded in x around inf 94.1%
if -3.2e7 < x < 5.19999999999999998e-7Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification96.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (exp (- z))))
(if (<= z -8e-15)
t_0
(if (<= z 1.1e-290)
(exp x)
(if (<= z 5.5e-242) (pow y y) (if (<= z 1.8e+36) (exp x) t_0))))))
double code(double x, double y, double z) {
double t_0 = exp(-z);
double tmp;
if (z <= -8e-15) {
tmp = t_0;
} else if (z <= 1.1e-290) {
tmp = exp(x);
} else if (z <= 5.5e-242) {
tmp = pow(y, y);
} else if (z <= 1.8e+36) {
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 <= (-8d-15)) then
tmp = t_0
else if (z <= 1.1d-290) then
tmp = exp(x)
else if (z <= 5.5d-242) then
tmp = y ** y
else if (z <= 1.8d+36) 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 <= -8e-15) {
tmp = t_0;
} else if (z <= 1.1e-290) {
tmp = Math.exp(x);
} else if (z <= 5.5e-242) {
tmp = Math.pow(y, y);
} else if (z <= 1.8e+36) {
tmp = Math.exp(x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.exp(-z) tmp = 0 if z <= -8e-15: tmp = t_0 elif z <= 1.1e-290: tmp = math.exp(x) elif z <= 5.5e-242: tmp = math.pow(y, y) elif z <= 1.8e+36: 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 <= -8e-15) tmp = t_0; elseif (z <= 1.1e-290) tmp = exp(x); elseif (z <= 5.5e-242) tmp = y ^ y; elseif (z <= 1.8e+36) 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 <= -8e-15) tmp = t_0; elseif (z <= 1.1e-290) tmp = exp(x); elseif (z <= 5.5e-242) tmp = y ^ y; elseif (z <= 1.8e+36) 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, -8e-15], t$95$0, If[LessEqual[z, 1.1e-290], N[Exp[x], $MachinePrecision], If[LessEqual[z, 5.5e-242], N[Power[y, y], $MachinePrecision], If[LessEqual[z, 1.8e+36], N[Exp[x], $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-z}\\
\mathbf{if}\;z \leq -8 \cdot 10^{-15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{-290}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{-242}:\\
\;\;\;\;{y}^{y}\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{+36}:\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -8.0000000000000006e-15 or 1.7999999999999999e36 < z Initial program 100.0%
Taylor expanded in x around 0 91.6%
Taylor expanded in y around 0 82.3%
if -8.0000000000000006e-15 < z < 1.1e-290 or 5.4999999999999998e-242 < z < 1.7999999999999999e36Initial program 100.0%
exp-diff96.8%
+-commutative96.8%
exp-sum88.7%
associate-*r/88.7%
*-commutative88.7%
exp-to-pow88.7%
exp-diff90.3%
Simplified90.3%
Taylor expanded in z around 0 91.9%
*-commutative91.9%
Simplified91.9%
Taylor expanded in y around 0 75.6%
if 1.1e-290 < z < 5.4999999999999998e-242Initial program 100.0%
Taylor expanded in x around 0 87.1%
Taylor expanded in z around 0 87.1%
Final simplification79.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -8e-15) (not (<= z 6.5e+39))) (exp (- z)) (exp x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8e-15) || !(z <= 6.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 <= (-8d-15)) .or. (.not. (z <= 6.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 <= -8e-15) || !(z <= 6.5e+39)) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8e-15) or not (z <= 6.5e+39): tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8e-15) || !(z <= 6.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 <= -8e-15) || ~((z <= 6.5e+39))) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8e-15], N[Not[LessEqual[z, 6.5e+39]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{-15} \lor \neg \left(z \leq 6.5 \cdot 10^{+39}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if z < -8.0000000000000006e-15 or 6.5000000000000001e39 < z Initial program 100.0%
Taylor expanded in x around 0 91.6%
Taylor expanded in y around 0 82.3%
if -8.0000000000000006e-15 < z < 6.5000000000000001e39Initial program 100.0%
exp-diff97.1%
+-commutative97.1%
exp-sum88.5%
associate-*r/88.5%
*-commutative88.5%
exp-to-pow88.5%
exp-diff89.9%
Simplified89.9%
Taylor expanded in z around 0 91.4%
*-commutative91.4%
Simplified91.4%
Taylor expanded in y around 0 71.9%
Final simplification76.7%
(FPCore (x y z) :precision binary64 (if (<= y 5.3e+98) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.3e+98) {
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 <= 5.3d+98) 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 <= 5.3e+98) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5.3e+98: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5.3e+98) 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 <= 5.3e+98) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5.3e+98], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.3 \cdot 10^{+98}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 5.29999999999999997e98Initial program 100.0%
Taylor expanded in x around inf 95.6%
if 5.29999999999999997e98 < y Initial program 100.0%
Taylor expanded in x around 0 93.2%
Taylor expanded in z around 0 86.3%
Final simplification93.0%
(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%
exp-diff80.5%
+-commutative80.5%
exp-sum73.8%
associate-*r/73.8%
*-commutative73.8%
exp-to-pow73.8%
exp-diff84.4%
Simplified84.4%
Taylor expanded in z around 0 69.7%
*-commutative69.7%
Simplified69.7%
Taylor expanded in y around 0 54.8%
Final simplification54.8%
(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 2023326
(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)))