
(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 9 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}
(FPCore (w l) :precision binary64 (if (<= w -1.0) (exp (- w)) (if (<= w 22.0) (* (exp w) (pow l (+ w 1.0))) (exp (- (* w (log l)) w)))))
double code(double w, double l) {
double tmp;
if (w <= -1.0) {
tmp = exp(-w);
} else if (w <= 22.0) {
tmp = exp(w) * pow(l, (w + 1.0));
} else {
tmp = exp(((w * log(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 <= (-1.0d0)) then
tmp = exp(-w)
else if (w <= 22.0d0) then
tmp = exp(w) * (l ** (w + 1.0d0))
else
tmp = exp(((w * log(l)) - w))
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -1.0) {
tmp = Math.exp(-w);
} else if (w <= 22.0) {
tmp = Math.exp(w) * Math.pow(l, (w + 1.0));
} else {
tmp = Math.exp(((w * Math.log(l)) - w));
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -1.0: tmp = math.exp(-w) elif w <= 22.0: tmp = math.exp(w) * math.pow(l, (w + 1.0)) else: tmp = math.exp(((w * math.log(l)) - w)) return tmp
function code(w, l) tmp = 0.0 if (w <= -1.0) tmp = exp(Float64(-w)); elseif (w <= 22.0) tmp = Float64(exp(w) * (l ^ Float64(w + 1.0))); else tmp = exp(Float64(Float64(w * log(l)) - w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -1.0) tmp = exp(-w); elseif (w <= 22.0) tmp = exp(w) * (l ^ (w + 1.0)); else tmp = exp(((w * log(l)) - w)); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -1.0], N[Exp[(-w)], $MachinePrecision], If[LessEqual[w, 22.0], N[(N[Exp[w], $MachinePrecision] * N[Power[l, N[(w + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(w * N[Log[l], $MachinePrecision]), $MachinePrecision] - w), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -1:\\
\;\;\;\;e^{-w}\\
\mathbf{elif}\;w \leq 22:\\
\;\;\;\;e^{w} \cdot {\ell}^{\left(w + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{w \cdot \log \ell - w}\\
\end{array}
\end{array}
(FPCore (w l)
:precision binary64
(if (<= w -0.0075)
(exp (- w))
(if (<= w 0.92)
(* l (+ 1.0 (* w (+ 1.0 (log l)))))
(exp (- (* w (log l)) w)))))
double code(double w, double l) {
double tmp;
if (w <= -0.0075) {
tmp = exp(-w);
} else if (w <= 0.92) {
tmp = l * (1.0 + (w * (1.0 + log(l))));
} else {
tmp = exp(((w * log(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.0075d0)) then
tmp = exp(-w)
else if (w <= 0.92d0) then
tmp = l * (1.0d0 + (w * (1.0d0 + log(l))))
else
tmp = exp(((w * log(l)) - w))
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -0.0075) {
tmp = Math.exp(-w);
} else if (w <= 0.92) {
tmp = l * (1.0 + (w * (1.0 + Math.log(l))));
} else {
tmp = Math.exp(((w * Math.log(l)) - w));
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.0075: tmp = math.exp(-w) elif w <= 0.92: tmp = l * (1.0 + (w * (1.0 + math.log(l)))) else: tmp = math.exp(((w * math.log(l)) - w)) return tmp
function code(w, l) tmp = 0.0 if (w <= -0.0075) tmp = exp(Float64(-w)); elseif (w <= 0.92) tmp = Float64(l * Float64(1.0 + Float64(w * Float64(1.0 + log(l))))); else tmp = exp(Float64(Float64(w * log(l)) - w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.0075) tmp = exp(-w); elseif (w <= 0.92) tmp = l * (1.0 + (w * (1.0 + log(l)))); else tmp = exp(((w * log(l)) - w)); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.0075], N[Exp[(-w)], $MachinePrecision], If[LessEqual[w, 0.92], N[(l * N[(1.0 + N[(w * N[(1.0 + N[Log[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(w * N[Log[l], $MachinePrecision]), $MachinePrecision] - w), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.0075:\\
\;\;\;\;e^{-w}\\
\mathbf{elif}\;w \leq 0.92:\\
\;\;\;\;\ell \cdot \left(1 + w \cdot \left(1 + \log \ell\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{w \cdot \log \ell - w}\\
\end{array}
\end{array}
(FPCore (w l) :precision binary64 (if (<= w -0.0075) (exp (- w)) (if (<= w 0.76) (* l (+ 1.0 (* w (+ 1.0 (log l))))) (/ (pow l w) (exp w)))))
double code(double w, double l) {
double tmp;
if (w <= -0.0075) {
tmp = exp(-w);
} else if (w <= 0.76) {
tmp = l * (1.0 + (w * (1.0 + log(l))));
} else {
tmp = pow(l, w) / exp(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.0075d0)) then
tmp = exp(-w)
else if (w <= 0.76d0) then
tmp = l * (1.0d0 + (w * (1.0d0 + log(l))))
else
tmp = (l ** w) / exp(w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -0.0075) {
tmp = Math.exp(-w);
} else if (w <= 0.76) {
tmp = l * (1.0 + (w * (1.0 + Math.log(l))));
} else {
tmp = Math.pow(l, w) / Math.exp(w);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.0075: tmp = math.exp(-w) elif w <= 0.76: tmp = l * (1.0 + (w * (1.0 + math.log(l)))) else: tmp = math.pow(l, w) / math.exp(w) return tmp
function code(w, l) tmp = 0.0 if (w <= -0.0075) tmp = exp(Float64(-w)); elseif (w <= 0.76) tmp = Float64(l * Float64(1.0 + Float64(w * Float64(1.0 + log(l))))); else tmp = Float64((l ^ w) / exp(w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.0075) tmp = exp(-w); elseif (w <= 0.76) tmp = l * (1.0 + (w * (1.0 + log(l)))); else tmp = (l ^ w) / exp(w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.0075], N[Exp[(-w)], $MachinePrecision], If[LessEqual[w, 0.76], N[(l * N[(1.0 + N[(w * N[(1.0 + N[Log[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[l, w], $MachinePrecision] / N[Exp[w], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.0075:\\
\;\;\;\;e^{-w}\\
\mathbf{elif}\;w \leq 0.76:\\
\;\;\;\;\ell \cdot \left(1 + w \cdot \left(1 + \log \ell\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{\ell}^{w}}{e^{w}}\\
\end{array}
\end{array}
(FPCore (w l) :precision binary64 (if (<= w -1.0) (exp (- w)) (/ (pow l (+ w 1.0)) (exp w))))
double code(double w, double l) {
double tmp;
if (w <= -1.0) {
tmp = exp(-w);
} else {
tmp = pow(l, (w + 1.0)) / exp(w);
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (w <= (-1.0d0)) then
tmp = exp(-w)
else
tmp = (l ** (w + 1.0d0)) / exp(w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -1.0) {
tmp = Math.exp(-w);
} else {
tmp = Math.pow(l, (w + 1.0)) / Math.exp(w);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -1.0: tmp = math.exp(-w) else: tmp = math.pow(l, (w + 1.0)) / math.exp(w) return tmp
function code(w, l) tmp = 0.0 if (w <= -1.0) tmp = exp(Float64(-w)); else tmp = Float64((l ^ Float64(w + 1.0)) / exp(w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -1.0) tmp = exp(-w); else tmp = (l ^ (w + 1.0)) / exp(w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -1.0], N[Exp[(-w)], $MachinePrecision], N[(N[Power[l, N[(w + 1.0), $MachinePrecision]], $MachinePrecision] / N[Exp[w], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -1:\\
\;\;\;\;e^{-w}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\ell}^{\left(w + 1\right)}}{e^{w}}\\
\end{array}
\end{array}
(FPCore (w l) :precision binary64 (if (or (<= w -0.0075) (not (<= w 5500000.0))) (exp (- w)) (* l (+ 1.0 (* w (+ 1.0 (log l)))))))
double code(double w, double l) {
double tmp;
if ((w <= -0.0075) || !(w <= 5500000.0)) {
tmp = exp(-w);
} else {
tmp = l * (1.0 + (w * (1.0 + log(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.0075d0)) .or. (.not. (w <= 5500000.0d0))) then
tmp = exp(-w)
else
tmp = l * (1.0d0 + (w * (1.0d0 + log(l))))
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if ((w <= -0.0075) || !(w <= 5500000.0)) {
tmp = Math.exp(-w);
} else {
tmp = l * (1.0 + (w * (1.0 + Math.log(l))));
}
return tmp;
}
def code(w, l): tmp = 0 if (w <= -0.0075) or not (w <= 5500000.0): tmp = math.exp(-w) else: tmp = l * (1.0 + (w * (1.0 + math.log(l)))) return tmp
function code(w, l) tmp = 0.0 if ((w <= -0.0075) || !(w <= 5500000.0)) tmp = exp(Float64(-w)); else tmp = Float64(l * Float64(1.0 + Float64(w * Float64(1.0 + log(l))))); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if ((w <= -0.0075) || ~((w <= 5500000.0))) tmp = exp(-w); else tmp = l * (1.0 + (w * (1.0 + log(l)))); end tmp_2 = tmp; end
code[w_, l_] := If[Or[LessEqual[w, -0.0075], N[Not[LessEqual[w, 5500000.0]], $MachinePrecision]], N[Exp[(-w)], $MachinePrecision], N[(l * N[(1.0 + N[(w * N[(1.0 + N[Log[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.0075 \lor \neg \left(w \leq 5500000\right):\\
\;\;\;\;e^{-w}\\
\mathbf{else}:\\
\;\;\;\;\ell \cdot \left(1 + w \cdot \left(1 + \log \ell\right)\right)\\
\end{array}
\end{array}
(FPCore (w l) :precision binary64 (if (or (<= w -0.68) (not (<= w 5500000.0))) (exp (- w)) l))
double code(double w, double l) {
double tmp;
if ((w <= -0.68) || !(w <= 5500000.0)) {
tmp = exp(-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.68d0)) .or. (.not. (w <= 5500000.0d0))) then
tmp = exp(-w)
else
tmp = l
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if ((w <= -0.68) || !(w <= 5500000.0)) {
tmp = Math.exp(-w);
} else {
tmp = l;
}
return tmp;
}
def code(w, l): tmp = 0 if (w <= -0.68) or not (w <= 5500000.0): tmp = math.exp(-w) else: tmp = l return tmp
function code(w, l) tmp = 0.0 if ((w <= -0.68) || !(w <= 5500000.0)) tmp = exp(Float64(-w)); else tmp = l; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if ((w <= -0.68) || ~((w <= 5500000.0))) tmp = exp(-w); else tmp = l; end tmp_2 = tmp; end
code[w_, l_] := If[Or[LessEqual[w, -0.68], N[Not[LessEqual[w, 5500000.0]], $MachinePrecision]], N[Exp[(-w)], $MachinePrecision], l]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.68 \lor \neg \left(w \leq 5500000\right):\\
\;\;\;\;e^{-w}\\
\mathbf{else}:\\
\;\;\;\;\ell\\
\end{array}
\end{array}
(FPCore (w l) :precision binary64 1.0)
double code(double w, double l) {
return 1.0;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = 1.0d0
end function
public static double code(double w, double l) {
return 1.0;
}
def code(w, l): return 1.0
function code(w, l) return 1.0 end
function tmp = code(w, l) tmp = 1.0; end
code[w_, l_] := 1.0
\begin{array}{l}
\\
1
\end{array}
(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}
herbie shell --seed 2024003
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))