
(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 9 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 (+ x (* y (log y)))))
(if (<= t_0 50.0)
(exp (- x z))
(if (or (<= t_0 5e+214) (not (<= t_0 5e+262)))
(* (pow y y) (exp x))
(pow y y)))))
double code(double x, double y, double z) {
double t_0 = x + (y * log(y));
double tmp;
if (t_0 <= 50.0) {
tmp = exp((x - z));
} else if ((t_0 <= 5e+214) || !(t_0 <= 5e+262)) {
tmp = pow(y, y) * 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 = x + (y * log(y))
if (t_0 <= 50.0d0) then
tmp = exp((x - z))
else if ((t_0 <= 5d+214) .or. (.not. (t_0 <= 5d+262))) then
tmp = (y ** y) * 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 = x + (y * Math.log(y));
double tmp;
if (t_0 <= 50.0) {
tmp = Math.exp((x - z));
} else if ((t_0 <= 5e+214) || !(t_0 <= 5e+262)) {
tmp = Math.pow(y, y) * Math.exp(x);
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): t_0 = x + (y * math.log(y)) tmp = 0 if t_0 <= 50.0: tmp = math.exp((x - z)) elif (t_0 <= 5e+214) or not (t_0 <= 5e+262): tmp = math.pow(y, y) * math.exp(x) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) t_0 = Float64(x + Float64(y * log(y))) tmp = 0.0 if (t_0 <= 50.0) tmp = exp(Float64(x - z)); elseif ((t_0 <= 5e+214) || !(t_0 <= 5e+262)) tmp = Float64((y ^ y) * exp(x)); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + (y * log(y)); tmp = 0.0; if (t_0 <= 50.0) tmp = exp((x - z)); elseif ((t_0 <= 5e+214) || ~((t_0 <= 5e+262))) tmp = (y ^ y) * exp(x); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 50.0], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[t$95$0, 5e+214], N[Not[LessEqual[t$95$0, 5e+262]], $MachinePrecision]], N[(N[Power[y, y], $MachinePrecision] * N[Exp[x], $MachinePrecision]), $MachinePrecision], N[Power[y, y], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + y \cdot \log y\\
\mathbf{if}\;t_0 \leq 50:\\
\;\;\;\;e^{x - z}\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+214} \lor \neg \left(t_0 \leq 5 \cdot 10^{+262}\right):\\
\;\;\;\;{y}^{y} \cdot e^{x}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if (+.f64 x (*.f64 y (log.f64 y))) < 50Initial program 100.0%
Taylor expanded in x around inf 99.2%
if 50 < (+.f64 x (*.f64 y (log.f64 y))) < 4.99999999999999953e214 or 5.00000000000000008e262 < (+.f64 x (*.f64 y (log.f64 y))) Initial program 100.0%
Taylor expanded in z around 0 93.0%
+-commutative93.0%
exp-sum86.0%
*-commutative86.0%
exp-to-pow86.0%
Simplified86.0%
if 4.99999999999999953e214 < (+.f64 x (*.f64 y (log.f64 y))) < 5.00000000000000008e262Initial program 100.0%
Taylor expanded in z around 0 88.2%
Taylor expanded in x around 0 88.2%
Final simplification92.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (log y))))
(if (or (<= t_0 50.0) (and (not (<= t_0 4e+21)) (<= t_0 1e+103)))
(exp (- x z))
(pow y y))))
double code(double x, double y, double z) {
double t_0 = y * log(y);
double tmp;
if ((t_0 <= 50.0) || (!(t_0 <= 4e+21) && (t_0 <= 1e+103))) {
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) :: t_0
real(8) :: tmp
t_0 = y * log(y)
if ((t_0 <= 50.0d0) .or. (.not. (t_0 <= 4d+21)) .and. (t_0 <= 1d+103)) 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 t_0 = y * Math.log(y);
double tmp;
if ((t_0 <= 50.0) || (!(t_0 <= 4e+21) && (t_0 <= 1e+103))) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): t_0 = y * math.log(y) tmp = 0 if (t_0 <= 50.0) or (not (t_0 <= 4e+21) and (t_0 <= 1e+103)): tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) t_0 = Float64(y * log(y)) tmp = 0.0 if ((t_0 <= 50.0) || (!(t_0 <= 4e+21) && (t_0 <= 1e+103))) tmp = exp(Float64(x - z)); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * log(y); tmp = 0.0; if ((t_0 <= 50.0) || (~((t_0 <= 4e+21)) && (t_0 <= 1e+103))) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, 50.0], And[N[Not[LessEqual[t$95$0, 4e+21]], $MachinePrecision], LessEqual[t$95$0, 1e+103]]], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \log y\\
\mathbf{if}\;t_0 \leq 50 \lor \neg \left(t_0 \leq 4 \cdot 10^{+21}\right) \land t_0 \leq 10^{+103}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 50 or 4e21 < (*.f64 y (log.f64 y)) < 1e103Initial program 100.0%
Taylor expanded in x around inf 92.4%
if 50 < (*.f64 y (log.f64 y)) < 4e21 or 1e103 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in z around 0 95.7%
Taylor expanded in x around 0 89.2%
Final simplification91.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* y (log y)))) (if (<= t_0 10000000000.0) (* (pow y y) (exp (- x z))) (exp (+ x t_0)))))
double code(double x, double y, double z) {
double t_0 = y * log(y);
double tmp;
if (t_0 <= 10000000000.0) {
tmp = pow(y, y) * exp((x - z));
} else {
tmp = exp((x + t_0));
}
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 <= 10000000000.0d0) then
tmp = (y ** y) * exp((x - z))
else
tmp = exp((x + t_0))
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 <= 10000000000.0) {
tmp = Math.pow(y, y) * Math.exp((x - z));
} else {
tmp = Math.exp((x + t_0));
}
return tmp;
}
def code(x, y, z): t_0 = y * math.log(y) tmp = 0 if t_0 <= 10000000000.0: tmp = math.pow(y, y) * math.exp((x - z)) else: tmp = math.exp((x + t_0)) return tmp
function code(x, y, z) t_0 = Float64(y * log(y)) tmp = 0.0 if (t_0 <= 10000000000.0) tmp = Float64((y ^ y) * exp(Float64(x - z))); else tmp = exp(Float64(x + t_0)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * log(y); tmp = 0.0; if (t_0 <= 10000000000.0) tmp = (y ^ y) * exp((x - z)); else tmp = exp((x + t_0)); 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, 10000000000.0], N[(N[Power[y, y], $MachinePrecision] * N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(x + t$95$0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \log y\\
\mathbf{if}\;t_0 \leq 10000000000:\\
\;\;\;\;{y}^{y} \cdot e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{x + t_0}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 1e10Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum100.0%
*-commutative100.0%
exp-to-pow100.0%
Simplified100.0%
if 1e10 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in z around 0 92.9%
Final simplification96.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* y (log y)))) (if (<= t_0 50.0) (exp (- x z)) (exp (+ x t_0)))))
double code(double x, double y, double z) {
double t_0 = y * log(y);
double tmp;
if (t_0 <= 50.0) {
tmp = exp((x - z));
} else {
tmp = exp((x + t_0));
}
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 <= 50.0d0) then
tmp = exp((x - z))
else
tmp = exp((x + t_0))
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 <= 50.0) {
tmp = Math.exp((x - z));
} else {
tmp = Math.exp((x + t_0));
}
return tmp;
}
def code(x, y, z): t_0 = y * math.log(y) tmp = 0 if t_0 <= 50.0: tmp = math.exp((x - z)) else: tmp = math.exp((x + t_0)) return tmp
function code(x, y, z) t_0 = Float64(y * log(y)) tmp = 0.0 if (t_0 <= 50.0) tmp = exp(Float64(x - z)); else tmp = exp(Float64(x + t_0)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * log(y); tmp = 0.0; if (t_0 <= 50.0) tmp = exp((x - z)); else tmp = exp((x + t_0)); 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, 50.0], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Exp[N[(x + t$95$0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \log y\\
\mathbf{if}\;t_0 \leq 50:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{x + t_0}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 50Initial program 100.0%
Taylor expanded in x around inf 99.3%
if 50 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in z around 0 92.3%
Final simplification95.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -160.0) (not (<= z 1.7e+14))) (exp (- z)) (exp x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -160.0) || !(z <= 1.7e+14)) {
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 <= (-160.0d0)) .or. (.not. (z <= 1.7d+14))) 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 <= -160.0) || !(z <= 1.7e+14)) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -160.0) or not (z <= 1.7e+14): tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -160.0) || !(z <= 1.7e+14)) tmp = exp(Float64(-z)); else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -160.0) || ~((z <= 1.7e+14))) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -160.0], N[Not[LessEqual[z, 1.7e+14]], $MachinePrecision]], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -160 \lor \neg \left(z \leq 1.7 \cdot 10^{+14}\right):\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if z < -160 or 1.7e14 < z Initial program 100.0%
Taylor expanded in z around inf 82.5%
neg-mul-182.5%
Simplified82.5%
if -160 < z < 1.7e14Initial program 100.0%
Taylor expanded in z around 0 99.8%
Taylor expanded in y around 0 66.1%
Final simplification73.7%
(FPCore (x y z) :precision binary64 (if (<= y 3.3e-178) (exp x) (if (<= y 14000.0) (exp (- z)) (pow y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.3e-178) {
tmp = exp(x);
} else if (y <= 14000.0) {
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 <= 3.3d-178) then
tmp = exp(x)
else if (y <= 14000.0d0) 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 <= 3.3e-178) {
tmp = Math.exp(x);
} else if (y <= 14000.0) {
tmp = Math.exp(-z);
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.3e-178: tmp = math.exp(x) elif y <= 14000.0: tmp = math.exp(-z) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.3e-178) tmp = exp(x); elseif (y <= 14000.0) tmp = exp(Float64(-z)); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.3e-178) tmp = exp(x); elseif (y <= 14000.0) tmp = exp(-z); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.3e-178], N[Exp[x], $MachinePrecision], If[LessEqual[y, 14000.0], N[Exp[(-z)], $MachinePrecision], N[Power[y, y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.3 \cdot 10^{-178}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;y \leq 14000:\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 3.3000000000000002e-178Initial program 100.0%
Taylor expanded in z around 0 76.2%
Taylor expanded in y around 0 76.2%
if 3.3000000000000002e-178 < y < 14000Initial program 99.9%
Taylor expanded in z around inf 76.4%
neg-mul-176.4%
Simplified76.4%
if 14000 < y Initial program 100.0%
Taylor expanded in z around 0 92.3%
Taylor expanded in x around 0 78.5%
Final simplification77.4%
(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%
Taylor expanded in z around 0 80.1%
Taylor expanded in y around 0 52.9%
Final simplification52.9%
(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%
Taylor expanded in z around 0 80.1%
Taylor expanded in x around 0 36.6%
distribute-lft1-in46.5%
*-commutative46.5%
Simplified46.5%
Taylor expanded in y around 0 14.5%
Final simplification14.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 2024024
(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)))