
(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 7 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 (- (+ (* (log y) y) x) z)))
double code(double x, double y, double z) {
return exp((((log(y) * y) + x) - 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((((log(y) * y) + x) - z))
end function
public static double code(double x, double y, double z) {
return Math.exp((((Math.log(y) * y) + x) - z));
}
def code(x, y, z): return math.exp((((math.log(y) * y) + x) - z))
function code(x, y, z) return exp(Float64(Float64(Float64(log(y) * y) + x) - z)) end
function tmp = code(x, y, z) tmp = exp((((log(y) * y) + x) - z)); end
code[x_, y_, z_] := N[Exp[N[(N[(N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(\log y \cdot y + x\right) - z}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (log y) y))) (if (<= t_0 5e+137) (exp (- x z)) (exp t_0))))
double code(double x, double y, double z) {
double t_0 = log(y) * y;
double tmp;
if (t_0 <= 5e+137) {
tmp = exp((x - z));
} else {
tmp = exp(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 = log(y) * y
if (t_0 <= 5d+137) then
tmp = exp((x - z))
else
tmp = exp(t_0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.log(y) * y;
double tmp;
if (t_0 <= 5e+137) {
tmp = Math.exp((x - z));
} else {
tmp = Math.exp(t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.log(y) * y tmp = 0 if t_0 <= 5e+137: tmp = math.exp((x - z)) else: tmp = math.exp(t_0) return tmp
function code(x, y, z) t_0 = Float64(log(y) * y) tmp = 0.0 if (t_0 <= 5e+137) tmp = exp(Float64(x - z)); else tmp = exp(t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = log(y) * y; tmp = 0.0; if (t_0 <= 5e+137) tmp = exp((x - z)); else tmp = exp(t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+137], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Exp[t$95$0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot y\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+137}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 5.0000000000000002e137Initial program 100.0%
Taylor expanded in y around 0
lower--.f6492.7
Applied rewrites92.7%
if 5.0000000000000002e137 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in y around inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower-log.f6491.1
Applied rewrites91.1%
Final simplification92.2%
(FPCore (x y z) :precision binary64 (if (<= (* (log y) y) 6.6e+214) (exp (- x z)) (exp (* (fma z (- z x) (* x x)) (fma x (/ x (* (* z z) z)) (/ -1.0 z))))))
double code(double x, double y, double z) {
double tmp;
if ((log(y) * y) <= 6.6e+214) {
tmp = exp((x - z));
} else {
tmp = exp((fma(z, (z - x), (x * x)) * fma(x, (x / ((z * z) * z)), (-1.0 / z))));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (Float64(log(y) * y) <= 6.6e+214) tmp = exp(Float64(x - z)); else tmp = exp(Float64(fma(z, Float64(z - x), Float64(x * x)) * fma(x, Float64(x / Float64(Float64(z * z) * z)), Float64(-1.0 / z)))); end return tmp end
code[x_, y_, z_] := If[LessEqual[N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision], 6.6e+214], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(z * N[(z - x), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * N[(x / N[(N[(z * z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\log y \cdot y \leq 6.6 \cdot 10^{+214}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{\mathsf{fma}\left(z, z - x, x \cdot x\right) \cdot \mathsf{fma}\left(x, \frac{x}{\left(z \cdot z\right) \cdot z}, \frac{-1}{z}\right)}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 6.60000000000000023e214Initial program 100.0%
Taylor expanded in y around 0
lower--.f6487.6
Applied rewrites87.6%
if 6.60000000000000023e214 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in y around 0
lower--.f6444.1
Applied rewrites44.1%
Applied rewrites15.5%
Taylor expanded in x around 0
Applied rewrites61.9%
Final simplification82.6%
(FPCore (x y z) :precision binary64 (if (<= (* (log y) y) 2.4e+264) (exp (- x z)) (exp (fma (* x x) (/ 1.0 z) (- (- z x))))))
double code(double x, double y, double z) {
double tmp;
if ((log(y) * y) <= 2.4e+264) {
tmp = exp((x - z));
} else {
tmp = exp(fma((x * x), (1.0 / z), -(z - x)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (Float64(log(y) * y) <= 2.4e+264) tmp = exp(Float64(x - z)); else tmp = exp(fma(Float64(x * x), Float64(1.0 / z), Float64(-Float64(z - x)))); end return tmp end
code[x_, y_, z_] := If[LessEqual[N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision], 2.4e+264], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(x * x), $MachinePrecision] * N[(1.0 / z), $MachinePrecision] + (-N[(z - x), $MachinePrecision])), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\log y \cdot y \leq 2.4 \cdot 10^{+264}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{\mathsf{fma}\left(x \cdot x, \frac{1}{z}, -\left(z - x\right)\right)}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 2.39999999999999993e264Initial program 100.0%
Taylor expanded in y around 0
lower--.f6484.5
Applied rewrites84.5%
if 2.39999999999999993e264 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in y around 0
lower--.f6434.7
Applied rewrites34.7%
Applied rewrites34.7%
Taylor expanded in x around 0
Applied rewrites34.7%
Taylor expanded in z around inf
Applied rewrites56.4%
Final simplification81.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (exp (- x z))))
(if (<= z 5.2e-307)
t_0
(if (<= z 2.45e-156)
(exp (fma (* x x) (/ 1.0 z) (- (- z x))))
(if (<= z 5e+80)
(exp (fma (/ x (+ z x)) x (* (/ (- z (/ (* z z) x)) x) (- z))))
t_0)))))
double code(double x, double y, double z) {
double t_0 = exp((x - z));
double tmp;
if (z <= 5.2e-307) {
tmp = t_0;
} else if (z <= 2.45e-156) {
tmp = exp(fma((x * x), (1.0 / z), -(z - x)));
} else if (z <= 5e+80) {
tmp = exp(fma((x / (z + x)), x, (((z - ((z * z) / x)) / x) * -z)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = exp(Float64(x - z)) tmp = 0.0 if (z <= 5.2e-307) tmp = t_0; elseif (z <= 2.45e-156) tmp = exp(fma(Float64(x * x), Float64(1.0 / z), Float64(-Float64(z - x)))); elseif (z <= 5e+80) tmp = exp(fma(Float64(x / Float64(z + x)), x, Float64(Float64(Float64(z - Float64(Float64(z * z) / x)) / x) * Float64(-z)))); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, 5.2e-307], t$95$0, If[LessEqual[z, 2.45e-156], N[Exp[N[(N[(x * x), $MachinePrecision] * N[(1.0 / z), $MachinePrecision] + (-N[(z - x), $MachinePrecision])), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 5e+80], N[Exp[N[(N[(x / N[(z + x), $MachinePrecision]), $MachinePrecision] * x + N[(N[(N[(z - N[(N[(z * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * (-z)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{x - z}\\
\mathbf{if}\;z \leq 5.2 \cdot 10^{-307}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.45 \cdot 10^{-156}:\\
\;\;\;\;e^{\mathsf{fma}\left(x \cdot x, \frac{1}{z}, -\left(z - x\right)\right)}\\
\mathbf{elif}\;z \leq 5 \cdot 10^{+80}:\\
\;\;\;\;e^{\mathsf{fma}\left(\frac{x}{z + x}, x, \frac{z - \frac{z \cdot z}{x}}{x} \cdot \left(-z\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < 5.19999999999999992e-307 or 4.99999999999999961e80 < z Initial program 100.0%
Taylor expanded in y around 0
lower--.f6490.9
Applied rewrites90.9%
if 5.19999999999999992e-307 < z < 2.44999999999999976e-156Initial program 100.0%
Taylor expanded in y around 0
lower--.f6451.6
Applied rewrites51.6%
Applied rewrites51.6%
Taylor expanded in x around 0
Applied rewrites50.1%
Taylor expanded in z around inf
Applied rewrites76.7%
if 2.44999999999999976e-156 < z < 4.99999999999999961e80Initial program 100.0%
Taylor expanded in y around 0
lower--.f6458.1
Applied rewrites58.1%
Applied rewrites58.1%
Taylor expanded in z around 0
Applied rewrites76.1%
Applied rewrites76.1%
Final simplification86.1%
(FPCore (x y z) :precision binary64 (exp (- x z)))
double code(double x, double y, double z) {
return exp((x - 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 - z))
end function
public static double code(double x, double y, double z) {
return Math.exp((x - z));
}
def code(x, y, z): return math.exp((x - z))
function code(x, y, z) return exp(Float64(x - z)) end
function tmp = code(x, y, z) tmp = exp((x - z)); end
code[x_, y_, z_] := N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{x - z}
\end{array}
Initial program 100.0%
Taylor expanded in y around 0
lower--.f6479.2
Applied rewrites79.2%
(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%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6449.7
Applied rewrites49.7%
(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 2024235
(FPCore (x y z)
:name "Statistics.Distribution.Poisson.Internal:probability from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (exp (+ (- x z) (* (log y) y))))
(exp (- (+ x (* y (log y))) z)))