
(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 (if (or (<= x -6.2e+61) (not (<= x 1.5e-12))) (exp (- x z)) (exp (- (* y (log y)) z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6.2e+61) || !(x <= 1.5e-12)) {
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 <= (-6.2d+61)) .or. (.not. (x <= 1.5d-12))) 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 <= -6.2e+61) || !(x <= 1.5e-12)) {
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 <= -6.2e+61) or not (x <= 1.5e-12): 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 <= -6.2e+61) || !(x <= 1.5e-12)) 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 <= -6.2e+61) || ~((x <= 1.5e-12))) tmp = exp((x - z)); else tmp = exp(((y * log(y)) - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -6.2e+61], N[Not[LessEqual[x, 1.5e-12]], $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 -6.2 \cdot 10^{+61} \lor \neg \left(x \leq 1.5 \cdot 10^{-12}\right):\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{y \cdot \log y - z}\\
\end{array}
\end{array}
if x < -6.1999999999999998e61 or 1.5000000000000001e-12 < x Initial program 100.0%
Taylor expanded in y around 0 95.9%
if -6.1999999999999998e61 < x < 1.5000000000000001e-12Initial program 100.0%
Taylor expanded in x around 0 98.9%
Final simplification97.5%
(FPCore (x y z) :precision binary64 (if (or (<= y 3.7e+58) (and (not (<= y 3.2e+119)) (<= y 2.4e+131))) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= 3.7e+58) || (!(y <= 3.2e+119) && (y <= 2.4e+131))) {
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.7d+58) .or. (.not. (y <= 3.2d+119)) .and. (y <= 2.4d+131)) 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.7e+58) || (!(y <= 3.2e+119) && (y <= 2.4e+131))) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= 3.7e+58) or (not (y <= 3.2e+119) and (y <= 2.4e+131)): tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= 3.7e+58) || (!(y <= 3.2e+119) && (y <= 2.4e+131))) 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.7e+58) || (~((y <= 3.2e+119)) && (y <= 2.4e+131))) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, 3.7e+58], And[N[Not[LessEqual[y, 3.2e+119]], $MachinePrecision], LessEqual[y, 2.4e+131]]], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.7 \cdot 10^{+58} \lor \neg \left(y \leq 3.2 \cdot 10^{+119}\right) \land y \leq 2.4 \cdot 10^{+131}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 3.7000000000000002e58 or 3.19999999999999989e119 < y < 2.3999999999999999e131Initial program 100.0%
Taylor expanded in y around 0 96.4%
if 3.7000000000000002e58 < y < 3.19999999999999989e119 or 2.3999999999999999e131 < y Initial program 100.0%
Taylor expanded in x around 0 96.0%
Taylor expanded in z around 0 86.1%
Final simplification92.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.5e-5) (not (<= z 28000000000.0))) (exp (- z)) (exp x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.5e-5) || !(z <= 28000000000.0)) {
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 <= (-5.5d-5)) .or. (.not. (z <= 28000000000.0d0))) 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 <= -5.5e-5) || !(z <= 28000000000.0)) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.5e-5) or not (z <= 28000000000.0): tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.5e-5) || !(z <= 28000000000.0)) tmp = exp(Float64(-z)); else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.5e-5) || ~((z <= 28000000000.0))) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.5e-5], N[Not[LessEqual[z, 28000000000.0]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{-5} \lor \neg \left(z \leq 28000000000\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if z < -5.5000000000000002e-5 or 2.8e10 < z Initial program 100.0%
Taylor expanded in x around 0 94.4%
Taylor expanded in y around 0 83.3%
if -5.5000000000000002e-5 < z < 2.8e10Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
exp-sum84.8%
exp-diff84.1%
associate-/r/84.1%
*-commutative84.1%
exp-to-pow84.1%
div-exp85.6%
Simplified85.6%
Taylor expanded in y around 0 66.9%
Taylor expanded in z around 0 66.7%
exp-neg66.7%
remove-double-div66.7%
Simplified66.7%
Final simplification74.7%
(FPCore (x y z) :precision binary64 (if (<= y 2.6e-146) (exp x) (if (<= y 5.8) (exp (- z)) (pow y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.6e-146) {
tmp = exp(x);
} else if (y <= 5.8) {
tmp = exp(-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.6d-146) then
tmp = exp(x)
else if (y <= 5.8d0) then
tmp = exp(-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.6e-146) {
tmp = Math.exp(x);
} else if (y <= 5.8) {
tmp = Math.exp(-z);
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.6e-146: tmp = math.exp(x) elif y <= 5.8: tmp = math.exp(-z) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.6e-146) tmp = exp(x); elseif (y <= 5.8) tmp = exp(Float64(-z)); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.6e-146) tmp = exp(x); elseif (y <= 5.8) tmp = exp(-z); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.6e-146], N[Exp[x], $MachinePrecision], If[LessEqual[y, 5.8], N[Exp[(-z)], $MachinePrecision], N[Power[y, y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.6 \cdot 10^{-146}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;y \leq 5.8:\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 2.59999999999999987e-146Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
exp-sum87.3%
exp-diff87.3%
associate-/r/87.3%
*-commutative87.3%
exp-to-pow87.3%
div-exp100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in z around 0 79.4%
exp-neg79.4%
remove-double-div79.4%
Simplified79.4%
if 2.59999999999999987e-146 < y < 5.79999999999999982Initial program 100.0%
Taylor expanded in x around 0 73.8%
Taylor expanded in y around 0 73.8%
if 5.79999999999999982 < y Initial program 100.0%
Taylor expanded in x around 0 91.6%
Taylor expanded in z around 0 79.4%
Final simplification78.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%
associate--l+100.0%
+-commutative100.0%
exp-sum82.4%
exp-diff71.9%
associate-/r/71.9%
*-commutative71.9%
exp-to-pow71.9%
div-exp80.1%
Simplified80.1%
Taylor expanded in y around 0 77.9%
Taylor expanded in z around 0 51.8%
exp-neg51.8%
remove-double-div51.8%
Simplified51.8%
Final simplification51.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 2024067
(FPCore (x y z)
:name "Statistics.Distribution.Poisson.Internal:probability from math-functions-0.1.5.2"
:precision binary64
:alt
(exp (+ (- x z) (* (log y) y)))
(exp (- (+ x (* y (log y))) z)))