
(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 2e+17) (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 <= 2e+17) {
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 <= 2d+17) 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 <= 2e+17) {
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 <= 2e+17: 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 <= 2e+17) 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 <= 2e+17) 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, 2e+17], 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 2 \cdot 10^{+17}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - z}\\
\end{array}
\end{array}
if (*.f64 y (log.f64 y)) < 2e17Initial program 100.0%
Taylor expanded in y around 0 97.8%
if 2e17 < (*.f64 y (log.f64 y)) Initial program 100.0%
Taylor expanded in x around 0 91.8%
Final simplification95.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (exp (- z))))
(if (<= x -2.1e-19)
(exp x)
(if (<= x -1.65e-134)
t_0
(if (<= x 3.1e-240) (pow y y) (if (<= x 9e+28) t_0 (exp x)))))))
double code(double x, double y, double z) {
double t_0 = exp(-z);
double tmp;
if (x <= -2.1e-19) {
tmp = exp(x);
} else if (x <= -1.65e-134) {
tmp = t_0;
} else if (x <= 3.1e-240) {
tmp = pow(y, y);
} else if (x <= 9e+28) {
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.1d-19)) then
tmp = exp(x)
else if (x <= (-1.65d-134)) then
tmp = t_0
else if (x <= 3.1d-240) then
tmp = y ** y
else if (x <= 9d+28) 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.1e-19) {
tmp = Math.exp(x);
} else if (x <= -1.65e-134) {
tmp = t_0;
} else if (x <= 3.1e-240) {
tmp = Math.pow(y, y);
} else if (x <= 9e+28) {
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.1e-19: tmp = math.exp(x) elif x <= -1.65e-134: tmp = t_0 elif x <= 3.1e-240: tmp = math.pow(y, y) elif x <= 9e+28: 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.1e-19) tmp = exp(x); elseif (x <= -1.65e-134) tmp = t_0; elseif (x <= 3.1e-240) tmp = y ^ y; elseif (x <= 9e+28) 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.1e-19) tmp = exp(x); elseif (x <= -1.65e-134) tmp = t_0; elseif (x <= 3.1e-240) tmp = y ^ y; elseif (x <= 9e+28) 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.1e-19], N[Exp[x], $MachinePrecision], If[LessEqual[x, -1.65e-134], t$95$0, If[LessEqual[x, 3.1e-240], N[Power[y, y], $MachinePrecision], If[LessEqual[x, 9e+28], t$95$0, N[Exp[x], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-z}\\
\mathbf{if}\;x \leq -2.1 \cdot 10^{-19}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;x \leq -1.65 \cdot 10^{-134}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-240}:\\
\;\;\;\;{y}^{y}\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+28}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if x < -2.0999999999999999e-19 or 8.9999999999999994e28 < x Initial program 100.0%
Taylor expanded in z around 0 91.2%
log-pow81.6%
exp-sum72.4%
rem-exp-log72.4%
Simplified72.4%
Taylor expanded in y around 0 84.0%
if -2.0999999999999999e-19 < x < -1.6500000000000001e-134 or 3.10000000000000017e-240 < x < 8.9999999999999994e28Initial program 100.0%
Taylor expanded in x around 0 98.0%
log-pow84.8%
div-exp77.8%
rem-exp-log77.8%
Simplified77.8%
Taylor expanded in y around 0 77.3%
rec-exp77.3%
Simplified77.3%
if -1.6500000000000001e-134 < x < 3.10000000000000017e-240Initial program 100.0%
Taylor expanded in z around 0 71.3%
log-pow71.3%
exp-sum71.3%
rem-exp-log71.3%
Simplified71.3%
Taylor expanded in x around 0 71.3%
Final simplification79.5%
(FPCore (x y z) :precision binary64 (if (or (<= y 9.5e+47) (and (not (<= y 4.9e+70)) (<= y 1.05e+175))) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= 9.5e+47) || (!(y <= 4.9e+70) && (y <= 1.05e+175))) {
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 <= 9.5d+47) .or. (.not. (y <= 4.9d+70)) .and. (y <= 1.05d+175)) 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 <= 9.5e+47) || (!(y <= 4.9e+70) && (y <= 1.05e+175))) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= 9.5e+47) or (not (y <= 4.9e+70) and (y <= 1.05e+175)): tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= 9.5e+47) || (!(y <= 4.9e+70) && (y <= 1.05e+175))) 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 <= 9.5e+47) || (~((y <= 4.9e+70)) && (y <= 1.05e+175))) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, 9.5e+47], And[N[Not[LessEqual[y, 4.9e+70]], $MachinePrecision], LessEqual[y, 1.05e+175]]], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.5 \cdot 10^{+47} \lor \neg \left(y \leq 4.9 \cdot 10^{+70}\right) \land y \leq 1.05 \cdot 10^{+175}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 9.50000000000000001e47 or 4.90000000000000028e70 < y < 1.05e175Initial program 100.0%
Taylor expanded in y around 0 91.3%
if 9.50000000000000001e47 < y < 4.90000000000000028e70 or 1.05e175 < y Initial program 100.0%
Taylor expanded in z around 0 96.1%
log-pow94.2%
exp-sum82.4%
rem-exp-log82.4%
Simplified82.4%
Taylor expanded in x around 0 94.2%
Final simplification91.8%
(FPCore (x y z) :precision binary64 (if (<= x -2.1e-19) (exp x) (if (<= x 2.2e+29) (exp (- z)) (exp x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.1e-19) {
tmp = exp(x);
} else if (x <= 2.2e+29) {
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-19)) then
tmp = exp(x)
else if (x <= 2.2d+29) 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-19) {
tmp = Math.exp(x);
} else if (x <= 2.2e+29) {
tmp = Math.exp(-z);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.1e-19: tmp = math.exp(x) elif x <= 2.2e+29: tmp = math.exp(-z) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.1e-19) tmp = exp(x); elseif (x <= 2.2e+29) 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-19) tmp = exp(x); elseif (x <= 2.2e+29) tmp = exp(-z); else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.1e-19], N[Exp[x], $MachinePrecision], If[LessEqual[x, 2.2e+29], N[Exp[(-z)], $MachinePrecision], N[Exp[x], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-19}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+29}:\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if x < -2.0999999999999999e-19 or 2.2000000000000001e29 < x Initial program 100.0%
Taylor expanded in z around 0 91.2%
log-pow81.6%
exp-sum72.4%
rem-exp-log72.4%
Simplified72.4%
Taylor expanded in y around 0 84.0%
if -2.0999999999999999e-19 < x < 2.2000000000000001e29Initial program 100.0%
Taylor expanded in x around 0 98.7%
log-pow89.1%
div-exp79.9%
rem-exp-log79.9%
Simplified79.9%
Taylor expanded in y around 0 69.4%
rec-exp69.4%
Simplified69.4%
Final simplification76.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 75.2%
log-pow70.6%
exp-sum66.2%
rem-exp-log66.2%
Simplified66.2%
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 2023279
(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)))