
(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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (log y))))
(if (<= t_0 6.6e+192)
(exp (- x z))
(if (<= t_0 6.5e+269)
(exp (* (fma z (+ x z) (* x x)) (/ -1.0 z)))
(exp
(* (* z (* z (+ 1.0 (fma x (/ x (* z z)) (/ x z))))) (/ 1.0 x)))))))
double code(double x, double y, double z) {
double t_0 = y * log(y);
double tmp;
if (t_0 <= 6.6e+192) {
tmp = exp((x - z));
} else if (t_0 <= 6.5e+269) {
tmp = exp((fma(z, (x + z), (x * x)) * (-1.0 / z)));
} else {
tmp = exp(((z * (z * (1.0 + fma(x, (x / (z * z)), (x / z))))) * (1.0 / x)));
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y * log(y)) tmp = 0.0 if (t_0 <= 6.6e+192) tmp = exp(Float64(x - z)); elseif (t_0 <= 6.5e+269) tmp = exp(Float64(fma(z, Float64(x + z), Float64(x * x)) * Float64(-1.0 / z))); else tmp = exp(Float64(Float64(z * Float64(z * Float64(1.0 + fma(x, Float64(x / Float64(z * z)), Float64(x / z))))) * Float64(1.0 / x))); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 6.6e+192], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 6.5e+269], N[Exp[N[(N[(z * N[(x + z), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(z * N[(z * N[(1.0 + N[(x * N[(x / N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \log y\\
\mathbf{if}\;t\_0 \leq 6.6 \cdot 10^{+192}:\\
\;\;\;\;e^{x - z}\\
\mathbf{elif}\;t\_0 \leq 6.5 \cdot 10^{+269}:\\
\;\;\;\;e^{\mathsf{fma}\left(z, x + z, x \cdot x\right) \cdot \frac{-1}{z}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(z \cdot \left(z \cdot \left(1 + \mathsf{fma}\left(x, \frac{x}{z \cdot z}, \frac{x}{z}\right)\right)\right)\right) \cdot \frac{1}{x}}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 6.60000000000000019e192Initial program 100.0%
Taylor expanded in y around 0
lower--.f6487.0
Applied rewrites87.0%
if 6.60000000000000019e192 < (*.f64 y (log.f64 y)) < 6.5000000000000003e269Initial program 100.0%
Taylor expanded in y around 0
lower--.f6453.3
Applied rewrites53.3%
Applied rewrites18.1%
Taylor expanded in x around 0
Applied rewrites47.3%
if 6.5000000000000003e269 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in y around 0
lower--.f6443.8
Applied rewrites43.8%
Applied rewrites16.2%
Taylor expanded in x around inf
Applied rewrites45.5%
Taylor expanded in z around inf
Applied rewrites46.7%
Final simplification79.4%
(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 2024228
(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)))