
(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 6 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 (* (* (cbrt (/ 1.0 (pow (exp w) 2.0))) (pow l (exp w))) (cbrt (exp (- w)))))
double code(double w, double l) {
return (cbrt((1.0 / pow(exp(w), 2.0))) * pow(l, exp(w))) * cbrt(exp(-w));
}
public static double code(double w, double l) {
return (Math.cbrt((1.0 / Math.pow(Math.exp(w), 2.0))) * Math.pow(l, Math.exp(w))) * Math.cbrt(Math.exp(-w));
}
function code(w, l) return Float64(Float64(cbrt(Float64(1.0 / (exp(w) ^ 2.0))) * (l ^ exp(w))) * cbrt(exp(Float64(-w)))) end
code[w_, l_] := N[(N[(N[Power[N[(1.0 / N[Power[N[Exp[w], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[N[Exp[(-w)], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sqrt[3]{\frac{1}{{\left(e^{w}\right)}^{2}}} \cdot {\ell}^{\left(e^{w}\right)}\right) \cdot \sqrt[3]{e^{-w}}
\end{array}
Initial program 99.5%
exp-neg99.5%
associate-*l/99.5%
*-lft-identity99.5%
Simplified99.5%
add-cbrt-cube63.9%
pow1/362.6%
div-inv62.6%
associate-*r*62.6%
unpow-prod-down62.6%
pow262.6%
pow1/362.6%
rec-exp62.6%
Applied egg-rr62.6%
unpow1/363.9%
*-commutative63.9%
Simplified63.9%
Taylor expanded in l around 0 99.5%
unpow1/399.5%
Simplified99.5%
Final simplification99.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%
associate-*l/99.5%
*-lft-identity99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (w l) :precision binary64 (* l (exp (* (- w) 0.3333333333333333))))
double code(double w, double l) {
return l * exp((-w * 0.3333333333333333));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l * exp((-w * 0.3333333333333333d0))
end function
public static double code(double w, double l) {
return l * Math.exp((-w * 0.3333333333333333));
}
def code(w, l): return l * math.exp((-w * 0.3333333333333333))
function code(w, l) return Float64(l * exp(Float64(Float64(-w) * 0.3333333333333333))) end
function tmp = code(w, l) tmp = l * exp((-w * 0.3333333333333333)); end
code[w_, l_] := N[(l * N[Exp[N[((-w) * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell \cdot e^{\left(-w\right) \cdot 0.3333333333333333}
\end{array}
Initial program 99.5%
exp-neg99.5%
associate-*l/99.5%
*-lft-identity99.5%
Simplified99.5%
add-cbrt-cube63.9%
pow1/362.6%
div-inv62.6%
associate-*r*62.6%
unpow-prod-down62.6%
pow262.6%
pow1/362.6%
rec-exp62.6%
Applied egg-rr62.6%
unpow1/363.9%
*-commutative63.9%
Simplified63.9%
Taylor expanded in l around 0 99.5%
unpow1/399.5%
Simplified99.5%
Taylor expanded in w around 0 99.3%
exp-neg99.3%
cbrt-div99.3%
metadata-eval99.3%
Applied egg-rr99.3%
unpow1/399.3%
exp-prod99.3%
*-commutative99.3%
rec-exp99.3%
*-commutative99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (w l) :precision binary64 (* l (+ 1.0 (* w -0.3333333333333333))))
double code(double w, double l) {
return l * (1.0 + (w * -0.3333333333333333));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l * (1.0d0 + (w * (-0.3333333333333333d0)))
end function
public static double code(double w, double l) {
return l * (1.0 + (w * -0.3333333333333333));
}
def code(w, l): return l * (1.0 + (w * -0.3333333333333333))
function code(w, l) return Float64(l * Float64(1.0 + Float64(w * -0.3333333333333333))) end
function tmp = code(w, l) tmp = l * (1.0 + (w * -0.3333333333333333)); end
code[w_, l_] := N[(l * N[(1.0 + N[(w * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell \cdot \left(1 + w \cdot -0.3333333333333333\right)
\end{array}
Initial program 99.5%
exp-neg99.5%
associate-*l/99.5%
*-lft-identity99.5%
Simplified99.5%
add-cbrt-cube63.9%
pow1/362.6%
div-inv62.6%
associate-*r*62.6%
unpow-prod-down62.6%
pow262.6%
pow1/362.6%
rec-exp62.6%
Applied egg-rr62.6%
unpow1/363.9%
*-commutative63.9%
Simplified63.9%
Taylor expanded in l around 0 99.5%
unpow1/399.5%
Simplified99.5%
Taylor expanded in w around 0 99.3%
Taylor expanded in w around 0 65.4%
*-commutative65.4%
Simplified65.4%
Final simplification65.4%
(FPCore (w l) :precision binary64 (if (<= w -10.0) (* w (- l)) l))
double code(double w, double l) {
double tmp;
if (w <= -10.0) {
tmp = w * -l;
} 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 <= (-10.0d0)) then
tmp = w * -l
else
tmp = l
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -10.0) {
tmp = w * -l;
} else {
tmp = l;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -10.0: tmp = w * -l else: tmp = l return tmp
function code(w, l) tmp = 0.0 if (w <= -10.0) tmp = Float64(w * Float64(-l)); else tmp = l; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -10.0) tmp = w * -l; else tmp = l; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -10.0], N[(w * (-l)), $MachinePrecision], l]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -10:\\
\;\;\;\;w \cdot \left(-\ell\right)\\
\mathbf{else}:\\
\;\;\;\;\ell\\
\end{array}
\end{array}
if w < -10Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in w around 0 1.7%
Taylor expanded in w around inf 1.7%
add-log-exp1.6%
*-commutative1.6%
exp-to-pow1.6%
Applied egg-rr1.6%
Taylor expanded in l around inf 30.9%
neg-mul-130.9%
Simplified30.9%
if -10 < w Initial program 99.4%
exp-neg99.4%
associate-*l/99.4%
*-lft-identity99.4%
Simplified99.4%
Taylor expanded in w around 0 78.5%
Final simplification65.8%
(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%
exp-neg99.5%
associate-*l/99.5%
*-lft-identity99.5%
Simplified99.5%
Taylor expanded in w around 0 58.6%
Final simplification58.6%
herbie shell --seed 2023339
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))