
(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 -1e-303) (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-303) {
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 <= (-1d-303)) 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 <= -1e-303) {
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 <= -1e-303: 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 <= -1e-303) 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 <= -1e-303) 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, -1e-303], 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 -1 \cdot 10^{-303}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - z}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < -9.99999999999999931e-304Initial program 100.0%
Taylor expanded in x around inf 100.0%
if -9.99999999999999931e-304 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in x around 0 94.1%
Final simplification96.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (exp (- z))))
(if (<= y 7.1e-211)
(exp x)
(if (<= y 1.15e-154)
t_0
(if (<= y 2.5e-116)
(exp x)
(if (<= y 1.58e-96)
t_0
(if (<= y 6.7) (exp x) (if (<= y 1.85e+28) t_0 (pow y y)))))))))
double code(double x, double y, double z) {
double t_0 = exp(-z);
double tmp;
if (y <= 7.1e-211) {
tmp = exp(x);
} else if (y <= 1.15e-154) {
tmp = t_0;
} else if (y <= 2.5e-116) {
tmp = exp(x);
} else if (y <= 1.58e-96) {
tmp = t_0;
} else if (y <= 6.7) {
tmp = exp(x);
} else if (y <= 1.85e+28) {
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(-z)
if (y <= 7.1d-211) then
tmp = exp(x)
else if (y <= 1.15d-154) then
tmp = t_0
else if (y <= 2.5d-116) then
tmp = exp(x)
else if (y <= 1.58d-96) then
tmp = t_0
else if (y <= 6.7d0) then
tmp = exp(x)
else if (y <= 1.85d+28) 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(-z);
double tmp;
if (y <= 7.1e-211) {
tmp = Math.exp(x);
} else if (y <= 1.15e-154) {
tmp = t_0;
} else if (y <= 2.5e-116) {
tmp = Math.exp(x);
} else if (y <= 1.58e-96) {
tmp = t_0;
} else if (y <= 6.7) {
tmp = Math.exp(x);
} else if (y <= 1.85e+28) {
tmp = t_0;
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): t_0 = math.exp(-z) tmp = 0 if y <= 7.1e-211: tmp = math.exp(x) elif y <= 1.15e-154: tmp = t_0 elif y <= 2.5e-116: tmp = math.exp(x) elif y <= 1.58e-96: tmp = t_0 elif y <= 6.7: tmp = math.exp(x) elif y <= 1.85e+28: tmp = t_0 else: tmp = math.pow(y, y) return tmp
function code(x, y, z) t_0 = exp(Float64(-z)) tmp = 0.0 if (y <= 7.1e-211) tmp = exp(x); elseif (y <= 1.15e-154) tmp = t_0; elseif (y <= 2.5e-116) tmp = exp(x); elseif (y <= 1.58e-96) tmp = t_0; elseif (y <= 6.7) tmp = exp(x); elseif (y <= 1.85e+28) tmp = t_0; else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) t_0 = exp(-z); tmp = 0.0; if (y <= 7.1e-211) tmp = exp(x); elseif (y <= 1.15e-154) tmp = t_0; elseif (y <= 2.5e-116) tmp = exp(x); elseif (y <= 1.58e-96) tmp = t_0; elseif (y <= 6.7) tmp = exp(x); elseif (y <= 1.85e+28) tmp = t_0; else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Exp[(-z)], $MachinePrecision]}, If[LessEqual[y, 7.1e-211], N[Exp[x], $MachinePrecision], If[LessEqual[y, 1.15e-154], t$95$0, If[LessEqual[y, 2.5e-116], N[Exp[x], $MachinePrecision], If[LessEqual[y, 1.58e-96], t$95$0, If[LessEqual[y, 6.7], N[Exp[x], $MachinePrecision], If[LessEqual[y, 1.85e+28], t$95$0, N[Power[y, y], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-z}\\
\mathbf{if}\;y \leq 7.1 \cdot 10^{-211}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{-154}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-116}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;y \leq 1.58 \cdot 10^{-96}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 6.7:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+28}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 7.09999999999999987e-211 or 1.15e-154 < y < 2.5000000000000001e-116 or 1.5800000000000001e-96 < y < 6.70000000000000018Initial program 100.0%
exp-diff90.0%
+-commutative90.0%
exp-sum90.0%
associate-*r/90.0%
*-commutative90.0%
exp-to-pow90.0%
exp-diff100.0%
Simplified100.0%
Taylor expanded in z around 0 83.0%
*-commutative83.0%
Simplified83.0%
Taylor expanded in y around 0 83.0%
if 7.09999999999999987e-211 < y < 1.15e-154 or 2.5000000000000001e-116 < y < 1.5800000000000001e-96 or 6.70000000000000018 < y < 1.85e28Initial program 100.0%
Taylor expanded in z around inf 79.8%
mul-1-neg79.8%
Simplified79.8%
if 1.85e28 < y Initial program 100.0%
exp-diff78.8%
+-commutative78.8%
exp-sum59.3%
associate-*r/59.3%
*-commutative59.3%
exp-to-pow59.3%
exp-diff68.6%
Simplified68.6%
Taylor expanded in z around 0 72.9%
*-commutative72.9%
Simplified72.9%
Taylor expanded in x around 0 87.5%
Final simplification84.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -700.0) (not (<= z 5.5e+86))) (exp (- z)) (exp x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -700.0) || !(z <= 5.5e+86)) {
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 <= 5.5d+86))) 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 <= 5.5e+86)) {
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 <= 5.5e+86): tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -700.0) || !(z <= 5.5e+86)) 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 <= 5.5e+86))) 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, 5.5e+86]], $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 5.5 \cdot 10^{+86}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if z < -700 or 5.5000000000000002e86 < z Initial program 100.0%
Taylor expanded in z around inf 87.2%
mul-1-neg87.2%
Simplified87.2%
if -700 < z < 5.5000000000000002e86Initial program 100.0%
exp-diff91.5%
+-commutative91.5%
exp-sum79.4%
associate-*r/79.4%
*-commutative79.4%
exp-to-pow79.4%
exp-diff83.0%
Simplified83.0%
Taylor expanded in z around 0 83.7%
*-commutative83.7%
Simplified83.7%
Taylor expanded in y around 0 68.2%
Final simplification76.7%
(FPCore (x y z) :precision binary64 (if (<= y 1.6e+141) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.6e+141) {
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+141) 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+141) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.6e+141: 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+141) 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+141) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.6e+141], 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^{+141}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 1.60000000000000009e141Initial program 100.0%
Taylor expanded in x around inf 94.2%
if 1.60000000000000009e141 < y Initial program 100.0%
exp-diff80.8%
+-commutative80.8%
exp-sum61.6%
associate-*r/61.6%
*-commutative61.6%
exp-to-pow61.6%
exp-diff68.5%
Simplified68.5%
Taylor expanded in z around 0 76.8%
*-commutative76.8%
Simplified76.8%
Taylor expanded in x around 0 96.0%
Final simplification94.7%
(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%
exp-diff82.0%
+-commutative82.0%
exp-sum72.7%
associate-*r/72.7%
*-commutative72.7%
exp-to-pow72.7%
exp-diff84.0%
Simplified84.0%
Taylor expanded in z around 0 70.3%
*-commutative70.3%
Simplified70.3%
Taylor expanded in y around 0 54.0%
Final simplification54.0%
(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 2023301
(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)))