
(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%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* y (log y)))) (if (<= t_0 -1e-302) (* (pow y y) (exp (- x z))) (exp (- t_0 z)))))
double code(double x, double y, double z) {
double t_0 = y * log(y);
double tmp;
if (t_0 <= -1e-302) {
tmp = pow(y, y) * exp((x - z));
} 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 <= (-1d-302)) then
tmp = (y ** y) * exp((x - z))
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 <= -1e-302) {
tmp = Math.pow(y, y) * Math.exp((x - z));
} 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 <= -1e-302: tmp = math.pow(y, y) * math.exp((x - z)) 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 <= -1e-302) tmp = Float64((y ^ y) * exp(Float64(x - z))); 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 <= -1e-302) tmp = (y ^ y) * exp((x - z)); 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, -1e-302], N[(N[Power[y, y], $MachinePrecision] * N[Exp[N[(x - z), $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 -1 \cdot 10^{-302}:\\
\;\;\;\;{y}^{y} \cdot e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 - z}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < -9.9999999999999996e-303Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum100.0%
*-commutative100.0%
exp-to-pow100.0%
Simplified100.0%
if -9.9999999999999996e-303 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in x around 0 93.6%
(FPCore (x y z) :precision binary64 (if (<= y 0.85) (exp (- x z)) (exp (- (* y (log y)) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.85) {
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 (y <= 0.85d0) 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 (y <= 0.85) {
tmp = Math.exp((x - z));
} else {
tmp = Math.exp(((y * Math.log(y)) - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 0.85: 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 (y <= 0.85) 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 (y <= 0.85) tmp = exp((x - z)); else tmp = exp(((y * log(y)) - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 0.85], 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}\;y \leq 0.85:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{y \cdot \log y - z}\\
\end{array}
\end{array}
if y < 0.849999999999999978Initial program 100.0%
Taylor expanded in x around inf 100.0%
if 0.849999999999999978 < y Initial program 100.0%
Taylor expanded in x around 0 93.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.72) (not (<= z 4.2e+101))) (exp (- z)) (exp x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.72) || !(z <= 4.2e+101)) {
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 <= (-0.72d0)) .or. (.not. (z <= 4.2d+101))) 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 <= -0.72) || !(z <= 4.2e+101)) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.72) or not (z <= 4.2e+101): tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.72) || !(z <= 4.2e+101)) tmp = exp(Float64(-z)); else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.72) || ~((z <= 4.2e+101))) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.72], N[Not[LessEqual[z, 4.2e+101]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.72 \lor \neg \left(z \leq 4.2 \cdot 10^{+101}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if z < -0.71999999999999997 or 4.2e101 < z Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum78.9%
*-commutative78.9%
exp-to-pow78.9%
Simplified78.9%
Taylor expanded in x around 0 74.1%
exp-to-pow74.1%
*-commutative74.1%
prod-exp92.8%
+-commutative92.8%
sub-neg92.8%
div-exp74.1%
*-commutative74.1%
exp-to-pow74.1%
Simplified74.1%
Taylor expanded in y around 0 86.4%
rec-exp86.4%
Simplified86.4%
if -0.71999999999999997 < z < 4.2e101Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum86.5%
*-commutative86.5%
exp-to-pow86.5%
Simplified86.5%
Taylor expanded in z around 0 88.7%
Taylor expanded in y around 0 69.3%
Final simplification77.5%
(FPCore (x y z) :precision binary64 (if (<= y 1.02e-140) (exp x) (if (<= y 5400.0) (exp (- z)) (pow y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.02e-140) {
tmp = exp(x);
} else if (y <= 5400.0) {
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 <= 1.02d-140) then
tmp = exp(x)
else if (y <= 5400.0d0) 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 <= 1.02e-140) {
tmp = Math.exp(x);
} else if (y <= 5400.0) {
tmp = Math.exp(-z);
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.02e-140: tmp = math.exp(x) elif y <= 5400.0: tmp = math.exp(-z) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.02e-140) tmp = exp(x); elseif (y <= 5400.0) tmp = exp(Float64(-z)); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.02e-140) tmp = exp(x); elseif (y <= 5400.0) tmp = exp(-z); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.02e-140], N[Exp[x], $MachinePrecision], If[LessEqual[y, 5400.0], N[Exp[(-z)], $MachinePrecision], N[Power[y, y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.02 \cdot 10^{-140}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;y \leq 5400:\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 1.01999999999999995e-140Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum100.0%
*-commutative100.0%
exp-to-pow100.0%
Simplified100.0%
Taylor expanded in z around 0 78.3%
Taylor expanded in y around 0 78.3%
if 1.01999999999999995e-140 < y < 5400Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum98.3%
*-commutative98.3%
exp-to-pow98.3%
Simplified98.3%
Taylor expanded in x around 0 73.2%
exp-to-pow73.2%
*-commutative73.2%
prod-exp74.9%
+-commutative74.9%
sub-neg74.9%
div-exp73.2%
*-commutative73.2%
exp-to-pow73.2%
Simplified73.2%
Taylor expanded in y around 0 73.5%
rec-exp73.5%
Simplified73.5%
if 5400 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum64.8%
*-commutative64.8%
exp-to-pow64.8%
Simplified64.8%
Taylor expanded in z around 0 66.5%
Taylor expanded in x around 0 82.2%
(FPCore (x y z) :precision binary64 (if (<= y 3e+148) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3e+148) {
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 <= 3d+148) 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 <= 3e+148) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3e+148: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3e+148) 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 <= 3e+148) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3e+148], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3 \cdot 10^{+148}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 3.00000000000000015e148Initial program 100.0%
Taylor expanded in x around inf 91.4%
if 3.00000000000000015e148 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum64.6%
*-commutative64.6%
exp-to-pow64.6%
Simplified64.6%
Taylor expanded in z around 0 69.3%
Taylor expanded in x around 0 92.4%
(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-sum82.8%
*-commutative82.8%
exp-to-pow82.8%
Simplified82.8%
Taylor expanded in z around 0 68.9%
Taylor expanded in y around 0 54.1%
(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 2024097
(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)))