
(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 (<= z -0.00011)
t_0
(if (<= z 2e-186) (pow y y) (if (<= z 3.6e+47) (exp x) t_0)))))
double code(double x, double y, double z) {
double t_0 = exp(-z);
double tmp;
if (z <= -0.00011) {
tmp = t_0;
} else if (z <= 2e-186) {
tmp = pow(y, y);
} else if (z <= 3.6e+47) {
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 <= (-0.00011d0)) then
tmp = t_0
else if (z <= 2d-186) then
tmp = y ** y
else if (z <= 3.6d+47) 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 <= -0.00011) {
tmp = t_0;
} else if (z <= 2e-186) {
tmp = Math.pow(y, y);
} else if (z <= 3.6e+47) {
tmp = Math.exp(x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.exp(-z) tmp = 0 if z <= -0.00011: tmp = t_0 elif z <= 2e-186: tmp = math.pow(y, y) elif z <= 3.6e+47: 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 <= -0.00011) tmp = t_0; elseif (z <= 2e-186) tmp = y ^ y; elseif (z <= 3.6e+47) 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 <= -0.00011) tmp = t_0; elseif (z <= 2e-186) tmp = y ^ y; elseif (z <= 3.6e+47) 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, -0.00011], t$95$0, If[LessEqual[z, 2e-186], N[Power[y, y], $MachinePrecision], If[LessEqual[z, 3.6e+47], N[Exp[x], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-z}\\
\mathbf{if}\;z \leq -0.00011:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2 \cdot 10^{-186}:\\
\;\;\;\;{y}^{y}\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{+47}:\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.10000000000000004e-4 or 3.60000000000000008e47 < z Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum75.6%
*-commutative75.6%
exp-to-pow75.6%
Simplified75.6%
Taylor expanded in x around 0 68.6%
*-commutative68.6%
exp-to-pow68.6%
*-commutative68.6%
prod-exp89.1%
unsub-neg89.1%
div-exp68.6%
*-commutative68.6%
exp-to-pow68.6%
Simplified68.6%
Taylor expanded in y around 0 85.3%
rec-exp85.3%
Simplified85.3%
if -1.10000000000000004e-4 < z < 1.9999999999999998e-186Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum87.0%
*-commutative87.0%
exp-to-pow87.0%
Simplified87.0%
Taylor expanded in z around 0 87.0%
*-commutative87.0%
Simplified87.0%
Taylor expanded in x around 0 78.1%
if 1.9999999999999998e-186 < z < 3.60000000000000008e47Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum88.5%
*-commutative88.5%
exp-to-pow88.5%
Simplified88.5%
Taylor expanded in z around 0 85.9%
*-commutative85.9%
Simplified85.9%
Taylor expanded in y around 0 78.7%
Final simplification81.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.5e+51) (not (<= x 255.0))) (exp x) (exp (- z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e+51) || !(x <= 255.0)) {
tmp = exp(x);
} else {
tmp = exp(-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 <= (-5.5d+51)) .or. (.not. (x <= 255.0d0))) then
tmp = exp(x)
else
tmp = exp(-z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e+51) || !(x <= 255.0)) {
tmp = Math.exp(x);
} else {
tmp = Math.exp(-z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.5e+51) or not (x <= 255.0): tmp = math.exp(x) else: tmp = math.exp(-z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.5e+51) || !(x <= 255.0)) tmp = exp(x); else tmp = exp(Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.5e+51) || ~((x <= 255.0))) tmp = exp(x); else tmp = exp(-z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.5e+51], N[Not[LessEqual[x, 255.0]], $MachinePrecision]], N[Exp[x], $MachinePrecision], N[Exp[(-z)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{+51} \lor \neg \left(x \leq 255\right):\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;e^{-z}\\
\end{array}
\end{array}
if x < -5.5e51 or 255 < x Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum77.6%
*-commutative77.6%
exp-to-pow77.6%
Simplified77.6%
Taylor expanded in z around 0 70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in y around 0 85.3%
if -5.5e51 < x < 255Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum84.6%
*-commutative84.6%
exp-to-pow84.6%
Simplified84.6%
Taylor expanded in x around 0 86.4%
*-commutative86.4%
exp-to-pow86.4%
*-commutative86.4%
prod-exp99.8%
unsub-neg99.8%
div-exp86.3%
*-commutative86.3%
exp-to-pow86.3%
Simplified86.3%
Taylor expanded in y around 0 75.8%
rec-exp75.8%
Simplified75.8%
Final simplification79.8%
(FPCore (x y z) :precision binary64 (if (<= y 7.5e+43) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 7.5e+43) {
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 <= 7.5d+43) 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 <= 7.5e+43) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7.5e+43: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7.5e+43) 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 <= 7.5e+43) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7.5e+43], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.5 \cdot 10^{+43}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 7.49999999999999967e43Initial program 100.0%
Taylor expanded in x around inf 98.2%
if 7.49999999999999967e43 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum69.4%
*-commutative69.4%
exp-to-pow69.4%
Simplified69.4%
Taylor expanded in z around 0 72.1%
*-commutative72.1%
Simplified72.1%
Taylor expanded in x around 0 84.0%
Final simplification92.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%
+-commutative100.0%
associate--l+100.0%
exp-sum81.6%
*-commutative81.6%
exp-to-pow81.6%
Simplified81.6%
Taylor expanded in z around 0 68.1%
*-commutative68.1%
Simplified68.1%
Taylor expanded in y around 0 52.6%
Final simplification52.6%
(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 2024096
(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)))