
(FPCore (w l) :precision binary64 (* (exp (- w)) (pow l (exp w))))
double code(double w, double l) {
return exp(-w) * pow(l, exp(w));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = exp(-w) * (l ** exp(w))
end function
public static double code(double w, double l) {
return Math.exp(-w) * Math.pow(l, Math.exp(w));
}
def code(w, l): return math.exp(-w) * math.pow(l, math.exp(w))
function code(w, l) return Float64(exp(Float64(-w)) * (l ^ exp(w))) end
function tmp = code(w, l) tmp = exp(-w) * (l ^ exp(w)); end
code[w_, l_] := N[(N[Exp[(-w)], $MachinePrecision] * N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{-w} \cdot {\ell}^{\left(e^{w}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (w l) :precision binary64 (* (exp (- w)) (pow l (exp w))))
double code(double w, double l) {
return exp(-w) * pow(l, exp(w));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = exp(-w) * (l ** exp(w))
end function
public static double code(double w, double l) {
return Math.exp(-w) * Math.pow(l, Math.exp(w));
}
def code(w, l): return math.exp(-w) * math.pow(l, math.exp(w))
function code(w, l) return Float64(exp(Float64(-w)) * (l ^ exp(w))) end
function tmp = code(w, l) tmp = exp(-w) * (l ^ exp(w)); end
code[w_, l_] := N[(N[Exp[(-w)], $MachinePrecision] * N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{-w} \cdot {\ell}^{\left(e^{w}\right)}
\end{array}
(FPCore (w l) :precision binary64 (/ (pow l (exp w)) (exp w)))
double code(double w, double l) {
return pow(l, exp(w)) / exp(w);
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = (l ** exp(w)) / exp(w)
end function
public static double code(double w, double l) {
return Math.pow(l, Math.exp(w)) / Math.exp(w);
}
def code(w, l): return math.pow(l, math.exp(w)) / math.exp(w)
function code(w, l) return Float64((l ^ exp(w)) / exp(w)) end
function tmp = code(w, l) tmp = (l ^ exp(w)) / exp(w); end
code[w_, l_] := N[(N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision] / N[Exp[w], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\ell}^{\left(e^{w}\right)}}{e^{w}}
\end{array}
Initial program 99.7%
Applied rewrites99.7%
lift-*.f64N/A
*-commutativeN/A
lift-exp.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
metadata-evalN/A
neg-mul-1N/A
exp-negN/A
lift-exp.f64N/A
un-div-invN/A
lower-/.f6499.7
Applied rewrites99.7%
(FPCore (w l) :precision binary64 (let* ((t_0 (pow l (exp w))) (t_1 (exp (- w)))) (if (<= (* t_0 t_1) 5e+306) (/ t_0 (fma w (fma w 0.5 1.0) 1.0)) t_1)))
double code(double w, double l) {
double t_0 = pow(l, exp(w));
double t_1 = exp(-w);
double tmp;
if ((t_0 * t_1) <= 5e+306) {
tmp = t_0 / fma(w, fma(w, 0.5, 1.0), 1.0);
} else {
tmp = t_1;
}
return tmp;
}
function code(w, l) t_0 = l ^ exp(w) t_1 = exp(Float64(-w)) tmp = 0.0 if (Float64(t_0 * t_1) <= 5e+306) tmp = Float64(t_0 / fma(w, fma(w, 0.5, 1.0), 1.0)); else tmp = t_1; end return tmp end
code[w_, l_] := Block[{t$95$0 = N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-w)], $MachinePrecision]}, If[LessEqual[N[(t$95$0 * t$95$1), $MachinePrecision], 5e+306], N[(t$95$0 / N[(w * N[(w * 0.5 + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\ell}^{\left(e^{w}\right)}\\
t_1 := e^{-w}\\
\mathbf{if}\;t\_0 \cdot t\_1 \leq 5 \cdot 10^{+306}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(w, \mathsf{fma}\left(w, 0.5, 1\right), 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (exp.f64 (neg.f64 w)) (pow.f64 l (exp.f64 w))) < 4.99999999999999993e306Initial program 99.6%
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift-exp.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
metadata-evalN/A
neg-mul-1N/A
exp-negN/A
lift-exp.f64N/A
un-div-invN/A
lower-/.f6499.6
Applied rewrites99.6%
Taylor expanded in w around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6498.8
Applied rewrites98.8%
if 4.99999999999999993e306 < (*.f64 (exp.f64 (neg.f64 w)) (pow.f64 l (exp.f64 w))) Initial program 99.0%
lift-pow.f64N/A
sqr-powN/A
pow-prod-upN/A
flip-+N/A
+-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
+-inversesN/A
metadata-evalN/A
flip--N/A
metadata-evalN/A
metadata-eval98.2
Applied rewrites98.2%
lift-*.f64N/A
*-rgt-identity98.2
Applied rewrites98.2%
Final simplification98.7%
herbie shell --seed 2024219
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))