
(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 4e+14) (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 <= 4e+14) {
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 <= 4d+14) 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 <= 4e+14) {
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 <= 4e+14: 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 <= 4e+14) 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 <= 4e+14) 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, 4e+14], 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 4 \cdot 10^{+14}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - z}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 4e14Initial program 100.0%
Taylor expanded in x around inf 98.2%
if 4e14 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in x around 0 93.0%
Final simplification95.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (exp (- z))))
(if (<= x -2.85e+51)
(exp x)
(if (<= x -3.4e-82)
(pow y y)
(if (<= x -1.95e-281)
t_0
(if (<= x 1.82e-65) (pow y y) (if (<= x 780000.0) t_0 (exp x))))))))
double code(double x, double y, double z) {
double t_0 = exp(-z);
double tmp;
if (x <= -2.85e+51) {
tmp = exp(x);
} else if (x <= -3.4e-82) {
tmp = pow(y, y);
} else if (x <= -1.95e-281) {
tmp = t_0;
} else if (x <= 1.82e-65) {
tmp = pow(y, y);
} else if (x <= 780000.0) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = exp(-z)
if (x <= (-2.85d+51)) then
tmp = exp(x)
else if (x <= (-3.4d-82)) then
tmp = y ** y
else if (x <= (-1.95d-281)) then
tmp = t_0
else if (x <= 1.82d-65) then
tmp = y ** y
else if (x <= 780000.0d0) then
tmp = t_0
else
tmp = exp(x)
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 (x <= -2.85e+51) {
tmp = Math.exp(x);
} else if (x <= -3.4e-82) {
tmp = Math.pow(y, y);
} else if (x <= -1.95e-281) {
tmp = t_0;
} else if (x <= 1.82e-65) {
tmp = Math.pow(y, y);
} else if (x <= 780000.0) {
tmp = t_0;
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): t_0 = math.exp(-z) tmp = 0 if x <= -2.85e+51: tmp = math.exp(x) elif x <= -3.4e-82: tmp = math.pow(y, y) elif x <= -1.95e-281: tmp = t_0 elif x <= 1.82e-65: tmp = math.pow(y, y) elif x <= 780000.0: tmp = t_0 else: tmp = math.exp(x) return tmp
function code(x, y, z) t_0 = exp(Float64(-z)) tmp = 0.0 if (x <= -2.85e+51) tmp = exp(x); elseif (x <= -3.4e-82) tmp = y ^ y; elseif (x <= -1.95e-281) tmp = t_0; elseif (x <= 1.82e-65) tmp = y ^ y; elseif (x <= 780000.0) tmp = t_0; else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = exp(-z); tmp = 0.0; if (x <= -2.85e+51) tmp = exp(x); elseif (x <= -3.4e-82) tmp = y ^ y; elseif (x <= -1.95e-281) tmp = t_0; elseif (x <= 1.82e-65) tmp = y ^ y; elseif (x <= 780000.0) tmp = t_0; else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Exp[(-z)], $MachinePrecision]}, If[LessEqual[x, -2.85e+51], N[Exp[x], $MachinePrecision], If[LessEqual[x, -3.4e-82], N[Power[y, y], $MachinePrecision], If[LessEqual[x, -1.95e-281], t$95$0, If[LessEqual[x, 1.82e-65], N[Power[y, y], $MachinePrecision], If[LessEqual[x, 780000.0], t$95$0, N[Exp[x], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-z}\\
\mathbf{if}\;x \leq -2.85 \cdot 10^{+51}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;x \leq -3.4 \cdot 10^{-82}:\\
\;\;\;\;{y}^{y}\\
\mathbf{elif}\;x \leq -1.95 \cdot 10^{-281}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.82 \cdot 10^{-65}:\\
\;\;\;\;{y}^{y}\\
\mathbf{elif}\;x \leq 780000:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if x < -2.8500000000000001e51 or 7.8e5 < x 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 67.3%
*-commutative67.3%
Simplified67.3%
Taylor expanded in y around 0 85.6%
if -2.8500000000000001e51 < x < -3.39999999999999975e-82 or -1.9500000000000001e-281 < x < 1.82e-65Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum86.6%
*-commutative86.6%
exp-to-pow86.6%
Simplified86.6%
Taylor expanded in z around 0 74.9%
*-commutative74.9%
Simplified74.9%
Taylor expanded in x around 0 75.7%
if -3.39999999999999975e-82 < x < -1.9500000000000001e-281 or 1.82e-65 < x < 7.8e5Initial program 100.0%
Taylor expanded in z around inf 77.3%
neg-mul-177.3%
Simplified77.3%
Final simplification80.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.15e+61) (not (<= x 780000.0))) (exp x) (exp (- z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.15e+61) || !(x <= 780000.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 <= (-1.15d+61)) .or. (.not. (x <= 780000.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 <= -1.15e+61) || !(x <= 780000.0)) {
tmp = Math.exp(x);
} else {
tmp = Math.exp(-z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.15e+61) or not (x <= 780000.0): tmp = math.exp(x) else: tmp = math.exp(-z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.15e+61) || !(x <= 780000.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 <= -1.15e+61) || ~((x <= 780000.0))) tmp = exp(x); else tmp = exp(-z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.15e+61], N[Not[LessEqual[x, 780000.0]], $MachinePrecision]], N[Exp[x], $MachinePrecision], N[Exp[(-z)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{+61} \lor \neg \left(x \leq 780000\right):\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;e^{-z}\\
\end{array}
\end{array}
if x < -1.15e61 or 7.8e5 < x Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum71.4%
*-commutative71.4%
exp-to-pow71.4%
Simplified71.4%
Taylor expanded in z around 0 68.0%
*-commutative68.0%
Simplified68.0%
Taylor expanded in y around 0 86.8%
if -1.15e61 < x < 7.8e5Initial program 100.0%
Taylor expanded in z around inf 65.3%
neg-mul-165.3%
Simplified65.3%
Final simplification74.7%
(FPCore (x y z) :precision binary64 (if (<= y 1.65e+191) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.65e+191) {
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.65d+191) 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.65e+191) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.65e+191: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.65e+191) 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.65e+191) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.65e+191], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.65 \cdot 10^{+191}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 1.6499999999999999e191Initial program 100.0%
Taylor expanded in x around inf 87.9%
if 1.6499999999999999e191 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum67.3%
*-commutative67.3%
exp-to-pow67.3%
Simplified67.3%
Taylor expanded in z around 0 80.8%
*-commutative80.8%
Simplified80.8%
Taylor expanded in x around 0 94.3%
Final simplification89.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-sum78.5%
*-commutative78.5%
exp-to-pow78.5%
Simplified78.5%
Taylor expanded in z around 0 66.1%
*-commutative66.1%
Simplified66.1%
Taylor expanded in y around 0 53.2%
Final simplification53.2%
(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 2023336
(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)))