
(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 (if (<= (* y (log y)) -5e-297) (exp (- x z)) (exp (- (* (log y) y) z))))
double code(double x, double y, double z) {
double tmp;
if ((y * log(y)) <= -5e-297) {
tmp = exp((x - z));
} else {
tmp = exp(((log(y) * y) - 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 ((y * log(y)) <= (-5d-297)) then
tmp = exp((x - z))
else
tmp = exp(((log(y) * y) - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y * Math.log(y)) <= -5e-297) {
tmp = Math.exp((x - z));
} else {
tmp = Math.exp(((Math.log(y) * y) - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * math.log(y)) <= -5e-297: tmp = math.exp((x - z)) else: tmp = math.exp(((math.log(y) * y) - z)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y * log(y)) <= -5e-297) tmp = exp(Float64(x - z)); else tmp = exp(Float64(Float64(log(y) * y) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y * log(y)) <= -5e-297) tmp = exp((x - z)); else tmp = exp(((log(y) * y) - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision], -5e-297], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot \log y \leq -5 \cdot 10^{-297}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{\log y \cdot y - z}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < -5e-297Initial program 100.0%
Taylor expanded in y around 0
lower--.f6499.4
Applied rewrites99.4%
if -5e-297 < (*.f64 y (log.f64 y)) Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f6490.1
Applied rewrites90.1%
(FPCore (x y z) :precision binary64 (if (<= (* y (log y)) 5e+58) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if ((y * log(y)) <= 5e+58) {
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 * log(y)) <= 5d+58) 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 * Math.log(y)) <= 5e+58) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * math.log(y)) <= 5e+58: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y * log(y)) <= 5e+58) 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 * log(y)) <= 5e+58) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision], 5e+58], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot \log y \leq 5 \cdot 10^{+58}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 4.99999999999999986e58Initial program 99.9%
Taylor expanded in y around 0
lower--.f6494.7
Applied rewrites94.7%
if 4.99999999999999986e58 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6463.9
Applied rewrites63.9%
Taylor expanded in x around 0
Applied rewrites86.4%
(FPCore (x y z) :precision binary64 (if (<= y 8.5e+14) (exp (- z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 8.5e+14) {
tmp = exp(-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 <= 8.5d+14) then
tmp = exp(-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 <= 8.5e+14) {
tmp = Math.exp(-z);
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 8.5e+14: tmp = math.exp(-z) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 8.5e+14) tmp = exp(Float64(-z)); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 8.5e+14) tmp = exp(-z); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 8.5e+14], N[Exp[(-z)], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{+14}:\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 8.5e14Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6468.8
Applied rewrites68.8%
if 8.5e14 < y Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6464.3
Applied rewrites64.3%
Taylor expanded in x around 0
Applied rewrites83.7%
(FPCore (x y z) :precision binary64 (pow y y))
double code(double x, double y, double z) {
return pow(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 = y ** y
end function
public static double code(double x, double y, double z) {
return Math.pow(y, y);
}
def code(x, y, z): return math.pow(y, y)
function code(x, y, z) return y ^ y end
function tmp = code(x, y, z) tmp = y ^ y; end
code[x_, y_, z_] := N[Power[y, y], $MachinePrecision]
\begin{array}{l}
\\
{y}^{y}
\end{array}
Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6466.5
Applied rewrites66.5%
Taylor expanded in x around 0
Applied rewrites53.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 2024329
(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)))