
(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 8 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 200000.0)
(* (pow y y) (exp (- x z)))
(if (<= t_0 1e+47) (exp x) (exp (- t_0 z))))))
double code(double x, double y, double z) {
double t_0 = y * log(y);
double tmp;
if (t_0 <= 200000.0) {
tmp = pow(y, y) * exp((x - z));
} else if (t_0 <= 1e+47) {
tmp = exp(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 <= 200000.0d0) then
tmp = (y ** y) * exp((x - z))
else if (t_0 <= 1d+47) then
tmp = exp(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 <= 200000.0) {
tmp = Math.pow(y, y) * Math.exp((x - z));
} else if (t_0 <= 1e+47) {
tmp = Math.exp(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 <= 200000.0: tmp = math.pow(y, y) * math.exp((x - z)) elif t_0 <= 1e+47: tmp = math.exp(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 <= 200000.0) tmp = Float64((y ^ y) * exp(Float64(x - z))); elseif (t_0 <= 1e+47) tmp = exp(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 <= 200000.0) tmp = (y ^ y) * exp((x - z)); elseif (t_0 <= 1e+47) tmp = exp(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, 200000.0], N[(N[Power[y, y], $MachinePrecision] * N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+47], N[Exp[x], $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 200000:\\
\;\;\;\;{y}^{y} \cdot e^{x - z}\\
\mathbf{elif}\;t\_0 \leq 10^{+47}:\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 - z}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 2e5Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum100.0%
*-commutative100.0%
exp-to-pow100.0%
Simplified100.0%
if 2e5 < (*.f64 y (log.f64 y)) < 1e47Initial program 100.0%
Taylor expanded in x around inf 86.2%
if 1e47 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in x around 0 92.2%
(FPCore (x y z) :precision binary64 (if (<= x -1.95e+145) (exp x) (if (<= x 0.013) (exp (- (* y (log y)) z)) (* (pow y y) (exp x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.95e+145) {
tmp = exp(x);
} else if (x <= 0.013) {
tmp = exp(((y * log(y)) - z));
} else {
tmp = pow(y, y) * 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 (x <= (-1.95d+145)) then
tmp = exp(x)
else if (x <= 0.013d0) then
tmp = exp(((y * log(y)) - z))
else
tmp = (y ** y) * exp(x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.95e+145) {
tmp = Math.exp(x);
} else if (x <= 0.013) {
tmp = Math.exp(((y * Math.log(y)) - z));
} else {
tmp = Math.pow(y, y) * Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.95e+145: tmp = math.exp(x) elif x <= 0.013: tmp = math.exp(((y * math.log(y)) - z)) else: tmp = math.pow(y, y) * math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.95e+145) tmp = exp(x); elseif (x <= 0.013) tmp = exp(Float64(Float64(y * log(y)) - z)); else tmp = Float64((y ^ y) * exp(x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.95e+145) tmp = exp(x); elseif (x <= 0.013) tmp = exp(((y * log(y)) - z)); else tmp = (y ^ y) * exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.95e+145], N[Exp[x], $MachinePrecision], If[LessEqual[x, 0.013], N[Exp[N[(N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision], N[(N[Power[y, y], $MachinePrecision] * N[Exp[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.95 \cdot 10^{+145}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;x \leq 0.013:\\
\;\;\;\;e^{y \cdot \log y - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y} \cdot e^{x}\\
\end{array}
\end{array}
if x < -1.9499999999999999e145Initial program 100.0%
Taylor expanded in x around inf 84.6%
if -1.9499999999999999e145 < x < 0.0129999999999999994Initial program 100.0%
Taylor expanded in x around 0 93.7%
if 0.0129999999999999994 < x Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum94.5%
*-commutative94.5%
exp-to-pow94.5%
Simplified94.5%
Taylor expanded in z around 0 87.5%
*-commutative87.5%
Simplified87.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -680.0) (not (<= z 3.3e+81))) (exp (- z)) (* (pow y y) (exp x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -680.0) || !(z <= 3.3e+81)) {
tmp = exp(-z);
} else {
tmp = pow(y, y) * 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 <= (-680.0d0)) .or. (.not. (z <= 3.3d+81))) then
tmp = exp(-z)
else
tmp = (y ** y) * exp(x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -680.0) || !(z <= 3.3e+81)) {
tmp = Math.exp(-z);
} else {
tmp = Math.pow(y, y) * Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -680.0) or not (z <= 3.3e+81): tmp = math.exp(-z) else: tmp = math.pow(y, y) * math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -680.0) || !(z <= 3.3e+81)) tmp = exp(Float64(-z)); else tmp = Float64((y ^ y) * exp(x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -680.0) || ~((z <= 3.3e+81))) tmp = exp(-z); else tmp = (y ^ y) * exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -680.0], N[Not[LessEqual[z, 3.3e+81]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[(N[Power[y, y], $MachinePrecision] * N[Exp[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -680 \lor \neg \left(z \leq 3.3 \cdot 10^{+81}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y} \cdot e^{x}\\
\end{array}
\end{array}
if z < -680 or 3.3e81 < z Initial program 100.0%
Taylor expanded in z around inf 81.5%
neg-mul-181.5%
Simplified81.5%
if -680 < z < 3.3e81Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum83.3%
*-commutative83.3%
exp-to-pow83.3%
Simplified83.3%
Taylor expanded in z around 0 83.8%
*-commutative83.8%
Simplified83.8%
Final simplification82.8%
(FPCore (x y z) :precision binary64 (if (<= x -4.7e+145) (exp x) (if (<= x 0.0024) (/ (pow y y) (exp z)) (* (pow y y) (exp x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.7e+145) {
tmp = exp(x);
} else if (x <= 0.0024) {
tmp = pow(y, y) / exp(z);
} else {
tmp = pow(y, y) * 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 (x <= (-4.7d+145)) then
tmp = exp(x)
else if (x <= 0.0024d0) then
tmp = (y ** y) / exp(z)
else
tmp = (y ** y) * exp(x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -4.7e+145) {
tmp = Math.exp(x);
} else if (x <= 0.0024) {
tmp = Math.pow(y, y) / Math.exp(z);
} else {
tmp = Math.pow(y, y) * Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.7e+145: tmp = math.exp(x) elif x <= 0.0024: tmp = math.pow(y, y) / math.exp(z) else: tmp = math.pow(y, y) * math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.7e+145) tmp = exp(x); elseif (x <= 0.0024) tmp = Float64((y ^ y) / exp(z)); else tmp = Float64((y ^ y) * exp(x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -4.7e+145) tmp = exp(x); elseif (x <= 0.0024) tmp = (y ^ y) / exp(z); else tmp = (y ^ y) * exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.7e+145], N[Exp[x], $MachinePrecision], If[LessEqual[x, 0.0024], N[(N[Power[y, y], $MachinePrecision] / N[Exp[z], $MachinePrecision]), $MachinePrecision], N[(N[Power[y, y], $MachinePrecision] * N[Exp[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.7 \cdot 10^{+145}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;x \leq 0.0024:\\
\;\;\;\;\frac{{y}^{y}}{e^{z}}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y} \cdot e^{x}\\
\end{array}
\end{array}
if x < -4.7000000000000002e145Initial program 100.0%
Taylor expanded in x around inf 84.6%
if -4.7000000000000002e145 < x < 0.00239999999999999979Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum82.8%
*-commutative82.8%
exp-to-pow82.8%
Simplified82.8%
Taylor expanded in x around 0 84.3%
*-commutative84.3%
exp-to-pow84.3%
*-commutative84.3%
exp-sum93.7%
sub-neg93.7%
exp-diff84.3%
*-commutative84.3%
exp-to-pow84.3%
Simplified84.3%
if 0.00239999999999999979 < x Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum94.5%
*-commutative94.5%
exp-to-pow94.5%
Simplified94.5%
Taylor expanded in z around 0 87.5%
*-commutative87.5%
Simplified87.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.8e+44) (not (<= x 0.023))) (exp x) (exp (- z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.8e+44) || !(x <= 0.023)) {
tmp = exp(x);
} else {
tmp = exp(-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 ((x <= (-3.8d+44)) .or. (.not. (x <= 0.023d0))) then
tmp = exp(x)
else
tmp = exp(-z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3.8e+44) || !(x <= 0.023)) {
tmp = Math.exp(x);
} else {
tmp = Math.exp(-z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.8e+44) or not (x <= 0.023): tmp = math.exp(x) else: tmp = math.exp(-z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.8e+44) || !(x <= 0.023)) tmp = exp(x); else tmp = exp(Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.8e+44) || ~((x <= 0.023))) tmp = exp(x); else tmp = exp(-z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.8e+44], N[Not[LessEqual[x, 0.023]], $MachinePrecision]], N[Exp[x], $MachinePrecision], N[Exp[(-z)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{+44} \lor \neg \left(x \leq 0.023\right):\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;e^{-z}\\
\end{array}
\end{array}
if x < -3.8000000000000002e44 or 0.023 < x Initial program 100.0%
Taylor expanded in x around inf 78.2%
if -3.8000000000000002e44 < x < 0.023Initial program 100.0%
Taylor expanded in z around inf 67.1%
neg-mul-167.1%
Simplified67.1%
Final simplification72.0%
(FPCore (x y z) :precision binary64 (if (<= y 1.5e-14) (exp (- z)) (if (<= y 3e+45) (exp x) (pow y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.5e-14) {
tmp = exp(-z);
} else if (y <= 3e+45) {
tmp = exp(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.5d-14) then
tmp = exp(-z)
else if (y <= 3d+45) then
tmp = exp(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.5e-14) {
tmp = Math.exp(-z);
} else if (y <= 3e+45) {
tmp = Math.exp(x);
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.5e-14: tmp = math.exp(-z) elif y <= 3e+45: tmp = math.exp(x) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.5e-14) tmp = exp(Float64(-z)); elseif (y <= 3e+45) tmp = exp(x); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.5e-14) tmp = exp(-z); elseif (y <= 3e+45) tmp = exp(x); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.5e-14], N[Exp[(-z)], $MachinePrecision], If[LessEqual[y, 3e+45], N[Exp[x], $MachinePrecision], N[Power[y, y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{-14}:\\
\;\;\;\;e^{-z}\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+45}:\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 1.4999999999999999e-14Initial program 100.0%
Taylor expanded in z around inf 76.3%
neg-mul-176.3%
Simplified76.3%
if 1.4999999999999999e-14 < y < 3.00000000000000011e45Initial program 100.0%
Taylor expanded in x around inf 70.7%
if 3.00000000000000011e45 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum64.0%
*-commutative64.0%
exp-to-pow64.0%
Simplified64.0%
Taylor expanded in z around 0 71.1%
*-commutative71.1%
Simplified71.1%
Taylor expanded in x around 0 84.3%
(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 50.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 2024103
(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)))