
(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 (* y (log y)))) (if (<= t_0 10.0) (* (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 <= 10.0) {
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 <= 10.0d0) 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 <= 10.0) {
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 <= 10.0: 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 <= 10.0) 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 <= 10.0) 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, 10.0], 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 10:\\
\;\;\;\;{y}^{y} \cdot e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 - z}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 10Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum100.0%
*-commutative100.0%
exp-to-pow100.0%
Simplified100.0%
if 10 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in x around 0 91.8%
Final simplification95.8%
(FPCore (x y z) :precision binary64 (if (<= y 2.45e-20) (exp (- x z)) (exp (- (* y (log y)) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.45e-20) {
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 <= 2.45d-20) 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 <= 2.45e-20) {
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 <= 2.45e-20: 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 <= 2.45e-20) 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 <= 2.45e-20) tmp = exp((x - z)); else tmp = exp(((y * log(y)) - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.45e-20], 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 2.45 \cdot 10^{-20}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{y \cdot \log y - z}\\
\end{array}
\end{array}
if y < 2.4500000000000001e-20Initial program 100.0%
Taylor expanded in x around inf 100.0%
if 2.4500000000000001e-20 < y Initial program 100.0%
Taylor expanded in x around 0 91.6%
Final simplification95.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (exp (- z))))
(if (<= y 5e-260)
t_0
(if (<= y 2.1e-126)
(exp x)
(if (<= y 3.3e-88) t_0 (if (<= y 15000000.0) (exp x) (pow y y)))))))
double code(double x, double y, double z) {
double t_0 = exp(-z);
double tmp;
if (y <= 5e-260) {
tmp = t_0;
} else if (y <= 2.1e-126) {
tmp = exp(x);
} else if (y <= 3.3e-88) {
tmp = t_0;
} else if (y <= 15000000.0) {
tmp = exp(x);
} 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 <= 5d-260) then
tmp = t_0
else if (y <= 2.1d-126) then
tmp = exp(x)
else if (y <= 3.3d-88) then
tmp = t_0
else if (y <= 15000000.0d0) then
tmp = exp(x)
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 <= 5e-260) {
tmp = t_0;
} else if (y <= 2.1e-126) {
tmp = Math.exp(x);
} else if (y <= 3.3e-88) {
tmp = t_0;
} else if (y <= 15000000.0) {
tmp = Math.exp(x);
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): t_0 = math.exp(-z) tmp = 0 if y <= 5e-260: tmp = t_0 elif y <= 2.1e-126: tmp = math.exp(x) elif y <= 3.3e-88: tmp = t_0 elif y <= 15000000.0: tmp = math.exp(x) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) t_0 = exp(Float64(-z)) tmp = 0.0 if (y <= 5e-260) tmp = t_0; elseif (y <= 2.1e-126) tmp = exp(x); elseif (y <= 3.3e-88) tmp = t_0; elseif (y <= 15000000.0) tmp = exp(x); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) t_0 = exp(-z); tmp = 0.0; if (y <= 5e-260) tmp = t_0; elseif (y <= 2.1e-126) tmp = exp(x); elseif (y <= 3.3e-88) tmp = t_0; elseif (y <= 15000000.0) tmp = exp(x); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Exp[(-z)], $MachinePrecision]}, If[LessEqual[y, 5e-260], t$95$0, If[LessEqual[y, 2.1e-126], N[Exp[x], $MachinePrecision], If[LessEqual[y, 3.3e-88], t$95$0, If[LessEqual[y, 15000000.0], N[Exp[x], $MachinePrecision], N[Power[y, y], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-z}\\
\mathbf{if}\;y \leq 5 \cdot 10^{-260}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{-126}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{-88}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 15000000:\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 5.0000000000000003e-260 or 2.0999999999999999e-126 < y < 3.29999999999999994e-88Initial program 100.0%
Taylor expanded in z around inf 87.0%
neg-mul-187.0%
Simplified87.0%
if 5.0000000000000003e-260 < y < 2.0999999999999999e-126 or 3.29999999999999994e-88 < y < 1.5e7Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum98.9%
*-commutative98.9%
exp-to-pow98.9%
Simplified98.9%
Taylor expanded in z around 0 78.9%
*-commutative78.9%
Simplified78.9%
Taylor expanded in y around 0 79.2%
if 1.5e7 < y Initial program 100.0%
Taylor expanded in x around 0 91.7%
Taylor expanded in z around 0 86.5%
Final simplification83.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -9.2e+70) (not (<= x 420.0))) (exp x) (exp (- z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.2e+70) || !(x <= 420.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 <= (-9.2d+70)) .or. (.not. (x <= 420.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 <= -9.2e+70) || !(x <= 420.0)) {
tmp = Math.exp(x);
} else {
tmp = Math.exp(-z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.2e+70) or not (x <= 420.0): tmp = math.exp(x) else: tmp = math.exp(-z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.2e+70) || !(x <= 420.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 <= -9.2e+70) || ~((x <= 420.0))) tmp = exp(x); else tmp = exp(-z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.2e+70], N[Not[LessEqual[x, 420.0]], $MachinePrecision]], N[Exp[x], $MachinePrecision], N[Exp[(-z)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{+70} \lor \neg \left(x \leq 420\right):\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;e^{-z}\\
\end{array}
\end{array}
if x < -9.19999999999999975e70 or 420 < x Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum81.0%
*-commutative81.0%
exp-to-pow81.0%
Simplified81.0%
Taylor expanded in z around 0 75.5%
*-commutative75.5%
Simplified75.5%
Taylor expanded in y around 0 83.6%
if -9.19999999999999975e70 < x < 420Initial program 100.0%
Taylor expanded in z around inf 61.3%
neg-mul-161.3%
Simplified61.3%
Final simplification72.3%
(FPCore (x y z) :precision binary64 (if (<= y 3.45e+55) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.45e+55) {
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.45d+55) 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.45e+55) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.45e+55: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.45e+55) 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.45e+55) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.45e+55], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.45 \cdot 10^{+55}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 3.4500000000000002e55Initial program 100.0%
Taylor expanded in x around inf 95.3%
if 3.4500000000000002e55 < y Initial program 100.0%
Taylor expanded in x around 0 94.6%
Taylor expanded in z around 0 90.1%
Final simplification93.1%
(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.6%
*-commutative81.6%
exp-to-pow81.6%
Simplified81.6%
Taylor expanded in z around 0 69.7%
*-commutative69.7%
Simplified69.7%
Taylor expanded in y around 0 52.4%
Final simplification52.4%
(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 2024095
(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)))