
(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 8 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 98.9%
exp-neg98.9%
remove-double-neg98.9%
associate-*l/98.9%
*-lft-identity98.9%
remove-double-neg98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (w l) :precision binary64 (if (or (<= w -0.7) (not (<= w 14.2))) (exp (- w)) (- l (* l w))))
double code(double w, double l) {
double tmp;
if ((w <= -0.7) || !(w <= 14.2)) {
tmp = exp(-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 <= (-0.7d0)) .or. (.not. (w <= 14.2d0))) then
tmp = exp(-w)
else
tmp = l - (l * w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if ((w <= -0.7) || !(w <= 14.2)) {
tmp = Math.exp(-w);
} else {
tmp = l - (l * w);
}
return tmp;
}
def code(w, l): tmp = 0 if (w <= -0.7) or not (w <= 14.2): tmp = math.exp(-w) else: tmp = l - (l * w) return tmp
function code(w, l) tmp = 0.0 if ((w <= -0.7) || !(w <= 14.2)) tmp = exp(Float64(-w)); else tmp = Float64(l - Float64(l * w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if ((w <= -0.7) || ~((w <= 14.2))) tmp = exp(-w); else tmp = l - (l * w); end tmp_2 = tmp; end
code[w_, l_] := If[Or[LessEqual[w, -0.7], N[Not[LessEqual[w, 14.2]], $MachinePrecision]], N[Exp[(-w)], $MachinePrecision], N[(l - N[(l * w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.7 \lor \neg \left(w \leq 14.2\right):\\
\;\;\;\;e^{-w}\\
\mathbf{else}:\\
\;\;\;\;\ell - \ell \cdot w\\
\end{array}
\end{array}
if w < -0.69999999999999996 or 14.199999999999999 < w Initial program 99.2%
exp-neg99.2%
remove-double-neg99.2%
associate-*l/99.2%
*-lft-identity99.2%
remove-double-neg99.2%
Simplified99.2%
Taylor expanded in l around inf 99.2%
mul-1-neg99.2%
distribute-rgt-neg-in99.2%
log-rec99.2%
remove-double-neg99.2%
+-rgt-identity99.2%
exp-diff100.0%
+-rgt-identity100.0%
*-commutative100.0%
remove-double-neg100.0%
distribute-rgt-neg-in100.0%
distribute-lft-neg-in100.0%
Simplified100.0%
Taylor expanded in w around inf 99.2%
neg-mul-199.2%
Simplified99.2%
if -0.69999999999999996 < w < 14.199999999999999Initial program 98.7%
exp-neg98.7%
remove-double-neg98.7%
associate-*l/98.7%
*-lft-identity98.7%
remove-double-neg98.7%
Simplified98.7%
Taylor expanded in w around 0 95.3%
Taylor expanded in w around 0 95.3%
mul-1-neg95.3%
unsub-neg95.3%
*-commutative95.3%
Simplified95.3%
Final simplification97.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 98.9%
exp-neg98.9%
remove-double-neg98.9%
associate-*l/98.9%
*-lft-identity98.9%
remove-double-neg98.9%
Simplified98.9%
Taylor expanded in w around 0 97.1%
Final simplification97.1%
(FPCore (w l)
:precision binary64
(let* ((t_0 (- (* l 0.5) l)))
(-
l
(*
w
(+
l
(* w (- t_0 (* w (- t_0 (+ (* l -0.5) (* l 0.16666666666666666)))))))))))
double code(double w, double l) {
double t_0 = (l * 0.5) - l;
return l - (w * (l + (w * (t_0 - (w * (t_0 - ((l * -0.5) + (l * 0.16666666666666666))))))));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: t_0
t_0 = (l * 0.5d0) - l
code = l - (w * (l + (w * (t_0 - (w * (t_0 - ((l * (-0.5d0)) + (l * 0.16666666666666666d0))))))))
end function
public static double code(double w, double l) {
double t_0 = (l * 0.5) - l;
return l - (w * (l + (w * (t_0 - (w * (t_0 - ((l * -0.5) + (l * 0.16666666666666666))))))));
}
def code(w, l): t_0 = (l * 0.5) - l return l - (w * (l + (w * (t_0 - (w * (t_0 - ((l * -0.5) + (l * 0.16666666666666666))))))))
function code(w, l) t_0 = Float64(Float64(l * 0.5) - l) return Float64(l - Float64(w * Float64(l + Float64(w * Float64(t_0 - Float64(w * Float64(t_0 - Float64(Float64(l * -0.5) + Float64(l * 0.16666666666666666))))))))) end
function tmp = code(w, l) t_0 = (l * 0.5) - l; tmp = l - (w * (l + (w * (t_0 - (w * (t_0 - ((l * -0.5) + (l * 0.16666666666666666)))))))); end
code[w_, l_] := Block[{t$95$0 = N[(N[(l * 0.5), $MachinePrecision] - l), $MachinePrecision]}, N[(l - N[(w * N[(l + N[(w * N[(t$95$0 - N[(w * N[(t$95$0 - N[(N[(l * -0.5), $MachinePrecision] + N[(l * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \ell \cdot 0.5 - \ell\\
\ell - w \cdot \left(\ell + w \cdot \left(t\_0 - w \cdot \left(t\_0 - \left(\ell \cdot -0.5 + \ell \cdot 0.16666666666666666\right)\right)\right)\right)
\end{array}
\end{array}
Initial program 98.9%
exp-neg98.9%
remove-double-neg98.9%
associate-*l/98.9%
*-lft-identity98.9%
remove-double-neg98.9%
Simplified98.9%
Taylor expanded in w around 0 97.1%
Taylor expanded in w around 0 77.8%
Final simplification77.8%
(FPCore (w l) :precision binary64 (+ l (* l (* w (+ -1.0 (* w 0.5))))))
double code(double w, double l) {
return l + (l * (w * (-1.0 + (w * 0.5))));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l + (l * (w * ((-1.0d0) + (w * 0.5d0))))
end function
public static double code(double w, double l) {
return l + (l * (w * (-1.0 + (w * 0.5))));
}
def code(w, l): return l + (l * (w * (-1.0 + (w * 0.5))))
function code(w, l) return Float64(l + Float64(l * Float64(w * Float64(-1.0 + Float64(w * 0.5))))) end
function tmp = code(w, l) tmp = l + (l * (w * (-1.0 + (w * 0.5)))); end
code[w_, l_] := N[(l + N[(l * N[(w * N[(-1.0 + N[(w * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell + \ell \cdot \left(w \cdot \left(-1 + w \cdot 0.5\right)\right)
\end{array}
Initial program 98.9%
exp-neg98.9%
remove-double-neg98.9%
associate-*l/98.9%
*-lft-identity98.9%
remove-double-neg98.9%
Simplified98.9%
Taylor expanded in w around 0 97.1%
Taylor expanded in w around 0 72.0%
associate-*r*72.0%
mul-1-neg72.0%
distribute-rgt-out72.0%
metadata-eval72.0%
Simplified72.0%
Taylor expanded in l around 0 76.7%
Final simplification76.7%
(FPCore (w l) :precision binary64 (+ l (* w (* w (* l 0.5)))))
double code(double w, double l) {
return l + (w * (w * (l * 0.5)));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l + (w * (w * (l * 0.5d0)))
end function
public static double code(double w, double l) {
return l + (w * (w * (l * 0.5)));
}
def code(w, l): return l + (w * (w * (l * 0.5)))
function code(w, l) return Float64(l + Float64(w * Float64(w * Float64(l * 0.5)))) end
function tmp = code(w, l) tmp = l + (w * (w * (l * 0.5))); end
code[w_, l_] := N[(l + N[(w * N[(w * N[(l * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell + w \cdot \left(w \cdot \left(\ell \cdot 0.5\right)\right)
\end{array}
Initial program 98.9%
exp-neg98.9%
remove-double-neg98.9%
associate-*l/98.9%
*-lft-identity98.9%
remove-double-neg98.9%
Simplified98.9%
Taylor expanded in w around 0 97.1%
Taylor expanded in w around 0 72.0%
associate-*r*72.0%
mul-1-neg72.0%
distribute-rgt-out72.0%
metadata-eval72.0%
Simplified72.0%
Taylor expanded in w around inf 72.0%
associate-*r*72.0%
*-commutative72.0%
Simplified72.0%
Final simplification72.0%
(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 98.9%
exp-neg98.9%
remove-double-neg98.9%
associate-*l/98.9%
*-lft-identity98.9%
remove-double-neg98.9%
Simplified98.9%
Taylor expanded in w around 0 97.1%
Taylor expanded in w around 0 61.5%
mul-1-neg61.5%
unsub-neg61.5%
*-commutative61.5%
Simplified61.5%
Final simplification61.5%
(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 98.9%
exp-neg98.9%
remove-double-neg98.9%
associate-*l/98.9%
*-lft-identity98.9%
remove-double-neg98.9%
Simplified98.9%
Taylor expanded in w around 0 51.4%
+-commutative51.4%
fma-define51.4%
sub-neg51.4%
*-commutative51.4%
neg-mul-151.4%
distribute-rgt-out51.4%
Simplified51.4%
Taylor expanded in l around 0 52.1%
Taylor expanded in w around 0 52.2%
Final simplification52.2%
herbie shell --seed 2024060
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))