
(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 (- (+ (* (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)) (t_1 (exp t_0)))
(if (<= t_0 5e+54)
(exp (- x z))
(if (<= t_0 5e+141)
t_1
(if (<= t_0 2e+204) (exp (/ (fma (- z) z (* x x)) (+ z x))) t_1)))))
double code(double x, double y, double z) {
double t_0 = log(y) * y;
double t_1 = exp(t_0);
double tmp;
if (t_0 <= 5e+54) {
tmp = exp((x - z));
} else if (t_0 <= 5e+141) {
tmp = t_1;
} else if (t_0 <= 2e+204) {
tmp = exp((fma(-z, z, (x * x)) / (z + x)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(log(y) * y) t_1 = exp(t_0) tmp = 0.0 if (t_0 <= 5e+54) tmp = exp(Float64(x - z)); elseif (t_0 <= 5e+141) tmp = t_1; elseif (t_0 <= 2e+204) tmp = exp(Float64(fma(Float64(-z), z, Float64(x * x)) / Float64(z + x))); else tmp = t_1; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$1 = N[Exp[t$95$0], $MachinePrecision]}, If[LessEqual[t$95$0, 5e+54], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 5e+141], t$95$1, If[LessEqual[t$95$0, 2e+204], N[Exp[N[(N[((-z) * z + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(z + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot y\\
t_1 := e^{t\_0}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+54}:\\
\;\;\;\;e^{x - z}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+141}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+204}:\\
\;\;\;\;e^{\frac{\mathsf{fma}\left(-z, z, x \cdot x\right)}{z + x}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 5.00000000000000005e54Initial program 100.0%
Taylor expanded in y around 0
lower--.f6494.3
Applied rewrites94.3%
if 5.00000000000000005e54 < (*.f64 y (log.f64 y)) < 5.00000000000000025e141 or 1.99999999999999998e204 < (*.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.f6488.4
Applied rewrites88.4%
if 5.00000000000000025e141 < (*.f64 y (log.f64 y)) < 1.99999999999999998e204Initial program 100.0%
Taylor expanded in y around 0
lower--.f6481.5
Applied rewrites81.5%
Applied rewrites81.5%
Final simplification91.3%
(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.5
Applied rewrites79.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%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6452.2
Applied rewrites52.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 2024249
(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)))