
(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 0.43) (exp (- x z)) (exp (- (* (log y) y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.43) {
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 <= 0.43d0) 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 <= 0.43) {
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 <= 0.43: 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 (y <= 0.43) 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 <= 0.43) tmp = exp((x - z)); else tmp = exp(((log(y) * y) - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 0.43], 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 \leq 0.43:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{\log y \cdot y - z}\\
\end{array}
\end{array}
if y < 0.429999999999999993Initial program 100.0%
Taylor expanded in y around 0
lower--.f6499.4
Applied rewrites99.4%
if 0.429999999999999993 < y Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f6488.9
Applied rewrites88.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -560000000000.0) (not (<= z 2.4e+47))) (exp (- z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -560000000000.0) || !(z <= 2.4e+47)) {
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 ((z <= (-560000000000.0d0)) .or. (.not. (z <= 2.4d+47))) 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 ((z <= -560000000000.0) || !(z <= 2.4e+47)) {
tmp = Math.exp(-z);
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -560000000000.0) or not (z <= 2.4e+47): tmp = math.exp(-z) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -560000000000.0) || !(z <= 2.4e+47)) tmp = exp(Float64(-z)); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -560000000000.0) || ~((z <= 2.4e+47))) tmp = exp(-z); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -560000000000.0], N[Not[LessEqual[z, 2.4e+47]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -560000000000 \lor \neg \left(z \leq 2.4 \cdot 10^{+47}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if z < -5.6e11 or 2.40000000000000019e47 < z Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6487.6
Applied rewrites87.6%
if -5.6e11 < z < 2.40000000000000019e47Initial 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.f6483.2
Applied rewrites83.2%
Taylor expanded in x around 0
Applied rewrites64.8%
Final simplification74.7%
(FPCore (x y z) :precision binary64 (if (<= y 1.55e+184) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.55e+184) {
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.55d+184) 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.55e+184) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.55e+184: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.55e+184) 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.55e+184) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.55e+184], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.55 \cdot 10^{+184}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 1.5499999999999999e184Initial program 100.0%
Taylor expanded in y around 0
lower--.f6488.1
Applied rewrites88.1%
if 1.5499999999999999e184 < 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.f6472.8
Applied rewrites72.8%
Taylor expanded in x around 0
Applied rewrites94.6%
(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.f6467.2
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites48.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 2024313
(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)))