
(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%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (<= x -2.65e+54) (exp x) (if (<= x -1.85e-258) (exp (- z)) (if (<= x 2.7e+22) (pow y y) (exp x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.65e+54) {
tmp = exp(x);
} else if (x <= -1.85e-258) {
tmp = exp(-z);
} else if (x <= 2.7e+22) {
tmp = pow(y, y);
} 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 (x <= (-2.65d+54)) then
tmp = exp(x)
else if (x <= (-1.85d-258)) then
tmp = exp(-z)
else if (x <= 2.7d+22) then
tmp = y ** y
else
tmp = exp(x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.65e+54) {
tmp = Math.exp(x);
} else if (x <= -1.85e-258) {
tmp = Math.exp(-z);
} else if (x <= 2.7e+22) {
tmp = Math.pow(y, y);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.65e+54: tmp = math.exp(x) elif x <= -1.85e-258: tmp = math.exp(-z) elif x <= 2.7e+22: tmp = math.pow(y, y) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.65e+54) tmp = exp(x); elseif (x <= -1.85e-258) tmp = exp(Float64(-z)); elseif (x <= 2.7e+22) tmp = y ^ y; else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.65e+54) tmp = exp(x); elseif (x <= -1.85e-258) tmp = exp(-z); elseif (x <= 2.7e+22) tmp = y ^ y; else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.65e+54], N[Exp[x], $MachinePrecision], If[LessEqual[x, -1.85e-258], N[Exp[(-z)], $MachinePrecision], If[LessEqual[x, 2.7e+22], N[Power[y, y], $MachinePrecision], N[Exp[x], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.65 \cdot 10^{+54}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{-258}:\\
\;\;\;\;e^{-z}\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+22}:\\
\;\;\;\;{y}^{y}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if x < -2.65000000000000009e54 or 2.7000000000000002e22 < x Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum73.5%
*-commutative73.5%
exp-to-pow73.5%
Simplified73.5%
Taylor expanded in z around 0 66.0%
*-commutative66.0%
Simplified66.0%
Taylor expanded in y around 0 81.5%
if -2.65000000000000009e54 < x < -1.85e-258Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum89.8%
*-commutative89.8%
exp-to-pow89.8%
Simplified89.8%
Taylor expanded in x around 0 88.2%
exp-neg88.2%
associate-*l/88.2%
*-lft-identity88.2%
Simplified88.2%
Taylor expanded in y around 0 72.0%
rec-exp72.0%
Simplified72.0%
if -1.85e-258 < x < 2.7000000000000002e22Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum86.2%
*-commutative86.2%
exp-to-pow86.2%
Simplified86.2%
Taylor expanded in z around 0 74.8%
*-commutative74.8%
Simplified74.8%
Taylor expanded in x around 0 73.9%
Final simplification76.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -12500000000.0) (not (<= z 6.6e+65))) (exp (- z)) (exp x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -12500000000.0) || !(z <= 6.6e+65)) {
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 <= (-12500000000.0d0)) .or. (.not. (z <= 6.6d+65))) 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 <= -12500000000.0) || !(z <= 6.6e+65)) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -12500000000.0) or not (z <= 6.6e+65): tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -12500000000.0) || !(z <= 6.6e+65)) tmp = exp(Float64(-z)); else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -12500000000.0) || ~((z <= 6.6e+65))) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -12500000000.0], N[Not[LessEqual[z, 6.6e+65]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -12500000000 \lor \neg \left(z \leq 6.6 \cdot 10^{+65}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if z < -1.25e10 or 6.60000000000000046e65 < z Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum77.9%
*-commutative77.9%
exp-to-pow77.9%
Simplified77.9%
Taylor expanded in x around 0 71.8%
exp-neg71.8%
associate-*l/71.8%
*-lft-identity71.8%
Simplified71.8%
Taylor expanded in y around 0 87.8%
rec-exp87.8%
Simplified87.8%
if -1.25e10 < z < 6.60000000000000046e65Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum83.9%
*-commutative83.9%
exp-to-pow83.9%
Simplified83.9%
Taylor expanded in z around 0 83.5%
*-commutative83.5%
Simplified83.5%
Taylor expanded in y around 0 65.7%
Final simplification75.5%
(FPCore (x y z) :precision binary64 (if (<= y 1.6e+95) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.6e+95) {
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.6d+95) 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.6e+95) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.6e+95: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.6e+95) 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.6e+95) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.6e+95], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{+95}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 1.6e95Initial program 100.0%
Taylor expanded in x around inf 93.0%
if 1.6e95 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum70.2%
*-commutative70.2%
exp-to-pow70.2%
Simplified70.2%
Taylor expanded in z around 0 74.5%
*-commutative74.5%
Simplified74.5%
Taylor expanded in x around 0 86.4%
Final simplification90.5%
(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-sum81.2%
*-commutative81.2%
exp-to-pow81.2%
Simplified81.2%
Taylor expanded in z around 0 65.9%
*-commutative65.9%
Simplified65.9%
Taylor expanded in y around 0 53.1%
Final simplification53.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 2023310
(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)))