
(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 (/ (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(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.6%
Final simplification98.6%
(FPCore (w l) :precision binary64 (* l (- 1.0 (+ w (* (* w w) -0.5)))))
double code(double w, double l) {
return l * (1.0 - (w + ((w * w) * -0.5)));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l * (1.0d0 - (w + ((w * w) * (-0.5d0))))
end function
public static double code(double w, double l) {
return l * (1.0 - (w + ((w * w) * -0.5)));
}
def code(w, l): return l * (1.0 - (w + ((w * w) * -0.5)))
function code(w, l) return Float64(l * Float64(1.0 - Float64(w + Float64(Float64(w * w) * -0.5)))) end
function tmp = code(w, l) tmp = l * (1.0 - (w + ((w * w) * -0.5))); end
code[w_, l_] := N[(l * N[(1.0 - N[(w + N[(N[(w * w), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell \cdot \left(1 - \left(w + \left(w \cdot w\right) \cdot -0.5\right)\right)
\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.6%
Taylor expanded in w around 0 74.1%
distribute-lft-out74.1%
unpow274.1%
distribute-rgt-out74.1%
metadata-eval74.1%
Simplified74.1%
Taylor expanded in l around 0 74.1%
mul-1-neg74.1%
*-commutative74.1%
unpow274.1%
Simplified74.1%
Final simplification74.1%
(FPCore (w l) :precision binary64 (if (<= w -2.3) (* 0.5 (* l (* w w))) (- l (* l w))))
double code(double w, double l) {
double tmp;
if (w <= -2.3) {
tmp = 0.5 * (l * (w * w));
} else {
tmp = l - (l * w);
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (w <= (-2.3d0)) then
tmp = 0.5d0 * (l * (w * w))
else
tmp = l - (l * w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -2.3) {
tmp = 0.5 * (l * (w * w));
} else {
tmp = l - (l * w);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -2.3: tmp = 0.5 * (l * (w * w)) else: tmp = l - (l * w) return tmp
function code(w, l) tmp = 0.0 if (w <= -2.3) tmp = Float64(0.5 * Float64(l * Float64(w * w))); else tmp = Float64(l - Float64(l * w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -2.3) tmp = 0.5 * (l * (w * w)); else tmp = l - (l * w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -2.3], N[(0.5 * N[(l * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(l - N[(l * w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -2.3:\\
\;\;\;\;0.5 \cdot \left(\ell \cdot \left(w \cdot w\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\ell - \ell \cdot w\\
\end{array}
\end{array}
if w < -2.2999999999999998Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in w around 0 100.0%
Taylor expanded in w around 0 66.5%
distribute-lft-out66.5%
unpow266.5%
distribute-rgt-out66.5%
metadata-eval66.5%
Simplified66.5%
Taylor expanded in w around inf 66.5%
unpow266.5%
Simplified66.5%
if -2.2999999999999998 < w Initial program 99.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in w around 0 97.9%
Taylor expanded in w around 0 77.9%
mul-1-neg77.9%
unsub-neg77.9%
Simplified77.9%
Final simplification74.3%
(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.6%
Taylor expanded in w around 0 65.9%
mul-1-neg65.9%
unsub-neg65.9%
Simplified65.9%
Final simplification65.9%
herbie shell --seed 2023277
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))