
(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 (let* ((t_0 (exp (- x z)))) (if (<= y 6.4e+44) (* (pow y y) t_0) (if (<= y 5.4e+93) t_0 (pow y y)))))
double code(double x, double y, double z) {
double t_0 = exp((x - z));
double tmp;
if (y <= 6.4e+44) {
tmp = pow(y, y) * t_0;
} else if (y <= 5.4e+93) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = exp((x - z))
if (y <= 6.4d+44) then
tmp = (y ** y) * t_0
else if (y <= 5.4d+93) then
tmp = t_0
else
tmp = y ** y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.exp((x - z));
double tmp;
if (y <= 6.4e+44) {
tmp = Math.pow(y, y) * t_0;
} else if (y <= 5.4e+93) {
tmp = t_0;
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): t_0 = math.exp((x - z)) tmp = 0 if y <= 6.4e+44: tmp = math.pow(y, y) * t_0 elif y <= 5.4e+93: tmp = t_0 else: tmp = math.pow(y, y) return tmp
function code(x, y, z) t_0 = exp(Float64(x - z)) tmp = 0.0 if (y <= 6.4e+44) tmp = Float64((y ^ y) * t_0); elseif (y <= 5.4e+93) tmp = t_0; else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) t_0 = exp((x - z)); tmp = 0.0; if (y <= 6.4e+44) tmp = (y ^ y) * t_0; elseif (y <= 5.4e+93) tmp = t_0; else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 6.4e+44], N[(N[Power[y, y], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[y, 5.4e+93], t$95$0, N[Power[y, y], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{x - z}\\
\mathbf{if}\;y \leq 6.4 \cdot 10^{+44}:\\
\;\;\;\;{y}^{y} \cdot t_0\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{+93}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 6.40000000000000009e44Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum96.4%
*-commutative96.4%
exp-to-pow96.4%
Simplified96.4%
if 6.40000000000000009e44 < y < 5.3999999999999999e93Initial program 100.0%
Taylor expanded in x around inf 89.2%
if 5.3999999999999999e93 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum65.9%
*-commutative65.9%
exp-to-pow65.9%
Simplified65.9%
Taylor expanded in z around 0 79.1%
Taylor expanded in x around 0 93.5%
Final simplification94.6%
(FPCore (x y z) :precision binary64 (if (or (<= y 3.4e+21) (and (not (<= y 6.3e+44)) (<= y 9.2e+92))) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= 3.4e+21) || (!(y <= 6.3e+44) && (y <= 9.2e+92))) {
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 <= 3.4d+21) .or. (.not. (y <= 6.3d+44)) .and. (y <= 9.2d+92)) 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 <= 3.4e+21) || (!(y <= 6.3e+44) && (y <= 9.2e+92))) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= 3.4e+21) or (not (y <= 6.3e+44) and (y <= 9.2e+92)): tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= 3.4e+21) || (!(y <= 6.3e+44) && (y <= 9.2e+92))) 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 <= 3.4e+21) || (~((y <= 6.3e+44)) && (y <= 9.2e+92))) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, 3.4e+21], And[N[Not[LessEqual[y, 6.3e+44]], $MachinePrecision], LessEqual[y, 9.2e+92]]], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.4 \cdot 10^{+21} \lor \neg \left(y \leq 6.3 \cdot 10^{+44}\right) \land y \leq 9.2 \cdot 10^{+92}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 3.4e21 or 6.3e44 < y < 9.19999999999999994e92Initial program 100.0%
Taylor expanded in x around inf 96.9%
if 3.4e21 < y < 6.3e44 or 9.19999999999999994e92 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum68.2%
*-commutative68.2%
exp-to-pow68.2%
Simplified68.2%
Taylor expanded in z around 0 79.5%
Taylor expanded in x around 0 91.7%
Final simplification94.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.3e-8) (not (<= z 4.9e+79))) (exp (- z)) (exp x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.3e-8) || !(z <= 4.9e+79)) {
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 <= (-1.3d-8)) .or. (.not. (z <= 4.9d+79))) 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 <= -1.3e-8) || !(z <= 4.9e+79)) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.3e-8) or not (z <= 4.9e+79): tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.3e-8) || !(z <= 4.9e+79)) tmp = exp(Float64(-z)); else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.3e-8) || ~((z <= 4.9e+79))) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.3e-8], N[Not[LessEqual[z, 4.9e+79]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{-8} \lor \neg \left(z \leq 4.9 \cdot 10^{+79}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if z < -1.3000000000000001e-8 or 4.8999999999999999e79 < z Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum76.4%
*-commutative76.4%
exp-to-pow76.4%
Simplified76.4%
Taylor expanded in x around 0 74.9%
exp-neg74.9%
associate-*l/74.9%
*-lft-identity74.9%
Simplified74.9%
Taylor expanded in y around 0 83.7%
rec-exp83.7%
Simplified83.7%
if -1.3000000000000001e-8 < z < 4.8999999999999999e79Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum86.0%
*-commutative86.0%
exp-to-pow86.0%
Simplified86.0%
Taylor expanded in z around 0 88.9%
Taylor expanded in y around 0 63.7%
Final simplification73.7%
(FPCore (x y z) :precision binary64 (if (<= y 9.5e-14) (exp (- z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 9.5e-14) {
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 <= 9.5d-14) 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 <= 9.5e-14) {
tmp = Math.exp(-z);
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 9.5e-14: tmp = math.exp(-z) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 9.5e-14) tmp = exp(Float64(-z)); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 9.5e-14) tmp = exp(-z); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 9.5e-14], N[Exp[(-z)], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.5 \cdot 10^{-14}:\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 9.4999999999999999e-14Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum100.0%
*-commutative100.0%
exp-to-pow100.0%
Simplified100.0%
Taylor expanded in x around 0 77.5%
exp-neg77.5%
associate-*l/77.5%
*-lft-identity77.5%
Simplified77.5%
Taylor expanded in y around 0 77.5%
rec-exp77.5%
Simplified77.5%
if 9.4999999999999999e-14 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum66.2%
*-commutative66.2%
exp-to-pow66.2%
Simplified66.2%
Taylor expanded in z around 0 74.7%
Taylor expanded in x around 0 82.5%
Final simplification80.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%
+-commutative100.0%
associate--l+100.0%
exp-sum81.2%
*-commutative81.2%
exp-to-pow81.2%
Simplified81.2%
Taylor expanded in z around 0 69.9%
Taylor expanded in y around 0 49.1%
Final simplification49.1%
(FPCore (x y z) :precision binary64 (+ x 1.0))
double code(double x, double y, double z) {
return x + 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + 1.0d0
end function
public static double code(double x, double y, double z) {
return x + 1.0;
}
def code(x, y, z): return x + 1.0
function code(x, y, z) return Float64(x + 1.0) end
function tmp = code(x, y, z) tmp = x + 1.0; end
code[x_, y_, z_] := N[(x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
x + 1
\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 69.9%
Taylor expanded in x around 0 38.2%
+-commutative38.2%
*-rgt-identity38.2%
distribute-lft-out52.0%
Simplified52.0%
Taylor expanded in y around 0 13.6%
Final simplification13.6%
(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 2023200
(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)))