
(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 10 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 (* (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}
Initial program 99.8%
Final simplification99.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%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (w l) :precision binary64 (if (<= w -1.0) (pow E (- w)) (/ (pow l (+ (+ w 1.0) (* (pow w 2.0) 0.5))) (+ w 1.0))))
double code(double w, double l) {
double tmp;
if (w <= -1.0) {
tmp = pow(((double) M_E), -w);
} else {
tmp = pow(l, ((w + 1.0) + (pow(w, 2.0) * 0.5))) / (w + 1.0);
}
return tmp;
}
public static double code(double w, double l) {
double tmp;
if (w <= -1.0) {
tmp = Math.pow(Math.E, -w);
} else {
tmp = Math.pow(l, ((w + 1.0) + (Math.pow(w, 2.0) * 0.5))) / (w + 1.0);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -1.0: tmp = math.pow(math.e, -w) else: tmp = math.pow(l, ((w + 1.0) + (math.pow(w, 2.0) * 0.5))) / (w + 1.0) return tmp
function code(w, l) tmp = 0.0 if (w <= -1.0) tmp = exp(1) ^ Float64(-w); else tmp = Float64((l ^ Float64(Float64(w + 1.0) + Float64((w ^ 2.0) * 0.5))) / Float64(w + 1.0)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -1.0) tmp = 2.71828182845904523536 ^ -w; else tmp = (l ^ ((w + 1.0) + ((w ^ 2.0) * 0.5))) / (w + 1.0); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -1.0], N[Power[E, (-w)], $MachinePrecision], N[(N[Power[l, N[(N[(w + 1.0), $MachinePrecision] + N[(N[Power[w, 2.0], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(w + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -1:\\
\;\;\;\;{e}^{\left(-w\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\ell}^{\left(\left(w + 1\right) + {w}^{2} \cdot 0.5\right)}}{w + 1}\\
\end{array}
\end{array}
if w < -1Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
add-exp-log100.0%
pow1100.0%
log-pow100.0%
exp-prod99.9%
exp-1-e99.9%
log-div99.9%
log-pow99.9%
add-log-exp99.9%
fma-neg99.9%
Applied egg-rr99.9%
Taylor expanded in w around inf 99.9%
neg-mul-199.9%
Simplified99.9%
if -1 < w Initial program 99.8%
exp-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in w around 0 99.5%
+-commutative99.0%
Simplified99.5%
Taylor expanded in w around 0 99.5%
associate-+r+99.5%
+-commutative99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.6%
(FPCore (w l) :precision binary64 (if (<= w -1.0) (pow E (- w)) (/ (pow l (exp w)) (+ w 1.0))))
double code(double w, double l) {
double tmp;
if (w <= -1.0) {
tmp = pow(((double) M_E), -w);
} else {
tmp = pow(l, exp(w)) / (w + 1.0);
}
return tmp;
}
public static double code(double w, double l) {
double tmp;
if (w <= -1.0) {
tmp = Math.pow(Math.E, -w);
} else {
tmp = Math.pow(l, Math.exp(w)) / (w + 1.0);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -1.0: tmp = math.pow(math.e, -w) else: tmp = math.pow(l, math.exp(w)) / (w + 1.0) return tmp
function code(w, l) tmp = 0.0 if (w <= -1.0) tmp = exp(1) ^ Float64(-w); else tmp = Float64((l ^ exp(w)) / Float64(w + 1.0)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -1.0) tmp = 2.71828182845904523536 ^ -w; else tmp = (l ^ exp(w)) / (w + 1.0); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -1.0], N[Power[E, (-w)], $MachinePrecision], N[(N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision] / N[(w + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -1:\\
\;\;\;\;{e}^{\left(-w\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\ell}^{\left(e^{w}\right)}}{w + 1}\\
\end{array}
\end{array}
if w < -1Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
add-exp-log100.0%
pow1100.0%
log-pow100.0%
exp-prod99.9%
exp-1-e99.9%
log-div99.9%
log-pow99.9%
add-log-exp99.9%
fma-neg99.9%
Applied egg-rr99.9%
Taylor expanded in w around inf 99.9%
neg-mul-199.9%
Simplified99.9%
if -1 < w Initial program 99.8%
exp-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in w around 0 99.5%
+-commutative99.0%
Simplified99.5%
Final simplification99.6%
(FPCore (w l) :precision binary64 (if (<= w -0.98) (pow E (- w)) (/ (pow l (+ w 1.0)) (+ w 1.0))))
double code(double w, double l) {
double tmp;
if (w <= -0.98) {
tmp = pow(((double) M_E), -w);
} else {
tmp = pow(l, (w + 1.0)) / (w + 1.0);
}
return tmp;
}
public static double code(double w, double l) {
double tmp;
if (w <= -0.98) {
tmp = Math.pow(Math.E, -w);
} else {
tmp = Math.pow(l, (w + 1.0)) / (w + 1.0);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.98: tmp = math.pow(math.e, -w) else: tmp = math.pow(l, (w + 1.0)) / (w + 1.0) return tmp
function code(w, l) tmp = 0.0 if (w <= -0.98) tmp = exp(1) ^ Float64(-w); else tmp = Float64((l ^ Float64(w + 1.0)) / Float64(w + 1.0)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.98) tmp = 2.71828182845904523536 ^ -w; else tmp = (l ^ (w + 1.0)) / (w + 1.0); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.98], N[Power[E, (-w)], $MachinePrecision], N[(N[Power[l, N[(w + 1.0), $MachinePrecision]], $MachinePrecision] / N[(w + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.98:\\
\;\;\;\;{e}^{\left(-w\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\ell}^{\left(w + 1\right)}}{w + 1}\\
\end{array}
\end{array}
if w < -0.97999999999999998Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
add-exp-log100.0%
pow1100.0%
log-pow100.0%
exp-prod99.9%
exp-1-e99.9%
log-div99.9%
log-pow99.9%
add-log-exp99.9%
fma-neg99.9%
Applied egg-rr99.9%
Taylor expanded in w around inf 99.9%
neg-mul-199.9%
Simplified99.9%
if -0.97999999999999998 < w Initial program 99.8%
exp-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in w around 0 99.5%
+-commutative99.0%
Simplified99.5%
Taylor expanded in w around 0 99.4%
+-commutative99.0%
Simplified99.4%
Final simplification99.5%
(FPCore (w l) :precision binary64 (if (<= w -1.0) (pow E (- w)) (* l (pow l w))))
double code(double w, double l) {
double tmp;
if (w <= -1.0) {
tmp = pow(((double) M_E), -w);
} else {
tmp = l * pow(l, w);
}
return tmp;
}
public static double code(double w, double l) {
double tmp;
if (w <= -1.0) {
tmp = Math.pow(Math.E, -w);
} else {
tmp = l * Math.pow(l, w);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -1.0: tmp = math.pow(math.e, -w) else: tmp = l * math.pow(l, w) return tmp
function code(w, l) tmp = 0.0 if (w <= -1.0) tmp = exp(1) ^ Float64(-w); else tmp = Float64(l * (l ^ w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -1.0) tmp = 2.71828182845904523536 ^ -w; else tmp = l * (l ^ w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -1.0], N[Power[E, (-w)], $MachinePrecision], N[(l * N[Power[l, w], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -1:\\
\;\;\;\;{e}^{\left(-w\right)}\\
\mathbf{else}:\\
\;\;\;\;\ell \cdot {\ell}^{w}\\
\end{array}
\end{array}
if w < -1Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
add-exp-log100.0%
pow1100.0%
log-pow100.0%
exp-prod99.9%
exp-1-e99.9%
log-div99.9%
log-pow99.9%
add-log-exp99.9%
fma-neg99.9%
Applied egg-rr99.9%
Taylor expanded in w around inf 99.9%
neg-mul-199.9%
Simplified99.9%
if -1 < w Initial program 99.8%
exp-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in w around 0 99.0%
Taylor expanded in w around 0 99.0%
+-commutative99.0%
Simplified99.0%
pow-plus99.0%
Applied egg-rr99.0%
Final simplification99.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.8%
exp-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in w around 0 97.6%
Final simplification97.6%
(FPCore (w l) :precision binary64 (if (<= w 0.116) (- l (* w l)) (+ -1.0 (+ l 1.0))))
double code(double w, double l) {
double tmp;
if (w <= 0.116) {
tmp = l - (w * l);
} else {
tmp = -1.0 + (l + 1.0);
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (w <= 0.116d0) then
tmp = l - (w * l)
else
tmp = (-1.0d0) + (l + 1.0d0)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 0.116) {
tmp = l - (w * l);
} else {
tmp = -1.0 + (l + 1.0);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 0.116: tmp = l - (w * l) else: tmp = -1.0 + (l + 1.0) return tmp
function code(w, l) tmp = 0.0 if (w <= 0.116) tmp = Float64(l - Float64(w * l)); else tmp = Float64(-1.0 + Float64(l + 1.0)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.116) tmp = l - (w * l); else tmp = -1.0 + (l + 1.0); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 0.116], N[(l - N[(w * l), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(l + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 0.116:\\
\;\;\;\;\ell - w \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(\ell + 1\right)\\
\end{array}
\end{array}
if w < 0.116000000000000006Initial program 99.8%
exp-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in w around 0 98.5%
Taylor expanded in w around 0 72.8%
mul-1-neg72.8%
unsub-neg72.8%
*-commutative72.8%
Simplified72.8%
if 0.116000000000000006 < w Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
exp-diff100.0%
log1p-udef100.0%
rem-exp-log100.0%
exp-1-e100.0%
Applied egg-rr100.0%
Taylor expanded in w around 0 5.2%
exp-1-e5.2%
associate-/l*5.2%
*-inverses5.2%
rem-square-sqrt5.2%
associate-*r/5.2%
/-rgt-identity5.2%
rem-square-sqrt5.2%
Simplified5.2%
expm1-log1p-u5.2%
expm1-udef91.2%
log1p-udef91.2%
rem-exp-log91.2%
Applied egg-rr91.2%
Final simplification75.2%
(FPCore (w l) :precision binary64 (- l (* w l)))
double code(double w, double l) {
return l - (w * l);
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l - (w * l)
end function
public static double code(double w, double l) {
return l - (w * l);
}
def code(w, l): return l - (w * l)
function code(w, l) return Float64(l - Float64(w * l)) end
function tmp = code(w, l) tmp = l - (w * l); end
code[w_, l_] := N[(l - N[(w * l), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell - w \cdot \ell
\end{array}
Initial program 99.8%
exp-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in w around 0 97.6%
Taylor expanded in w around 0 63.9%
mul-1-neg63.9%
unsub-neg63.9%
*-commutative63.9%
Simplified63.9%
Final simplification63.9%
(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%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
expm1-log1p-u68.2%
expm1-udef68.2%
exp-diff68.2%
log1p-udef68.2%
rem-exp-log99.8%
exp-1-e99.8%
Applied egg-rr99.8%
Taylor expanded in w around 0 56.3%
exp-1-e56.3%
associate-/l*56.5%
*-inverses56.5%
rem-square-sqrt56.0%
associate-*r/56.0%
/-rgt-identity56.0%
rem-square-sqrt56.5%
Simplified56.5%
Final simplification56.5%
herbie shell --seed 2024101
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))