
(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 6 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 (* y (log y)))) (if (<= t_0 100000000.0) (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 <= 100000000.0) {
tmp = 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 <= 100000000.0d0) then
tmp = 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 <= 100000000.0) {
tmp = 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 <= 100000000.0: tmp = 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 <= 100000000.0) tmp = 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 <= 100000000.0) tmp = 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, 100000000.0], N[Exp[N[(x - z), $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 100000000:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 - z}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 1e8Initial program 100.0%
Taylor expanded in x around inf 100.0%
if 1e8 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in x around 0 93.6%
Final simplification97.3%
(FPCore (x y z) :precision binary64 (if (<= x -2.1e+103) (exp x) (if (<= x -23500000.0) (pow y y) (if (<= x 125.0) (exp (- z)) (exp x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.1e+103) {
tmp = exp(x);
} else if (x <= -23500000.0) {
tmp = pow(y, y);
} else if (x <= 125.0) {
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 (x <= (-2.1d+103)) then
tmp = exp(x)
else if (x <= (-23500000.0d0)) then
tmp = y ** y
else if (x <= 125.0d0) 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 (x <= -2.1e+103) {
tmp = Math.exp(x);
} else if (x <= -23500000.0) {
tmp = Math.pow(y, y);
} else if (x <= 125.0) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.1e+103: tmp = math.exp(x) elif x <= -23500000.0: tmp = math.pow(y, y) elif x <= 125.0: tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.1e+103) tmp = exp(x); elseif (x <= -23500000.0) tmp = y ^ y; elseif (x <= 125.0) tmp = exp(Float64(-z)); else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.1e+103) tmp = exp(x); elseif (x <= -23500000.0) tmp = y ^ y; elseif (x <= 125.0) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.1e+103], N[Exp[x], $MachinePrecision], If[LessEqual[x, -23500000.0], N[Power[y, y], $MachinePrecision], If[LessEqual[x, 125.0], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{+103}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;x \leq -23500000:\\
\;\;\;\;{y}^{y}\\
\mathbf{elif}\;x \leq 125:\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if x < -2.1000000000000002e103 or 125 < x Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum80.2%
*-commutative80.2%
exp-to-pow80.2%
Simplified80.2%
Taylor expanded in z around 0 75.6%
*-commutative75.6%
Simplified75.6%
Taylor expanded in y around 0 85.1%
if -2.1000000000000002e103 < x < -2.35e7Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum47.1%
*-commutative47.1%
exp-to-pow47.1%
Simplified47.1%
Taylor expanded in z around 0 29.4%
*-commutative29.4%
Simplified29.4%
Taylor expanded in x around 0 71.5%
if -2.35e7 < x < 125Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum94.7%
*-commutative94.7%
exp-to-pow94.7%
Simplified94.7%
Taylor expanded in x around 0 94.2%
exp-neg94.2%
associate-*l/94.2%
*-lft-identity94.2%
Simplified94.2%
Taylor expanded in y around 0 81.2%
rec-exp81.3%
Simplified81.3%
Final simplification82.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -460000000.0) (not (<= x 135.0))) (exp x) (exp (- z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -460000000.0) || !(x <= 135.0)) {
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 <= (-460000000.0d0)) .or. (.not. (x <= 135.0d0))) 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 <= -460000000.0) || !(x <= 135.0)) {
tmp = Math.exp(x);
} else {
tmp = Math.exp(-z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -460000000.0) or not (x <= 135.0): tmp = math.exp(x) else: tmp = math.exp(-z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -460000000.0) || !(x <= 135.0)) tmp = exp(x); else tmp = exp(Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -460000000.0) || ~((x <= 135.0))) tmp = exp(x); else tmp = exp(-z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -460000000.0], N[Not[LessEqual[x, 135.0]], $MachinePrecision]], N[Exp[x], $MachinePrecision], N[Exp[(-z)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -460000000 \lor \neg \left(x \leq 135\right):\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;e^{-z}\\
\end{array}
\end{array}
if x < -4.6e8 or 135 < x Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum76.2%
*-commutative76.2%
exp-to-pow76.2%
Simplified76.2%
Taylor expanded in z around 0 69.8%
*-commutative69.8%
Simplified69.8%
Taylor expanded in y around 0 78.2%
if -4.6e8 < x < 135Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum94.0%
*-commutative94.0%
exp-to-pow94.0%
Simplified94.0%
Taylor expanded in x around 0 94.3%
exp-neg94.3%
associate-*l/94.3%
*-lft-identity94.3%
Simplified94.3%
Taylor expanded in y around 0 80.7%
rec-exp80.7%
Simplified80.7%
Final simplification79.5%
(FPCore (x y z) :precision binary64 (if (<= y 4e+79) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 4e+79) {
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 <= 4d+79) 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 <= 4e+79) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4e+79: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4e+79) 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 <= 4e+79) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4e+79], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{+79}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 3.99999999999999987e79Initial program 100.0%
Taylor expanded in x around inf 97.2%
if 3.99999999999999987e79 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum71.6%
*-commutative71.6%
exp-to-pow71.6%
Simplified71.6%
Taylor expanded in z around 0 74.2%
*-commutative74.2%
Simplified74.2%
Taylor expanded in x around 0 90.3%
Final simplification95.0%
(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-sum85.5%
*-commutative85.5%
exp-to-pow85.5%
Simplified85.5%
Taylor expanded in z around 0 67.9%
*-commutative67.9%
Simplified67.9%
Taylor expanded in y around 0 54.5%
Final simplification54.5%
(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 2024036
(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)))