
(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 4 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 (<= y 6.2e+84) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.2e+84) {
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 <= 6.2d+84) 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 <= 6.2e+84) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 6.2e+84: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 6.2e+84) 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 <= 6.2e+84) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 6.2e+84], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.2 \cdot 10^{+84}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 6.20000000000000006e84Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum90.7%
*-commutative90.7%
exp-to-pow90.7%
Simplified90.7%
Taylor expanded in y around 0 95.2%
if 6.20000000000000006e84 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum61.9%
*-commutative61.9%
exp-to-pow61.9%
Simplified61.9%
Taylor expanded in x around 0 65.6%
exp-to-pow65.6%
*-commutative65.6%
prod-exp91.8%
+-commutative91.8%
unsub-neg91.8%
div-exp65.6%
*-commutative65.6%
exp-to-pow65.6%
Simplified65.6%
Taylor expanded in z around 0 85.9%
Final simplification92.2%
(FPCore (x y z) :precision binary64 (if (<= y 2500.0) (exp (- z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2500.0) {
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 <= 2500.0d0) 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 <= 2500.0) {
tmp = Math.exp(-z);
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2500.0: tmp = math.exp(-z) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2500.0) tmp = exp(Float64(-z)); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2500.0) tmp = exp(-z); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2500.0], N[Exp[(-z)], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2500:\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 2500Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum99.3%
*-commutative99.3%
exp-to-pow99.3%
Simplified99.3%
Taylor expanded in x around 0 66.7%
exp-to-pow66.7%
*-commutative66.7%
prod-exp67.4%
+-commutative67.4%
unsub-neg67.4%
div-exp66.7%
*-commutative66.7%
exp-to-pow66.7%
Simplified66.7%
Taylor expanded in y around 0 67.1%
rec-exp67.1%
Simplified67.1%
if 2500 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum60.8%
*-commutative60.8%
exp-to-pow60.8%
Simplified60.8%
Taylor expanded in x around 0 64.3%
exp-to-pow64.3%
*-commutative64.3%
prod-exp88.5%
+-commutative88.5%
unsub-neg88.5%
div-exp64.3%
*-commutative64.3%
exp-to-pow64.3%
Simplified64.3%
Taylor expanded in z around 0 78.7%
Final simplification72.5%
(FPCore (x y z) :precision binary64 (exp (- z)))
double code(double x, double y, double z) {
return exp(-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(-z)
end function
public static double code(double x, double y, double z) {
return Math.exp(-z);
}
def code(x, y, z): return math.exp(-z)
function code(x, y, z) return exp(Float64(-z)) end
function tmp = code(x, y, z) tmp = exp(-z); end
code[x_, y_, z_] := N[Exp[(-z)], $MachinePrecision]
\begin{array}{l}
\\
e^{-z}
\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 x around 0 65.6%
exp-to-pow65.6%
*-commutative65.6%
prod-exp77.3%
+-commutative77.3%
unsub-neg77.3%
div-exp65.6%
*-commutative65.6%
exp-to-pow65.6%
Simplified65.6%
Taylor expanded in y around 0 50.2%
rec-exp50.2%
Simplified50.2%
Final simplification50.2%
(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 2023340
(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)))