
(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 1.0)) E)))
double code(double w, double l) {
return pow(l, exp(w)) / (exp((w + 1.0)) / ((double) M_E));
}
public static double code(double w, double l) {
return Math.pow(l, Math.exp(w)) / (Math.exp((w + 1.0)) / Math.E);
}
def code(w, l): return math.pow(l, math.exp(w)) / (math.exp((w + 1.0)) / math.e)
function code(w, l) return Float64((l ^ exp(w)) / Float64(exp(Float64(w + 1.0)) / exp(1))) end
function tmp = code(w, l) tmp = (l ^ exp(w)) / (exp((w + 1.0)) / 2.71828182845904523536); end
code[w_, l_] := N[(N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision] / N[(N[Exp[N[(w + 1.0), $MachinePrecision]], $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\ell}^{\left(e^{w}\right)}}{\frac{e^{w + 1}}{e}}
\end{array}
Initial program 99.8%
exp-neg99.8%
remove-double-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
remove-double-neg99.8%
Simplified99.8%
expm1-log1p-u74.1%
expm1-undefine74.1%
exp-diff74.1%
log1p-undefine74.1%
rem-exp-log99.8%
exp-1-e99.8%
Applied egg-rr99.8%
+-commutative99.8%
Simplified99.8%
(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.8%
exp-neg99.8%
remove-double-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
remove-double-neg99.8%
Simplified99.8%
(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.8%
exp-neg99.8%
remove-double-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
remove-double-neg99.8%
Simplified99.8%
expm1-log1p-u74.1%
expm1-undefine74.1%
exp-diff74.1%
log1p-undefine74.1%
rem-exp-log99.8%
exp-1-e99.8%
Applied egg-rr99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in l around 0 99.4%
Taylor expanded in w around 0 97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in l around 0 97.9%
+-commutative97.9%
exp-sum97.9%
exp-1-e97.9%
associate-/l/97.9%
associate-/l*98.4%
*-inverses98.4%
*-rgt-identity98.4%
Simplified98.4%
(FPCore (w l) :precision binary64 (if (<= w 3.8e-29) (- l (* l w)) (/ (* l E) (+ E (* w (+ E (* 0.5 (* w E))))))))
double code(double w, double l) {
double tmp;
if (w <= 3.8e-29) {
tmp = l - (l * w);
} else {
tmp = (l * ((double) M_E)) / (((double) M_E) + (w * (((double) M_E) + (0.5 * (w * ((double) M_E))))));
}
return tmp;
}
public static double code(double w, double l) {
double tmp;
if (w <= 3.8e-29) {
tmp = l - (l * w);
} else {
tmp = (l * Math.E) / (Math.E + (w * (Math.E + (0.5 * (w * Math.E)))));
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 3.8e-29: tmp = l - (l * w) else: tmp = (l * math.e) / (math.e + (w * (math.e + (0.5 * (w * math.e))))) return tmp
function code(w, l) tmp = 0.0 if (w <= 3.8e-29) tmp = Float64(l - Float64(l * w)); else tmp = Float64(Float64(l * exp(1)) / Float64(exp(1) + Float64(w * Float64(exp(1) + Float64(0.5 * Float64(w * exp(1))))))); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 3.8e-29) tmp = l - (l * w); else tmp = (l * 2.71828182845904523536) / (2.71828182845904523536 + (w * (2.71828182845904523536 + (0.5 * (w * 2.71828182845904523536))))); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 3.8e-29], N[(l - N[(l * w), $MachinePrecision]), $MachinePrecision], N[(N[(l * E), $MachinePrecision] / N[(E + N[(w * N[(E + N[(0.5 * N[(w * E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 3.8 \cdot 10^{-29}:\\
\;\;\;\;\ell - \ell \cdot w\\
\mathbf{else}:\\
\;\;\;\;\frac{\ell \cdot e}{e + w \cdot \left(e + 0.5 \cdot \left(w \cdot e\right)\right)}\\
\end{array}
\end{array}
if w < 3.79999999999999976e-29Initial program 100.0%
exp-neg100.0%
remove-double-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
remove-double-neg100.0%
Simplified100.0%
expm1-log1p-u69.3%
expm1-undefine69.3%
exp-diff69.3%
log1p-undefine69.3%
rem-exp-log100.0%
exp-1-e100.0%
Applied egg-rr100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in l around 0 99.4%
Taylor expanded in w around 0 98.3%
*-commutative98.3%
Simplified98.3%
Taylor expanded in w around 0 76.6%
+-commutative76.6%
mul-1-neg76.6%
unsub-neg76.6%
exp-1-e76.6%
associate-/l*77.2%
*-inverses77.2%
*-rgt-identity77.2%
exp-1-e77.2%
associate-/l*77.2%
associate-/l*77.2%
*-inverses77.2%
*-rgt-identity77.2%
*-commutative77.2%
Simplified77.2%
if 3.79999999999999976e-29 < 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%
expm1-log1p-u99.2%
expm1-undefine99.2%
exp-diff99.2%
log1p-undefine99.2%
rem-exp-log99.2%
exp-1-e99.2%
Applied egg-rr99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in l around 0 99.2%
Taylor expanded in w around 0 95.4%
*-commutative95.4%
Simplified95.4%
Taylor expanded in w around 0 78.3%
exp-1-e78.3%
exp-1-e78.3%
exp-1-e78.3%
*-commutative78.3%
Simplified78.3%
Final simplification77.3%
(FPCore (w l) :precision binary64 (if (<= w 3.8e-29) (- l (* l w)) (/ (* l E) (* (+ w 1.0) E))))
double code(double w, double l) {
double tmp;
if (w <= 3.8e-29) {
tmp = l - (l * w);
} else {
tmp = (l * ((double) M_E)) / ((w + 1.0) * ((double) M_E));
}
return tmp;
}
public static double code(double w, double l) {
double tmp;
if (w <= 3.8e-29) {
tmp = l - (l * w);
} else {
tmp = (l * Math.E) / ((w + 1.0) * Math.E);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 3.8e-29: tmp = l - (l * w) else: tmp = (l * math.e) / ((w + 1.0) * math.e) return tmp
function code(w, l) tmp = 0.0 if (w <= 3.8e-29) tmp = Float64(l - Float64(l * w)); else tmp = Float64(Float64(l * exp(1)) / Float64(Float64(w + 1.0) * exp(1))); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 3.8e-29) tmp = l - (l * w); else tmp = (l * 2.71828182845904523536) / ((w + 1.0) * 2.71828182845904523536); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 3.8e-29], N[(l - N[(l * w), $MachinePrecision]), $MachinePrecision], N[(N[(l * E), $MachinePrecision] / N[(N[(w + 1.0), $MachinePrecision] * E), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 3.8 \cdot 10^{-29}:\\
\;\;\;\;\ell - \ell \cdot w\\
\mathbf{else}:\\
\;\;\;\;\frac{\ell \cdot e}{\left(w + 1\right) \cdot e}\\
\end{array}
\end{array}
if w < 3.79999999999999976e-29Initial program 100.0%
exp-neg100.0%
remove-double-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
remove-double-neg100.0%
Simplified100.0%
expm1-log1p-u69.3%
expm1-undefine69.3%
exp-diff69.3%
log1p-undefine69.3%
rem-exp-log100.0%
exp-1-e100.0%
Applied egg-rr100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in l around 0 99.4%
Taylor expanded in w around 0 98.3%
*-commutative98.3%
Simplified98.3%
Taylor expanded in w around 0 76.6%
+-commutative76.6%
mul-1-neg76.6%
unsub-neg76.6%
exp-1-e76.6%
associate-/l*77.2%
*-inverses77.2%
*-rgt-identity77.2%
exp-1-e77.2%
associate-/l*77.2%
associate-/l*77.2%
*-inverses77.2%
*-rgt-identity77.2%
*-commutative77.2%
Simplified77.2%
if 3.79999999999999976e-29 < 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%
expm1-log1p-u99.2%
expm1-undefine99.2%
exp-diff99.2%
log1p-undefine99.2%
rem-exp-log99.2%
exp-1-e99.2%
Applied egg-rr99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in l around 0 99.2%
Taylor expanded in w around 0 95.4%
*-commutative95.4%
Simplified95.4%
Taylor expanded in w around 0 52.4%
exp-1-e52.4%
exp-1-e52.4%
distribute-rgt1-in52.4%
Simplified52.4%
Final simplification73.2%
(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.8%
exp-neg99.8%
remove-double-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
remove-double-neg99.8%
Simplified99.8%
expm1-log1p-u74.1%
expm1-undefine74.1%
exp-diff74.1%
log1p-undefine74.1%
rem-exp-log99.8%
exp-1-e99.8%
Applied egg-rr99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in l around 0 99.4%
Taylor expanded in w around 0 97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in w around 0 66.7%
+-commutative66.7%
mul-1-neg66.7%
unsub-neg66.7%
exp-1-e66.7%
associate-/l*67.2%
*-inverses67.2%
*-rgt-identity67.2%
exp-1-e67.2%
associate-/l*67.2%
associate-/l*67.2%
*-inverses67.2%
*-rgt-identity67.2%
*-commutative67.2%
Simplified67.2%
Final simplification67.2%
(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.8%
exp-neg99.8%
remove-double-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
remove-double-neg99.8%
Simplified99.8%
Taylor expanded in w around 0 60.9%
herbie shell --seed 2024146
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))