
(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 6 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%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* y (log y)))) (if (<= t_0 400.0) (/ (pow y y) (exp (- z x))) (exp (- t_0 z)))))
double code(double x, double y, double z) {
double t_0 = y * log(y);
double tmp;
if (t_0 <= 400.0) {
tmp = pow(y, y) / exp((z - x));
} else {
tmp = exp((t_0 - 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) :: t_0
real(8) :: tmp
t_0 = y * log(y)
if (t_0 <= 400.0d0) then
tmp = (y ** y) / exp((z - x))
else
tmp = exp((t_0 - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * Math.log(y);
double tmp;
if (t_0 <= 400.0) {
tmp = Math.pow(y, y) / Math.exp((z - x));
} else {
tmp = Math.exp((t_0 - z));
}
return tmp;
}
def code(x, y, z): t_0 = y * math.log(y) tmp = 0 if t_0 <= 400.0: tmp = math.pow(y, y) / math.exp((z - x)) else: tmp = math.exp((t_0 - z)) return tmp
function code(x, y, z) t_0 = Float64(y * log(y)) tmp = 0.0 if (t_0 <= 400.0) tmp = Float64((y ^ y) / exp(Float64(z - x))); else tmp = exp(Float64(t_0 - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * log(y); tmp = 0.0; if (t_0 <= 400.0) tmp = (y ^ y) / exp((z - x)); else tmp = exp((t_0 - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 400.0], N[(N[Power[y, y], $MachinePrecision] / N[Exp[N[(z - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - z), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \log y\\
\mathbf{if}\;t\_0 \leq 400:\\
\;\;\;\;\frac{{y}^{y}}{e^{z - x}}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 - z}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 400Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
exp-sum86.3%
exp-diff86.3%
associate-/r/86.3%
*-commutative86.3%
exp-to-pow86.3%
div-exp100.0%
Simplified100.0%
if 400 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in x around 0 89.1%
Final simplification95.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* y (log y)))) (if (<= t_0 400.0) (/ 1.0 (exp (- z x))) (exp (- t_0 z)))))
double code(double x, double y, double z) {
double t_0 = y * log(y);
double tmp;
if (t_0 <= 400.0) {
tmp = 1.0 / exp((z - x));
} else {
tmp = exp((t_0 - 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) :: t_0
real(8) :: tmp
t_0 = y * log(y)
if (t_0 <= 400.0d0) then
tmp = 1.0d0 / exp((z - x))
else
tmp = exp((t_0 - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * Math.log(y);
double tmp;
if (t_0 <= 400.0) {
tmp = 1.0 / Math.exp((z - x));
} else {
tmp = Math.exp((t_0 - z));
}
return tmp;
}
def code(x, y, z): t_0 = y * math.log(y) tmp = 0 if t_0 <= 400.0: tmp = 1.0 / math.exp((z - x)) else: tmp = math.exp((t_0 - z)) return tmp
function code(x, y, z) t_0 = Float64(y * log(y)) tmp = 0.0 if (t_0 <= 400.0) tmp = Float64(1.0 / exp(Float64(z - x))); else tmp = exp(Float64(t_0 - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * log(y); tmp = 0.0; if (t_0 <= 400.0) tmp = 1.0 / exp((z - x)); else tmp = exp((t_0 - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 400.0], N[(1.0 / N[Exp[N[(z - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - z), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \log y\\
\mathbf{if}\;t\_0 \leq 400:\\
\;\;\;\;\frac{1}{e^{z - x}}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 - z}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 400Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
exp-sum86.3%
exp-diff86.3%
associate-/r/86.3%
*-commutative86.3%
exp-to-pow86.3%
div-exp100.0%
Simplified100.0%
Taylor expanded in y around 0 98.6%
if 400 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in x around 0 89.1%
Final simplification94.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -480.0) (not (<= z 6.6e+68))) (exp (- z)) (exp x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -480.0) || !(z <= 6.6e+68)) {
tmp = exp(-z);
} else {
tmp = exp(x);
}
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 <= (-480.0d0)) .or. (.not. (z <= 6.6d+68))) then
tmp = exp(-z)
else
tmp = exp(x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -480.0) || !(z <= 6.6e+68)) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -480.0) or not (z <= 6.6e+68): tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -480.0) || !(z <= 6.6e+68)) tmp = exp(Float64(-z)); else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -480.0) || ~((z <= 6.6e+68))) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -480.0], N[Not[LessEqual[z, 6.6e+68]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -480 \lor \neg \left(z \leq 6.6 \cdot 10^{+68}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if z < -480 or 6.6000000000000001e68 < z Initial program 100.0%
Taylor expanded in z around inf 88.6%
neg-mul-188.6%
Simplified88.6%
if -480 < z < 6.6000000000000001e68Initial program 100.0%
Taylor expanded in x around inf 73.1%
Final simplification79.4%
(FPCore (x y z) :precision binary64 (if (<= y 1.1e+136) (/ 1.0 (exp (- z x))) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.1e+136) {
tmp = 1.0 / exp((z - x));
} 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.1d+136) then
tmp = 1.0d0 / exp((z - x))
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.1e+136) {
tmp = 1.0 / Math.exp((z - x));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.1e+136: tmp = 1.0 / math.exp((z - x)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.1e+136) tmp = Float64(1.0 / exp(Float64(z - x))); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.1e+136) tmp = 1.0 / exp((z - x)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.1e+136], N[(1.0 / N[Exp[N[(z - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{+136}:\\
\;\;\;\;\frac{1}{e^{z - x}}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 1.1e136Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
exp-sum81.9%
exp-diff76.2%
associate-/r/76.2%
*-commutative76.2%
exp-to-pow76.2%
div-exp86.5%
Simplified86.5%
Taylor expanded in y around 0 91.4%
if 1.1e136 < y Initial program 100.0%
associate--l+100.0%
+-commutative100.0%
exp-sum69.8%
exp-diff50.8%
associate-/r/50.8%
*-commutative50.8%
exp-to-pow50.8%
div-exp63.5%
Simplified63.5%
Taylor expanded in z around 0 63.6%
exp-neg63.6%
associate-/r/63.6%
/-rgt-identity63.6%
Simplified63.6%
Taylor expanded in x around 0 90.6%
Final simplification91.2%
(FPCore (x y z) :precision binary64 (exp x))
double code(double x, double y, double z) {
return exp(x);
}
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)
end function
public static double code(double x, double y, double z) {
return Math.exp(x);
}
def code(x, y, z): return math.exp(x)
function code(x, y, z) return exp(x) end
function tmp = code(x, y, z) tmp = exp(x); end
code[x_, y_, z_] := N[Exp[x], $MachinePrecision]
\begin{array}{l}
\\
e^{x}
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 56.3%
Final simplification56.3%
(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 2024066
(FPCore (x y z)
:name "Statistics.Distribution.Poisson.Internal:probability from math-functions-0.1.5.2"
:precision binary64
:alt
(exp (+ (- x z) (* (log y) y)))
(exp (- (+ x (* y (log y))) z)))