
(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 7 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 (if (or (<= x -2.45e+39) (not (<= x 2.65e-5))) (exp (- x z)) (exp (- (* y (log y)) z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.45e+39) || !(x <= 2.65e-5)) {
tmp = exp((x - z));
} else {
tmp = exp(((y * log(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 ((x <= (-2.45d+39)) .or. (.not. (x <= 2.65d-5))) then
tmp = exp((x - z))
else
tmp = exp(((y * log(y)) - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.45e+39) || !(x <= 2.65e-5)) {
tmp = Math.exp((x - z));
} else {
tmp = Math.exp(((y * Math.log(y)) - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.45e+39) or not (x <= 2.65e-5): tmp = math.exp((x - z)) else: tmp = math.exp(((y * math.log(y)) - z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.45e+39) || !(x <= 2.65e-5)) tmp = exp(Float64(x - z)); else tmp = exp(Float64(Float64(y * log(y)) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.45e+39) || ~((x <= 2.65e-5))) tmp = exp((x - z)); else tmp = exp(((y * log(y)) - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.45e+39], N[Not[LessEqual[x, 2.65e-5]], $MachinePrecision]], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.45 \cdot 10^{+39} \lor \neg \left(x \leq 2.65 \cdot 10^{-5}\right):\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{y \cdot \log y - z}\\
\end{array}
\end{array}
if x < -2.44999999999999994e39 or 2.65e-5 < x Initial program 100.0%
Taylor expanded in x around inf 94.8%
if -2.44999999999999994e39 < x < 2.65e-5Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification97.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.08e+20) (not (<= x 1.3e-5))) (exp (- x z)) (/ (pow y y) (exp z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.08e+20) || !(x <= 1.3e-5)) {
tmp = exp((x - z));
} else {
tmp = pow(y, y) / 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 <= (-1.08d+20)) .or. (.not. (x <= 1.3d-5))) then
tmp = exp((x - z))
else
tmp = (y ** y) / exp(z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.08e+20) || !(x <= 1.3e-5)) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y) / Math.exp(z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.08e+20) or not (x <= 1.3e-5): tmp = math.exp((x - z)) else: tmp = math.pow(y, y) / math.exp(z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.08e+20) || !(x <= 1.3e-5)) tmp = exp(Float64(x - z)); else tmp = Float64((y ^ y) / exp(z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.08e+20) || ~((x <= 1.3e-5))) tmp = exp((x - z)); else tmp = (y ^ y) / exp(z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.08e+20], N[Not[LessEqual[x, 1.3e-5]], $MachinePrecision]], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[(N[Power[y, y], $MachinePrecision] / N[Exp[z], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.08 \cdot 10^{+20} \lor \neg \left(x \leq 1.3 \cdot 10^{-5}\right):\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{{y}^{y}}{e^{z}}\\
\end{array}
\end{array}
if x < -1.08e20 or 1.29999999999999992e-5 < x Initial program 100.0%
Taylor expanded in x around inf 94.1%
if -1.08e20 < x < 1.29999999999999992e-5Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum86.9%
*-commutative86.9%
exp-to-pow86.9%
Simplified86.9%
Taylor expanded in x around 0 87.7%
exp-neg87.7%
associate-*l/87.7%
*-lft-identity87.7%
Simplified87.7%
Final simplification91.1%
(FPCore (x y z) :precision binary64 (if (or (<= y 180000.0) (and (not (<= y 2.6e+67)) (<= y 1.6e+188))) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= 180000.0) || (!(y <= 2.6e+67) && (y <= 1.6e+188))) {
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 <= 180000.0d0) .or. (.not. (y <= 2.6d+67)) .and. (y <= 1.6d+188)) 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 <= 180000.0) || (!(y <= 2.6e+67) && (y <= 1.6e+188))) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= 180000.0) or (not (y <= 2.6e+67) and (y <= 1.6e+188)): tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= 180000.0) || (!(y <= 2.6e+67) && (y <= 1.6e+188))) 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 <= 180000.0) || (~((y <= 2.6e+67)) && (y <= 1.6e+188))) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, 180000.0], And[N[Not[LessEqual[y, 2.6e+67]], $MachinePrecision], LessEqual[y, 1.6e+188]]], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 180000 \lor \neg \left(y \leq 2.6 \cdot 10^{+67}\right) \land y \leq 1.6 \cdot 10^{+188}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 1.8e5 or 2.6e67 < y < 1.59999999999999985e188Initial program 100.0%
Taylor expanded in x around inf 92.8%
if 1.8e5 < y < 2.6e67 or 1.59999999999999985e188 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum69.3%
*-commutative69.3%
exp-to-pow69.3%
Simplified69.3%
Taylor expanded in z around 0 74.7%
*-commutative74.7%
Simplified74.7%
Taylor expanded in x around 0 92.1%
Final simplification92.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (exp (- z))))
(if (<= z -29000000.0)
t_0
(if (<= z 1.7e-297) (pow y y) (if (<= z 1.1e+47) (exp x) t_0)))))
double code(double x, double y, double z) {
double t_0 = exp(-z);
double tmp;
if (z <= -29000000.0) {
tmp = t_0;
} else if (z <= 1.7e-297) {
tmp = pow(y, y);
} else if (z <= 1.1e+47) {
tmp = exp(x);
} else {
tmp = t_0;
}
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 = exp(-z)
if (z <= (-29000000.0d0)) then
tmp = t_0
else if (z <= 1.7d-297) then
tmp = y ** y
else if (z <= 1.1d+47) then
tmp = exp(x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.exp(-z);
double tmp;
if (z <= -29000000.0) {
tmp = t_0;
} else if (z <= 1.7e-297) {
tmp = Math.pow(y, y);
} else if (z <= 1.1e+47) {
tmp = Math.exp(x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.exp(-z) tmp = 0 if z <= -29000000.0: tmp = t_0 elif z <= 1.7e-297: tmp = math.pow(y, y) elif z <= 1.1e+47: tmp = math.exp(x) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = exp(Float64(-z)) tmp = 0.0 if (z <= -29000000.0) tmp = t_0; elseif (z <= 1.7e-297) tmp = y ^ y; elseif (z <= 1.1e+47) tmp = exp(x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = exp(-z); tmp = 0.0; if (z <= -29000000.0) tmp = t_0; elseif (z <= 1.7e-297) tmp = y ^ y; elseif (z <= 1.1e+47) tmp = exp(x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Exp[(-z)], $MachinePrecision]}, If[LessEqual[z, -29000000.0], t$95$0, If[LessEqual[z, 1.7e-297], N[Power[y, y], $MachinePrecision], If[LessEqual[z, 1.1e+47], N[Exp[x], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-z}\\
\mathbf{if}\;z \leq -29000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{-297}:\\
\;\;\;\;{y}^{y}\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{+47}:\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.9e7 or 1.1e47 < z Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum79.7%
*-commutative79.7%
exp-to-pow79.7%
Simplified79.7%
Taylor expanded in x around 0 75.5%
exp-neg75.5%
associate-*l/75.5%
*-lft-identity75.5%
Simplified75.5%
Taylor expanded in y around 0 85.0%
rec-exp85.0%
Simplified85.0%
if -2.9e7 < z < 1.69999999999999991e-297Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum90.9%
*-commutative90.9%
exp-to-pow90.9%
Simplified90.9%
Taylor expanded in z around 0 90.3%
*-commutative90.3%
Simplified90.3%
Taylor expanded in x around 0 78.8%
if 1.69999999999999991e-297 < z < 1.1e47Initial 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 85.0%
*-commutative85.0%
Simplified85.0%
Taylor expanded in y around 0 68.5%
Final simplification78.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -700.0) (not (<= z 1.95e+46))) (exp (- z)) (exp x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -700.0) || !(z <= 1.95e+46)) {
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 <= (-700.0d0)) .or. (.not. (z <= 1.95d+46))) 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 <= -700.0) || !(z <= 1.95e+46)) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -700.0) or not (z <= 1.95e+46): tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -700.0) || !(z <= 1.95e+46)) tmp = exp(Float64(-z)); else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -700.0) || ~((z <= 1.95e+46))) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -700.0], N[Not[LessEqual[z, 1.95e+46]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -700 \lor \neg \left(z \leq 1.95 \cdot 10^{+46}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if z < -700 or 1.94999999999999997e46 < z Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum79.8%
*-commutative79.8%
exp-to-pow79.8%
Simplified79.8%
Taylor expanded in x around 0 75.7%
exp-neg75.7%
associate-*l/75.7%
*-lft-identity75.7%
Simplified75.7%
Taylor expanded in y around 0 85.1%
rec-exp85.1%
Simplified85.1%
if -700 < z < 1.94999999999999997e46Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum86.9%
*-commutative86.9%
exp-to-pow86.9%
Simplified86.9%
Taylor expanded in z around 0 87.4%
*-commutative87.4%
Simplified87.4%
Taylor expanded in y around 0 66.9%
Final simplification75.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%
+-commutative100.0%
associate--l+100.0%
exp-sum83.6%
*-commutative83.6%
exp-to-pow83.6%
Simplified83.6%
Taylor expanded in z around 0 68.0%
*-commutative68.0%
Simplified68.0%
Taylor expanded in y around 0 50.7%
Final simplification50.7%
(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 2024031
(FPCore (x y z)
:name "Statistics.Distribution.Poisson.Internal:probability from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(exp (+ (- x z) (* (log y) y)))
(exp (- (+ x (* y (log y))) z)))