
(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 11 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
(let* ((t_0 (cbrt (/ 1.0 (- (exp w))))))
(*
(- (pow l (exp w)))
(* (pow (cbrt (exp (- w))) 2.0) (cbrt (* t_0 (* t_0 t_0)))))))
double code(double w, double l) {
double t_0 = cbrt((1.0 / -exp(w)));
return -pow(l, exp(w)) * (pow(cbrt(exp(-w)), 2.0) * cbrt((t_0 * (t_0 * t_0))));
}
public static double code(double w, double l) {
double t_0 = Math.cbrt((1.0 / -Math.exp(w)));
return -Math.pow(l, Math.exp(w)) * (Math.pow(Math.cbrt(Math.exp(-w)), 2.0) * Math.cbrt((t_0 * (t_0 * t_0))));
}
function code(w, l) t_0 = cbrt(Float64(1.0 / Float64(-exp(w)))) return Float64(Float64(-(l ^ exp(w))) * Float64((cbrt(exp(Float64(-w))) ^ 2.0) * cbrt(Float64(t_0 * Float64(t_0 * t_0))))) end
code[w_, l_] := Block[{t$95$0 = N[Power[N[(1.0 / (-N[Exp[w], $MachinePrecision])), $MachinePrecision], 1/3], $MachinePrecision]}, N[((-N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]) * N[(N[Power[N[Power[N[Exp[(-w)], $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[N[(t$95$0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{1}{-e^{w}}}\\
\left(-{\ell}^{\left(e^{w}\right)}\right) \cdot \left({\left(\sqrt[3]{e^{-w}}\right)}^{2} \cdot \sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}\right)
\end{array}
\end{array}
Initial program 99.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
frac-2neg99.7%
div-inv99.7%
Applied egg-rr99.7%
add-cube-cbrt99.7%
Applied egg-rr99.7%
pow299.7%
add-sqr-sqrt29.3%
sqrt-unprod99.7%
sqr-neg99.7%
sqrt-unprod99.7%
add-sqr-sqrt99.7%
rec-exp99.7%
Applied egg-rr99.7%
add-cube-cbrt99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (w l) :precision binary64 (* (- (pow l (exp w))) (* (pow (cbrt (exp (- w))) 2.0) (cbrt (/ -1.0 (exp w))))))
double code(double w, double l) {
return -pow(l, exp(w)) * (pow(cbrt(exp(-w)), 2.0) * cbrt((-1.0 / exp(w))));
}
public static double code(double w, double l) {
return -Math.pow(l, Math.exp(w)) * (Math.pow(Math.cbrt(Math.exp(-w)), 2.0) * Math.cbrt((-1.0 / Math.exp(w))));
}
function code(w, l) return Float64(Float64(-(l ^ exp(w))) * Float64((cbrt(exp(Float64(-w))) ^ 2.0) * cbrt(Float64(-1.0 / exp(w))))) end
code[w_, l_] := N[((-N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]) * N[(N[Power[N[Power[N[Exp[(-w)], $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[N[(-1.0 / N[Exp[w], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-{\ell}^{\left(e^{w}\right)}\right) \cdot \left({\left(\sqrt[3]{e^{-w}}\right)}^{2} \cdot \sqrt[3]{\frac{-1}{e^{w}}}\right)
\end{array}
Initial program 99.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
frac-2neg99.7%
div-inv99.7%
Applied egg-rr99.7%
add-cube-cbrt99.7%
Applied egg-rr99.7%
pow299.7%
add-sqr-sqrt29.3%
sqrt-unprod99.7%
sqr-neg99.7%
sqrt-unprod99.7%
add-sqr-sqrt99.7%
rec-exp99.7%
Applied egg-rr99.7%
Taylor expanded in w around inf 99.7%
Final simplification99.7%
(FPCore (w l) :precision binary64 (* (- (pow l (exp w))) (* (cbrt (/ 1.0 (- (exp w)))) (pow (exp (- w)) 0.6666666666666666))))
double code(double w, double l) {
return -pow(l, exp(w)) * (cbrt((1.0 / -exp(w))) * pow(exp(-w), 0.6666666666666666));
}
public static double code(double w, double l) {
return -Math.pow(l, Math.exp(w)) * (Math.cbrt((1.0 / -Math.exp(w))) * Math.pow(Math.exp(-w), 0.6666666666666666));
}
function code(w, l) return Float64(Float64(-(l ^ exp(w))) * Float64(cbrt(Float64(1.0 / Float64(-exp(w)))) * (exp(Float64(-w)) ^ 0.6666666666666666))) end
code[w_, l_] := N[((-N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]) * N[(N[Power[N[(1.0 / (-N[Exp[w], $MachinePrecision])), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[Exp[(-w)], $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-{\ell}^{\left(e^{w}\right)}\right) \cdot \left(\sqrt[3]{\frac{1}{-e^{w}}} \cdot {\left(e^{-w}\right)}^{0.6666666666666666}\right)
\end{array}
Initial program 99.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
frac-2neg99.7%
div-inv99.7%
Applied egg-rr99.7%
add-cube-cbrt99.7%
Applied egg-rr99.7%
pow1/315.2%
pow1/344.5%
pow-prod-up44.5%
add-sqr-sqrt29.3%
sqrt-unprod99.7%
sqr-neg99.7%
sqrt-unprod99.7%
add-sqr-sqrt99.7%
rec-exp99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Final simplification99.7%
(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(Float64(-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}
\\
{\ell}^{\left(e^{w}\right)} \cdot e^{-w}
\end{array}
Initial program 99.7%
Final simplification99.7%
(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%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
Final simplification99.7%
(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(Float64(-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}
\\
\ell \cdot e^{-w}
\end{array}
Initial program 99.7%
Taylor expanded in w around 0 98.1%
Final simplification98.1%
(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.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
Taylor expanded in w around 0 98.1%
Final simplification98.1%
(FPCore (w l) :precision binary64 (if (<= w -0.56) (* l (- w)) l))
double code(double w, double l) {
double tmp;
if (w <= -0.56) {
tmp = l * -w;
} 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 <= (-0.56d0)) then
tmp = l * -w
else
tmp = l
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -0.56) {
tmp = l * -w;
} else {
tmp = l;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.56: tmp = l * -w else: tmp = l return tmp
function code(w, l) tmp = 0.0 if (w <= -0.56) tmp = Float64(l * Float64(-w)); else tmp = l; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.56) tmp = l * -w; else tmp = l; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.56], N[(l * (-w)), $MachinePrecision], l]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.56:\\
\;\;\;\;\ell \cdot \left(-w\right)\\
\mathbf{else}:\\
\;\;\;\;\ell\\
\end{array}
\end{array}
if w < -0.56000000000000005Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
frac-2neg100.0%
div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in w around 0 5.5%
Taylor expanded in w around 0 29.1%
Taylor expanded in w around inf 29.1%
associate-*r*29.1%
mul-1-neg29.1%
Simplified29.1%
if -0.56000000000000005 < w Initial program 99.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
frac-2neg99.6%
div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in w around 0 76.8%
Final simplification62.8%
(FPCore (w l) :precision binary64 (* (- l) (+ w -1.0)))
double code(double w, double l) {
return -l * (w + -1.0);
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = -l * (w + (-1.0d0))
end function
public static double code(double w, double l) {
return -l * (w + -1.0);
}
def code(w, l): return -l * (w + -1.0)
function code(w, l) return Float64(Float64(-l) * Float64(w + -1.0)) end
function tmp = code(w, l) tmp = -l * (w + -1.0); end
code[w_, l_] := N[((-l) * N[(w + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-\ell\right) \cdot \left(w + -1\right)
\end{array}
Initial program 99.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
frac-2neg99.7%
div-inv99.7%
Applied egg-rr99.7%
Taylor expanded in w around 0 71.4%
Taylor expanded in w around 0 62.6%
Final simplification62.6%
(FPCore (w l) :precision binary64 (- l (* l w)))
double code(double w, double l) {
return l - (l * w);
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l - (l * w)
end function
public static double code(double w, double l) {
return l - (l * w);
}
def code(w, l): return l - (l * w)
function code(w, l) return Float64(l - Float64(l * w)) end
function tmp = code(w, l) tmp = l - (l * w); end
code[w_, l_] := N[(l - N[(l * w), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell - \ell \cdot w
\end{array}
Initial program 99.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
Taylor expanded in w around 0 98.1%
Taylor expanded in w around 0 62.6%
+-commutative62.6%
mul-1-neg62.6%
unsub-neg62.6%
*-commutative62.6%
Simplified62.6%
Final simplification62.6%
(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.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
frac-2neg99.7%
div-inv99.7%
Applied egg-rr99.7%
Taylor expanded in w around 0 55.5%
Final simplification55.5%
herbie shell --seed 2023200
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))