
(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)) (/ (- -1.0) (exp w))))
double code(double w, double l) {
return pow(l, exp(w)) * (-(-1.0) / exp(w));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = (l ** exp(w)) * (-(-1.0d0) / exp(w))
end function
public static double code(double w, double l) {
return Math.pow(l, Math.exp(w)) * (-(-1.0) / Math.exp(w));
}
def code(w, l): return math.pow(l, math.exp(w)) * (-(-1.0) / math.exp(w))
function code(w, l) return Float64((l ^ exp(w)) * Float64(Float64(-(-1.0)) / exp(w))) end
function tmp = code(w, l) tmp = (l ^ exp(w)) * (-(-1.0) / exp(w)); end
code[w_, l_] := N[(N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision] * N[((--1.0) / N[Exp[w], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\ell}^{\left(e^{w}\right)} \cdot \frac{--1}{e^{w}}
\end{array}
Initial program 99.0%
exp-neg99.0%
associate-*l/99.0%
*-lft-identity99.0%
Simplified99.0%
frac-2neg99.0%
div-inv99.0%
Applied egg-rr99.0%
Taylor expanded in w around inf 99.0%
Final simplification99.0%
(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.0%
exp-neg99.0%
associate-*l/99.0%
*-lft-identity99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (w l)
:precision binary64
(if (<= w -0.062)
(exp (- w))
(if (<= w 0.0076)
(* (+ l (* l (* w (log l)))) (- (- w) -1.0))
(exp (- (log l) w)))))
double code(double w, double l) {
double tmp;
if (w <= -0.062) {
tmp = exp(-w);
} else if (w <= 0.0076) {
tmp = (l + (l * (w * log(l)))) * (-w - -1.0);
} else {
tmp = exp((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.062d0)) then
tmp = exp(-w)
else if (w <= 0.0076d0) then
tmp = (l + (l * (w * log(l)))) * (-w - (-1.0d0))
else
tmp = exp((log(l) - w))
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -0.062) {
tmp = Math.exp(-w);
} else if (w <= 0.0076) {
tmp = (l + (l * (w * Math.log(l)))) * (-w - -1.0);
} else {
tmp = Math.exp((Math.log(l) - w));
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.062: tmp = math.exp(-w) elif w <= 0.0076: tmp = (l + (l * (w * math.log(l)))) * (-w - -1.0) else: tmp = math.exp((math.log(l) - w)) return tmp
function code(w, l) tmp = 0.0 if (w <= -0.062) tmp = exp(Float64(-w)); elseif (w <= 0.0076) tmp = Float64(Float64(l + Float64(l * Float64(w * log(l)))) * Float64(Float64(-w) - -1.0)); else tmp = exp(Float64(log(l) - w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.062) tmp = exp(-w); elseif (w <= 0.0076) tmp = (l + (l * (w * log(l)))) * (-w - -1.0); else tmp = exp((log(l) - w)); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.062], N[Exp[(-w)], $MachinePrecision], If[LessEqual[w, 0.0076], N[(N[(l + N[(l * N[(w * N[Log[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((-w) - -1.0), $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[Log[l], $MachinePrecision] - w), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.062:\\
\;\;\;\;e^{-w}\\
\mathbf{elif}\;w \leq 0.0076:\\
\;\;\;\;\left(\ell + \ell \cdot \left(w \cdot \log \ell\right)\right) \cdot \left(\left(-w\right) - -1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log \ell - w}\\
\end{array}
\end{array}
if w < -0.062Initial program 99.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
add-exp-log99.6%
log-div99.6%
log-pow99.6%
add-log-exp99.6%
Applied egg-rr99.6%
Taylor expanded in w around inf 96.4%
neg-mul-196.4%
Simplified96.4%
if -0.062 < w < 0.00759999999999999998Initial 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 99.3%
Taylor expanded in w around 0 99.0%
*-commutative99.0%
Simplified99.0%
if 0.00759999999999999998 < w Initial program 94.7%
exp-neg94.7%
associate-*l/94.7%
*-lft-identity94.7%
Simplified94.7%
add-exp-log94.7%
log-div94.6%
log-pow94.6%
add-log-exp99.7%
Applied egg-rr99.7%
Taylor expanded in w around 0 90.3%
Final simplification96.9%
(FPCore (w l) :precision binary64 (if (<= w -4.1) (exp (- w)) (pow l (exp w))))
double code(double w, double l) {
double tmp;
if (w <= -4.1) {
tmp = exp(-w);
} else {
tmp = pow(l, 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 <= (-4.1d0)) then
tmp = exp(-w)
else
tmp = l ** exp(w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -4.1) {
tmp = Math.exp(-w);
} else {
tmp = Math.pow(l, Math.exp(w));
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -4.1: tmp = math.exp(-w) else: tmp = math.pow(l, math.exp(w)) return tmp
function code(w, l) tmp = 0.0 if (w <= -4.1) tmp = exp(Float64(-w)); else tmp = l ^ exp(w); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -4.1) tmp = exp(-w); else tmp = l ^ exp(w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -4.1], N[Exp[(-w)], $MachinePrecision], N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -4.1:\\
\;\;\;\;e^{-w}\\
\mathbf{else}:\\
\;\;\;\;{\ell}^{\left(e^{w}\right)}\\
\end{array}
\end{array}
if w < -4.0999999999999996Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
add-exp-log99.9%
log-div99.9%
log-pow99.9%
add-log-exp99.9%
Applied egg-rr99.9%
Taylor expanded in w around inf 99.0%
neg-mul-199.0%
Simplified99.0%
if -4.0999999999999996 < w Initial program 98.6%
exp-neg98.6%
associate-*l/98.6%
*-lft-identity98.6%
Simplified98.6%
frac-2neg98.6%
div-inv98.6%
Applied egg-rr98.6%
Taylor expanded in w around 0 97.6%
Final simplification98.0%
(FPCore (w l) :precision binary64 (if (or (<= w -0.122) (not (<= w 5000000.0))) (exp (- w)) (+ l (* w (- (* l (log l)) l)))))
double code(double w, double l) {
double tmp;
if ((w <= -0.122) || !(w <= 5000000.0)) {
tmp = exp(-w);
} else {
tmp = l + (w * ((l * log(l)) - 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.122d0)) .or. (.not. (w <= 5000000.0d0))) then
tmp = exp(-w)
else
tmp = l + (w * ((l * log(l)) - l))
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if ((w <= -0.122) || !(w <= 5000000.0)) {
tmp = Math.exp(-w);
} else {
tmp = l + (w * ((l * Math.log(l)) - l));
}
return tmp;
}
def code(w, l): tmp = 0 if (w <= -0.122) or not (w <= 5000000.0): tmp = math.exp(-w) else: tmp = l + (w * ((l * math.log(l)) - l)) return tmp
function code(w, l) tmp = 0.0 if ((w <= -0.122) || !(w <= 5000000.0)) tmp = exp(Float64(-w)); else tmp = Float64(l + Float64(w * Float64(Float64(l * log(l)) - l))); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if ((w <= -0.122) || ~((w <= 5000000.0))) tmp = exp(-w); else tmp = l + (w * ((l * log(l)) - l)); end tmp_2 = tmp; end
code[w_, l_] := If[Or[LessEqual[w, -0.122], N[Not[LessEqual[w, 5000000.0]], $MachinePrecision]], N[Exp[(-w)], $MachinePrecision], N[(l + N[(w * N[(N[(l * N[Log[l], $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.122 \lor \neg \left(w \leq 5000000\right):\\
\;\;\;\;e^{-w}\\
\mathbf{else}:\\
\;\;\;\;\ell + w \cdot \left(\ell \cdot \log \ell - \ell\right)\\
\end{array}
\end{array}
if w < -0.122 or 5e6 < w Initial program 99.8%
exp-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
add-exp-log99.8%
log-div99.8%
log-pow99.7%
add-log-exp99.7%
Applied egg-rr99.7%
Taylor expanded in w around inf 97.6%
neg-mul-197.6%
Simplified97.6%
if -0.122 < w < 5e6Initial program 98.3%
exp-neg98.3%
associate-*l/98.3%
*-lft-identity98.3%
Simplified98.3%
Taylor expanded in w around 0 95.9%
Final simplification96.6%
(FPCore (w l) :precision binary64 (if (or (<= w -0.075) (not (<= w 5000000.0))) (exp (- w)) (+ l (* (+ -1.0 (log l)) (* l w)))))
double code(double w, double l) {
double tmp;
if ((w <= -0.075) || !(w <= 5000000.0)) {
tmp = exp(-w);
} else {
tmp = l + ((-1.0 + log(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.075d0)) .or. (.not. (w <= 5000000.0d0))) then
tmp = exp(-w)
else
tmp = l + (((-1.0d0) + log(l)) * (l * w))
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if ((w <= -0.075) || !(w <= 5000000.0)) {
tmp = Math.exp(-w);
} else {
tmp = l + ((-1.0 + Math.log(l)) * (l * w));
}
return tmp;
}
def code(w, l): tmp = 0 if (w <= -0.075) or not (w <= 5000000.0): tmp = math.exp(-w) else: tmp = l + ((-1.0 + math.log(l)) * (l * w)) return tmp
function code(w, l) tmp = 0.0 if ((w <= -0.075) || !(w <= 5000000.0)) tmp = exp(Float64(-w)); else tmp = Float64(l + Float64(Float64(-1.0 + log(l)) * Float64(l * w))); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if ((w <= -0.075) || ~((w <= 5000000.0))) tmp = exp(-w); else tmp = l + ((-1.0 + log(l)) * (l * w)); end tmp_2 = tmp; end
code[w_, l_] := If[Or[LessEqual[w, -0.075], N[Not[LessEqual[w, 5000000.0]], $MachinePrecision]], N[Exp[(-w)], $MachinePrecision], N[(l + N[(N[(-1.0 + N[Log[l], $MachinePrecision]), $MachinePrecision] * N[(l * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.075 \lor \neg \left(w \leq 5000000\right):\\
\;\;\;\;e^{-w}\\
\mathbf{else}:\\
\;\;\;\;\ell + \left(-1 + \log \ell\right) \cdot \left(\ell \cdot w\right)\\
\end{array}
\end{array}
if w < -0.0749999999999999972 or 5e6 < w Initial program 99.8%
exp-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
add-exp-log99.8%
log-div99.8%
log-pow99.7%
add-log-exp99.7%
Applied egg-rr99.7%
Taylor expanded in w around inf 97.6%
neg-mul-197.6%
Simplified97.6%
if -0.0749999999999999972 < w < 5e6Initial program 98.3%
exp-neg98.3%
associate-*l/98.3%
*-lft-identity98.3%
Simplified98.3%
Taylor expanded in w around 0 95.9%
Taylor expanded in l around 0 96.4%
Final simplification96.9%
(FPCore (w l) :precision binary64 (if (or (<= w -0.69) (not (<= w 5000000.0))) (exp (- w)) l))
double code(double w, double l) {
double tmp;
if ((w <= -0.69) || !(w <= 5000000.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.69d0)) .or. (.not. (w <= 5000000.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.69) || !(w <= 5000000.0)) {
tmp = Math.exp(-w);
} else {
tmp = l;
}
return tmp;
}
def code(w, l): tmp = 0 if (w <= -0.69) or not (w <= 5000000.0): tmp = math.exp(-w) else: tmp = l return tmp
function code(w, l) tmp = 0.0 if ((w <= -0.69) || !(w <= 5000000.0)) tmp = exp(Float64(-w)); else tmp = l; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if ((w <= -0.69) || ~((w <= 5000000.0))) tmp = exp(-w); else tmp = l; end tmp_2 = tmp; end
code[w_, l_] := If[Or[LessEqual[w, -0.69], N[Not[LessEqual[w, 5000000.0]], $MachinePrecision]], N[Exp[(-w)], $MachinePrecision], l]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.69 \lor \neg \left(w \leq 5000000\right):\\
\;\;\;\;e^{-w}\\
\mathbf{else}:\\
\;\;\;\;\ell\\
\end{array}
\end{array}
if w < -0.68999999999999995 or 5e6 < w Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
add-exp-log100.0%
log-div100.0%
log-pow100.0%
add-log-exp100.0%
Applied egg-rr100.0%
Taylor expanded in w around inf 99.3%
neg-mul-199.3%
Simplified99.3%
if -0.68999999999999995 < w < 5e6Initial program 98.2%
exp-neg98.2%
associate-*l/98.2%
*-lft-identity98.2%
Simplified98.2%
Taylor expanded in w around 0 94.5%
Final simplification96.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 99.0%
exp-neg99.0%
associate-*l/99.0%
*-lft-identity99.0%
Simplified99.0%
Taylor expanded in w around 0 57.6%
Final simplification57.6%
herbie shell --seed 2023215
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))