
(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 5 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 (exp (- z))))
(if (<= y 5.6e-281)
t_0
(if (<= y 4e-193) (exp x) (if (<= y 5.7e+49) t_0 (pow y y))))))
double code(double x, double y, double z) {
double t_0 = exp(-z);
double tmp;
if (y <= 5.6e-281) {
tmp = t_0;
} else if (y <= 4e-193) {
tmp = exp(x);
} else if (y <= 5.7e+49) {
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(-z)
if (y <= 5.6d-281) then
tmp = t_0
else if (y <= 4d-193) then
tmp = exp(x)
else if (y <= 5.7d+49) 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(-z);
double tmp;
if (y <= 5.6e-281) {
tmp = t_0;
} else if (y <= 4e-193) {
tmp = Math.exp(x);
} else if (y <= 5.7e+49) {
tmp = t_0;
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): t_0 = math.exp(-z) tmp = 0 if y <= 5.6e-281: tmp = t_0 elif y <= 4e-193: tmp = math.exp(x) elif y <= 5.7e+49: tmp = t_0 else: tmp = math.pow(y, y) return tmp
function code(x, y, z) t_0 = exp(Float64(-z)) tmp = 0.0 if (y <= 5.6e-281) tmp = t_0; elseif (y <= 4e-193) tmp = exp(x); elseif (y <= 5.7e+49) tmp = t_0; else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) t_0 = exp(-z); tmp = 0.0; if (y <= 5.6e-281) tmp = t_0; elseif (y <= 4e-193) tmp = exp(x); elseif (y <= 5.7e+49) tmp = t_0; else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Exp[(-z)], $MachinePrecision]}, If[LessEqual[y, 5.6e-281], t$95$0, If[LessEqual[y, 4e-193], N[Exp[x], $MachinePrecision], If[LessEqual[y, 5.7e+49], t$95$0, N[Power[y, y], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-z}\\
\mathbf{if}\;y \leq 5.6 \cdot 10^{-281}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-193}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;y \leq 5.7 \cdot 10^{+49}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 5.6000000000000001e-281 or 4.0000000000000002e-193 < y < 5.6999999999999998e49Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum89.0%
*-commutative89.0%
exp-to-pow89.0%
Simplified89.0%
Taylor expanded in x around 0 73.7%
exp-neg73.7%
associate-*l/73.7%
*-lft-identity73.7%
Simplified73.7%
Taylor expanded in y around 0 74.6%
exp-neg74.6%
Simplified74.6%
if 5.6000000000000001e-281 < y < 4.0000000000000002e-193Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum100.0%
*-commutative100.0%
exp-to-pow100.0%
Simplified100.0%
Taylor expanded in z around 0 76.4%
*-commutative76.4%
Simplified76.4%
Taylor expanded in y around 0 76.4%
if 5.6999999999999998e49 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum54.5%
*-commutative54.5%
exp-to-pow54.5%
Simplified54.5%
Taylor expanded in z around 0 63.8%
*-commutative63.8%
Simplified63.8%
Taylor expanded in x around 0 83.0%
Final simplification78.5%
(FPCore (x y z) :precision binary64 (if (<= x -1.55e+87) (exp x) (if (<= x 680.0) (exp (- z)) (exp x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.55e+87) {
tmp = exp(x);
} else if (x <= 680.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 (x <= (-1.55d+87)) then
tmp = exp(x)
else if (x <= 680.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 (x <= -1.55e+87) {
tmp = Math.exp(x);
} else if (x <= 680.0) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.55e+87: tmp = math.exp(x) elif x <= 680.0: tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.55e+87) tmp = exp(x); elseif (x <= 680.0) tmp = exp(Float64(-z)); else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.55e+87) tmp = exp(x); elseif (x <= 680.0) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.55e+87], N[Exp[x], $MachinePrecision], If[LessEqual[x, 680.0], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{+87}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;x \leq 680:\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if x < -1.55e87 or 680 < 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 67.2%
*-commutative67.2%
Simplified67.2%
Taylor expanded in y around 0 79.9%
if -1.55e87 < x < 680Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum76.5%
*-commutative76.5%
exp-to-pow76.5%
Simplified76.5%
Taylor expanded in x around 0 79.8%
exp-neg79.8%
associate-*l/79.8%
*-lft-identity79.8%
Simplified79.8%
Taylor expanded in y around 0 66.8%
exp-neg66.8%
Simplified66.8%
Final simplification72.1%
(FPCore (x y z) :precision binary64 (if (<= y 1.2e+108) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.2e+108) {
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 <= 1.2d+108) 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 <= 1.2e+108) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.2e+108: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.2e+108) 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 <= 1.2e+108) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.2e+108], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.2 \cdot 10^{+108}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 1.20000000000000009e108Initial program 100.0%
Taylor expanded in x around inf 95.2%
if 1.20000000000000009e108 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum51.1%
*-commutative51.1%
exp-to-pow51.1%
Simplified51.1%
Taylor expanded in z around 0 63.5%
*-commutative63.5%
Simplified63.5%
Taylor expanded in x around 0 84.7%
Final simplification91.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-sum75.8%
*-commutative75.8%
exp-to-pow75.8%
Simplified75.8%
Taylor expanded in z around 0 64.7%
*-commutative64.7%
Simplified64.7%
Taylor expanded in y around 0 47.2%
Final simplification47.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 2023297
(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)))