
(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 7 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.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (w l) :precision binary64 (if (or (<= w -0.7) (not (<= w 12.0))) (exp (- w)) (- l (* l w))))
double code(double w, double l) {
double tmp;
if ((w <= -0.7) || !(w <= 12.0)) {
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 <= 12.0d0))) 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 <= 12.0)) {
tmp = Math.exp(-w);
} else {
tmp = l - (l * w);
}
return tmp;
}
def code(w, l): tmp = 0 if (w <= -0.7) or not (w <= 12.0): tmp = math.exp(-w) else: tmp = l - (l * w) return tmp
function code(w, l) tmp = 0.0 if ((w <= -0.7) || !(w <= 12.0)) 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 <= 12.0))) 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, 12.0]], $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 12\right):\\
\;\;\;\;e^{-w}\\
\mathbf{else}:\\
\;\;\;\;\ell - \ell \cdot w\\
\end{array}
\end{array}
if w < -0.69999999999999996 or 12 < w Initial program 99.9%
exp-neg99.9%
associate-*l/99.9%
*-lft-identity99.9%
Simplified99.9%
add-exp-log100.0%
log-div99.9%
log-pow100.0%
add-log-exp100.0%
Applied egg-rr100.0%
Taylor expanded in w around inf 99.2%
neg-mul-199.2%
Simplified99.2%
if -0.69999999999999996 < w < 12Initial program 99.3%
exp-neg99.3%
associate-*l/99.3%
*-lft-identity99.3%
Simplified99.3%
Taylor expanded in w around 0 95.8%
Taylor expanded in w around 0 95.8%
+-commutative95.8%
mul-1-neg95.8%
unsub-neg95.8%
Simplified95.8%
Final simplification97.3%
(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.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in w around 0 97.3%
Final simplification97.3%
(FPCore (w l)
:precision binary64
(if (<= l 2.65e-101)
l
(if (<= l 7.6e+47)
(/ (- (* l l) (* (* l l) (* w w))) (+ l (* l w)))
(- l (* l w)))))
double code(double w, double l) {
double tmp;
if (l <= 2.65e-101) {
tmp = l;
} else if (l <= 7.6e+47) {
tmp = ((l * l) - ((l * l) * (w * w))) / (l + (l * 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 (l <= 2.65d-101) then
tmp = l
else if (l <= 7.6d+47) then
tmp = ((l * l) - ((l * l) * (w * w))) / (l + (l * w))
else
tmp = l - (l * w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (l <= 2.65e-101) {
tmp = l;
} else if (l <= 7.6e+47) {
tmp = ((l * l) - ((l * l) * (w * w))) / (l + (l * w));
} else {
tmp = l - (l * w);
}
return tmp;
}
def code(w, l): tmp = 0 if l <= 2.65e-101: tmp = l elif l <= 7.6e+47: tmp = ((l * l) - ((l * l) * (w * w))) / (l + (l * w)) else: tmp = l - (l * w) return tmp
function code(w, l) tmp = 0.0 if (l <= 2.65e-101) tmp = l; elseif (l <= 7.6e+47) tmp = Float64(Float64(Float64(l * l) - Float64(Float64(l * l) * Float64(w * w))) / Float64(l + Float64(l * w))); else tmp = Float64(l - Float64(l * w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (l <= 2.65e-101) tmp = l; elseif (l <= 7.6e+47) tmp = ((l * l) - ((l * l) * (w * w))) / (l + (l * w)); else tmp = l - (l * w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[l, 2.65e-101], l, If[LessEqual[l, 7.6e+47], N[(N[(N[(l * l), $MachinePrecision] - N[(N[(l * l), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l + N[(l * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(l - N[(l * w), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.65 \cdot 10^{-101}:\\
\;\;\;\;\ell\\
\mathbf{elif}\;\ell \leq 7.6 \cdot 10^{+47}:\\
\;\;\;\;\frac{\ell \cdot \ell - \left(\ell \cdot \ell\right) \cdot \left(w \cdot w\right)}{\ell + \ell \cdot w}\\
\mathbf{else}:\\
\;\;\;\;\ell - \ell \cdot w\\
\end{array}
\end{array}
if l < 2.6500000000000001e-101Initial program 99.4%
exp-neg99.4%
associate-*l/99.4%
*-lft-identity99.4%
Simplified99.4%
add-sqr-sqrt99.1%
pow299.1%
Applied egg-rr99.1%
Taylor expanded in w around 0 42.9%
if 2.6500000000000001e-101 < l < 7.6000000000000007e47Initial program 99.8%
exp-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in w around 0 98.8%
Taylor expanded in w around 0 56.8%
+-commutative56.8%
mul-1-neg56.8%
unsub-neg56.8%
Simplified56.8%
sub-neg56.8%
flip-+74.2%
distribute-rgt-neg-in74.2%
distribute-rgt-neg-in74.2%
distribute-rgt-neg-in74.2%
Applied egg-rr74.2%
swap-sqr79.1%
sqr-neg79.1%
Simplified79.1%
if 7.6000000000000007e47 < l Initial program 99.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in w around 0 98.2%
Taylor expanded in w around 0 88.3%
+-commutative88.3%
mul-1-neg88.3%
unsub-neg88.3%
Simplified88.3%
Final simplification68.1%
(FPCore (w l) :precision binary64 (if (<= w -0.42) (* w (- l)) l))
double code(double w, double l) {
double tmp;
if (w <= -0.42) {
tmp = w * -l;
} 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.42d0)) then
tmp = w * -l
else
tmp = l
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -0.42) {
tmp = w * -l;
} else {
tmp = l;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.42: tmp = w * -l else: tmp = l return tmp
function code(w, l) tmp = 0.0 if (w <= -0.42) tmp = Float64(w * Float64(-l)); else tmp = l; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.42) tmp = w * -l; else tmp = l; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.42], N[(w * (-l)), $MachinePrecision], l]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.42:\\
\;\;\;\;w \cdot \left(-\ell\right)\\
\mathbf{else}:\\
\;\;\;\;\ell\\
\end{array}
\end{array}
if w < -0.419999999999999984Initial program 99.9%
exp-neg99.9%
associate-*l/99.9%
*-lft-identity99.9%
Simplified99.9%
Taylor expanded in w around 0 98.8%
Taylor expanded in w around 0 27.5%
+-commutative27.5%
mul-1-neg27.5%
unsub-neg27.5%
Simplified27.5%
Taylor expanded in w around inf 27.5%
mul-1-neg27.5%
distribute-rgt-neg-out27.5%
Simplified27.5%
if -0.419999999999999984 < w Initial program 99.4%
exp-neg99.4%
associate-*l/99.4%
*-lft-identity99.4%
Simplified99.4%
add-sqr-sqrt98.8%
pow298.8%
Applied egg-rr98.8%
Taylor expanded in w around 0 78.6%
Final simplification63.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 99.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in w around 0 97.3%
Taylor expanded in w around 0 62.7%
+-commutative62.7%
mul-1-neg62.7%
unsub-neg62.7%
Simplified62.7%
Final simplification62.7%
(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.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
add-sqr-sqrt99.1%
pow299.1%
Applied egg-rr99.1%
Taylor expanded in w around 0 55.8%
Final simplification55.8%
herbie shell --seed 2023240
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))