
(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 5 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 (* (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}
Initial program 99.5%
(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.5%
exp-neg99.5%
remove-double-neg99.5%
associate-*l/99.5%
*-lft-identity99.5%
remove-double-neg99.5%
Simplified99.5%
(FPCore (w l) :precision binary64 (if (or (<= w -120000000.0) (not (<= w 0.105))) (* 0.03333333333333333 (pow l 5.0)) l))
double code(double w, double l) {
double tmp;
if ((w <= -120000000.0) || !(w <= 0.105)) {
tmp = 0.03333333333333333 * pow(l, 5.0);
} else {
tmp = l;
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if ((w <= (-120000000.0d0)) .or. (.not. (w <= 0.105d0))) then
tmp = 0.03333333333333333d0 * (l ** 5.0d0)
else
tmp = l
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if ((w <= -120000000.0) || !(w <= 0.105)) {
tmp = 0.03333333333333333 * Math.pow(l, 5.0);
} else {
tmp = l;
}
return tmp;
}
def code(w, l): tmp = 0 if (w <= -120000000.0) or not (w <= 0.105): tmp = 0.03333333333333333 * math.pow(l, 5.0) else: tmp = l return tmp
function code(w, l) tmp = 0.0 if ((w <= -120000000.0) || !(w <= 0.105)) tmp = Float64(0.03333333333333333 * (l ^ 5.0)); else tmp = l; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if ((w <= -120000000.0) || ~((w <= 0.105))) tmp = 0.03333333333333333 * (l ^ 5.0); else tmp = l; end tmp_2 = tmp; end
code[w_, l_] := If[Or[LessEqual[w, -120000000.0], N[Not[LessEqual[w, 0.105]], $MachinePrecision]], N[(0.03333333333333333 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision], l]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -120000000 \lor \neg \left(w \leq 0.105\right):\\
\;\;\;\;0.03333333333333333 \cdot {\ell}^{5}\\
\mathbf{else}:\\
\;\;\;\;\ell\\
\end{array}
\end{array}
if w < -1.2e8 or 0.104999999999999996 < w Initial program 99.1%
add-sqr-sqrt99.1%
sqrt-unprod99.1%
add-sqr-sqrt62.4%
sqrt-unprod64.1%
sqr-neg64.1%
sqrt-unprod1.7%
add-sqr-sqrt1.7%
pow11.7%
exp-neg1.7%
inv-pow1.7%
pow-prod-up39.6%
metadata-eval39.6%
metadata-eval39.6%
metadata-eval39.6%
*-un-lft-identity39.6%
add-sqr-sqrt37.6%
sqrt-unprod66.3%
sqr-neg66.3%
sqrt-unprod28.7%
add-sqr-sqrt29.9%
Applied egg-rr31.9%
Taylor expanded in l around 0 20.3%
*-commutative20.3%
Simplified20.3%
Taylor expanded in l around 0 23.1%
Taylor expanded in l around inf 50.5%
if -1.2e8 < w < 0.104999999999999996Initial program 99.8%
Taylor expanded in w around 0 97.8%
Final simplification76.2%
(FPCore (w l) :precision binary64 (/ l (exp w)))
double code(double w, double l) {
return l / exp(w);
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l / exp(w)
end function
public static double code(double w, double l) {
return l / Math.exp(w);
}
def code(w, l): return l / math.exp(w)
function code(w, l) return Float64(l / exp(w)) end
function tmp = code(w, l) tmp = l / exp(w); end
code[w_, l_] := N[(l / N[Exp[w], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\ell}{e^{w}}
\end{array}
Initial program 99.5%
exp-neg99.5%
remove-double-neg99.5%
associate-*l/99.5%
*-lft-identity99.5%
remove-double-neg99.5%
Simplified99.5%
add-sqr-sqrt48.0%
sqrt-unprod83.0%
sqr-neg83.0%
sqrt-unprod35.0%
add-sqr-sqrt82.0%
add-sqr-sqrt82.0%
sqrt-unprod82.0%
add-sqr-sqrt35.0%
sqrt-unprod66.0%
sqr-neg66.0%
sqrt-unprod31.0%
add-sqr-sqrt53.1%
pow153.1%
exp-neg53.1%
inv-pow53.1%
pow-prod-up98.4%
metadata-eval98.4%
metadata-eval98.4%
metadata-eval98.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (w l) :precision binary64 l)
double code(double w, double l) {
return l;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l
end function
public static double code(double w, double l) {
return l;
}
def code(w, l): return l
function code(w, l) return l end
function tmp = code(w, l) tmp = l; end
code[w_, l_] := l
\begin{array}{l}
\\
\ell
\end{array}
Initial program 99.5%
Taylor expanded in w around 0 55.1%
herbie shell --seed 2024107
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))