
(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}
(FPCore (x y z) :precision binary64 (let* ((t_0 (* y (log y)))) (if (<= t_0 2e+67) (exp (- x z)) (exp (- t_0 z)))))
double code(double x, double y, double z) {
double t_0 = y * log(y);
double tmp;
if (t_0 <= 2e+67) {
tmp = exp((x - z));
} 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) :: tmp
t_0 = y * log(y)
if (t_0 <= 2d+67) then
tmp = exp((x - z))
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 tmp;
if (t_0 <= 2e+67) {
tmp = Math.exp((x - z));
} else {
tmp = Math.exp((t_0 - z));
}
return tmp;
}
def code(x, y, z): t_0 = y * math.log(y) tmp = 0 if t_0 <= 2e+67: tmp = math.exp((x - z)) else: tmp = math.exp((t_0 - z)) return tmp
function code(x, y, z) t_0 = Float64(y * log(y)) tmp = 0.0 if (t_0 <= 2e+67) tmp = exp(Float64(x - z)); else tmp = exp(Float64(t_0 - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * log(y); tmp = 0.0; if (t_0 <= 2e+67) tmp = exp((x - z)); 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]}, If[LessEqual[t$95$0, 2e+67], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Exp[N[(t$95$0 - z), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \log y\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{+67}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - z}\\
\end{array}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (exp (- z))))
(if (<= y 1.2e-161)
t_0
(if (<= y 1.6e-28)
(exp x)
(if (<= y 2.35e+21)
t_0
(if (<= y 9.2e+28)
(exp x)
(if (<= y 9e+47)
(pow y y)
(if (<= y 1.15e+67)
(exp x)
(if (<= y 3.1e+69) t_0 (pow y y))))))))))
double code(double x, double y, double z) {
double t_0 = exp(-z);
double tmp;
if (y <= 1.2e-161) {
tmp = t_0;
} else if (y <= 1.6e-28) {
tmp = exp(x);
} else if (y <= 2.35e+21) {
tmp = t_0;
} else if (y <= 9.2e+28) {
tmp = exp(x);
} else if (y <= 9e+47) {
tmp = pow(y, y);
} else if (y <= 1.15e+67) {
tmp = exp(x);
} else if (y <= 3.1e+69) {
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 <= 1.2d-161) then
tmp = t_0
else if (y <= 1.6d-28) then
tmp = exp(x)
else if (y <= 2.35d+21) then
tmp = t_0
else if (y <= 9.2d+28) then
tmp = exp(x)
else if (y <= 9d+47) then
tmp = y ** y
else if (y <= 1.15d+67) then
tmp = exp(x)
else if (y <= 3.1d+69) 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 <= 1.2e-161) {
tmp = t_0;
} else if (y <= 1.6e-28) {
tmp = Math.exp(x);
} else if (y <= 2.35e+21) {
tmp = t_0;
} else if (y <= 9.2e+28) {
tmp = Math.exp(x);
} else if (y <= 9e+47) {
tmp = Math.pow(y, y);
} else if (y <= 1.15e+67) {
tmp = Math.exp(x);
} else if (y <= 3.1e+69) {
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 <= 1.2e-161: tmp = t_0 elif y <= 1.6e-28: tmp = math.exp(x) elif y <= 2.35e+21: tmp = t_0 elif y <= 9.2e+28: tmp = math.exp(x) elif y <= 9e+47: tmp = math.pow(y, y) elif y <= 1.15e+67: tmp = math.exp(x) elif y <= 3.1e+69: 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 <= 1.2e-161) tmp = t_0; elseif (y <= 1.6e-28) tmp = exp(x); elseif (y <= 2.35e+21) tmp = t_0; elseif (y <= 9.2e+28) tmp = exp(x); elseif (y <= 9e+47) tmp = y ^ y; elseif (y <= 1.15e+67) tmp = exp(x); elseif (y <= 3.1e+69) 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 <= 1.2e-161) tmp = t_0; elseif (y <= 1.6e-28) tmp = exp(x); elseif (y <= 2.35e+21) tmp = t_0; elseif (y <= 9.2e+28) tmp = exp(x); elseif (y <= 9e+47) tmp = y ^ y; elseif (y <= 1.15e+67) tmp = exp(x); elseif (y <= 3.1e+69) 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, 1.2e-161], t$95$0, If[LessEqual[y, 1.6e-28], N[Exp[x], $MachinePrecision], If[LessEqual[y, 2.35e+21], t$95$0, If[LessEqual[y, 9.2e+28], N[Exp[x], $MachinePrecision], If[LessEqual[y, 9e+47], N[Power[y, y], $MachinePrecision], If[LessEqual[y, 1.15e+67], N[Exp[x], $MachinePrecision], If[LessEqual[y, 3.1e+69], t$95$0, N[Power[y, y], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-z}\\
\mathbf{if}\;y \leq 1.2 \cdot 10^{-161}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{-28}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{+21}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+28}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+47}:\\
\;\;\;\;{y}^{y}\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{+67}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{+69}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= x -3.8e+43) (not (<= x 2.85e-5))) (exp x) (exp (- z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.8e+43) || !(x <= 2.85e-5)) {
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 <= (-3.8d+43)) .or. (.not. (x <= 2.85d-5))) 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 <= -3.8e+43) || !(x <= 2.85e-5)) {
tmp = Math.exp(x);
} else {
tmp = Math.exp(-z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.8e+43) or not (x <= 2.85e-5): tmp = math.exp(x) else: tmp = math.exp(-z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.8e+43) || !(x <= 2.85e-5)) tmp = exp(x); else tmp = exp(Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.8e+43) || ~((x <= 2.85e-5))) tmp = exp(x); else tmp = exp(-z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.8e+43], N[Not[LessEqual[x, 2.85e-5]], $MachinePrecision]], N[Exp[x], $MachinePrecision], N[Exp[(-z)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{+43} \lor \neg \left(x \leq 2.85 \cdot 10^{-5}\right):\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;e^{-z}\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (<= y 1.02e+71) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.02e+71) {
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.02d+71) 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.02e+71) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.02e+71: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.02e+71) 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.02e+71) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.02e+71], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.02 \cdot 10^{+71}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
(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}
(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 2023343
(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)))