
(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 (* (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.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 (or (<= w -0.7) (not (<= w 14500000.0))) (exp (- w)) l))
double code(double w, double l) {
double tmp;
if ((w <= -0.7) || !(w <= 14500000.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.7d0)) .or. (.not. (w <= 14500000.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.7) || !(w <= 14500000.0)) {
tmp = Math.exp(-w);
} else {
tmp = l;
}
return tmp;
}
def code(w, l): tmp = 0 if (w <= -0.7) or not (w <= 14500000.0): tmp = math.exp(-w) else: tmp = l return tmp
function code(w, l) tmp = 0.0 if ((w <= -0.7) || !(w <= 14500000.0)) tmp = exp(Float64(-w)); else tmp = l; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if ((w <= -0.7) || ~((w <= 14500000.0))) tmp = exp(-w); else tmp = l; end tmp_2 = tmp; end
code[w_, l_] := If[Or[LessEqual[w, -0.7], N[Not[LessEqual[w, 14500000.0]], $MachinePrecision]], N[Exp[(-w)], $MachinePrecision], l]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.7 \lor \neg \left(w \leq 14500000\right):\\
\;\;\;\;e^{-w}\\
\mathbf{else}:\\
\;\;\;\;\ell\\
\end{array}
\end{array}
if w < -0.69999999999999996 or 1.45e7 < w Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in l around inf 100.0%
mul-1-neg100.0%
*-commutative100.0%
distribute-lft-neg-in100.0%
log-rec100.0%
remove-double-div100.0%
Simplified100.0%
div-exp100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in w around inf 100.0%
neg-mul-1100.0%
Simplified100.0%
if -0.69999999999999996 < w < 1.45e7Initial program 98.2%
Taylor expanded in w around 0 97.1%
Final simplification98.4%
(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.0%
exp-neg99.0%
associate-*l/99.0%
*-lft-identity99.0%
Simplified99.0%
add-sqr-sqrt47.5%
sqrt-unprod84.1%
sqr-neg84.1%
sqrt-unprod36.6%
add-sqr-sqrt83.9%
add-sqr-sqrt83.9%
sqrt-unprod83.9%
add-sqr-sqrt36.6%
sqrt-unprod66.7%
sqr-neg66.7%
sqrt-unprod30.1%
add-sqr-sqrt55.0%
pow155.0%
exp-neg55.0%
inv-pow55.0%
pow-prod-up97.6%
metadata-eval97.6%
metadata-eval97.6%
metadata-eval97.6%
Applied egg-rr97.6%
Taylor expanded in l around 0 97.6%
Final simplification97.6%
(FPCore (w l) :precision binary64 (if (<= w 0.048) (* l (- 1.0 w)) (/ (+ (* (+ l 1.0) (+ l 1.0)) -1.0) (+ 1.0 (+ l 1.0)))))
double code(double w, double l) {
double tmp;
if (w <= 0.048) {
tmp = l * (1.0 - w);
} else {
tmp = (((l + 1.0) * (l + 1.0)) + -1.0) / (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.048d0) then
tmp = l * (1.0d0 - w)
else
tmp = (((l + 1.0d0) * (l + 1.0d0)) + (-1.0d0)) / (1.0d0 + (l + 1.0d0))
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 0.048) {
tmp = l * (1.0 - w);
} else {
tmp = (((l + 1.0) * (l + 1.0)) + -1.0) / (1.0 + (l + 1.0));
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 0.048: tmp = l * (1.0 - w) else: tmp = (((l + 1.0) * (l + 1.0)) + -1.0) / (1.0 + (l + 1.0)) return tmp
function code(w, l) tmp = 0.0 if (w <= 0.048) tmp = Float64(l * Float64(1.0 - w)); else tmp = Float64(Float64(Float64(Float64(l + 1.0) * Float64(l + 1.0)) + -1.0) / Float64(1.0 + Float64(l + 1.0))); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.048) tmp = l * (1.0 - w); else tmp = (((l + 1.0) * (l + 1.0)) + -1.0) / (1.0 + (l + 1.0)); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 0.048], N[(l * N[(1.0 - w), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(l + 1.0), $MachinePrecision] * N[(l + 1.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / N[(1.0 + N[(l + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 0.048:\\
\;\;\;\;\ell \cdot \left(1 - w\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\ell + 1\right) \cdot \left(\ell + 1\right) + -1}{1 + \left(\ell + 1\right)}\\
\end{array}
\end{array}
if w < 0.048000000000000001Initial program 99.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
add-sqr-sqrt37.0%
sqrt-unprod81.6%
sqr-neg81.6%
sqrt-unprod44.6%
add-sqr-sqrt81.3%
add-sqr-sqrt81.3%
sqrt-unprod81.3%
add-sqr-sqrt44.6%
sqrt-unprod81.3%
sqr-neg81.3%
sqrt-unprod36.7%
add-sqr-sqrt67.0%
pow167.0%
exp-neg67.0%
inv-pow67.0%
pow-prod-up98.0%
metadata-eval98.0%
metadata-eval98.0%
metadata-eval98.0%
Applied egg-rr98.0%
Taylor expanded in l around 0 98.0%
Taylor expanded in w around 0 74.7%
mul-1-neg74.7%
*-lft-identity74.7%
distribute-rgt-neg-out74.7%
*-commutative74.7%
distribute-rgt-in74.7%
sub-neg74.7%
Simplified74.7%
if 0.048000000000000001 < w Initial program 95.7%
add-sqr-sqrt95.7%
sqrt-unprod95.7%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
sqr-neg0.0%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
pow10.0%
exp-neg0.0%
inv-pow0.0%
pow-prod-up100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
*-un-lft-identity100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod0.0%
add-sqr-sqrt3.1%
Applied egg-rr5.2%
expm1-udef91.7%
flip--93.7%
log1p-udef93.7%
rem-exp-log93.7%
log1p-udef93.7%
rem-exp-log93.7%
+-commutative93.7%
+-commutative93.7%
metadata-eval93.7%
log1p-udef93.7%
rem-exp-log93.7%
+-commutative93.7%
Applied egg-rr93.7%
Final simplification78.1%
(FPCore (w l) :precision binary64 (if (<= w 0.094) (* l (- 1.0 w)) (+ (+ l 1.0) -1.0)))
double code(double w, double l) {
double tmp;
if (w <= 0.094) {
tmp = l * (1.0 - w);
} else {
tmp = (l + 1.0) + -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.094d0) then
tmp = l * (1.0d0 - w)
else
tmp = (l + 1.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 0.094) {
tmp = l * (1.0 - w);
} else {
tmp = (l + 1.0) + -1.0;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 0.094: tmp = l * (1.0 - w) else: tmp = (l + 1.0) + -1.0 return tmp
function code(w, l) tmp = 0.0 if (w <= 0.094) tmp = Float64(l * Float64(1.0 - w)); else tmp = Float64(Float64(l + 1.0) + -1.0); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.094) tmp = l * (1.0 - w); else tmp = (l + 1.0) + -1.0; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 0.094], N[(l * N[(1.0 - w), $MachinePrecision]), $MachinePrecision], N[(N[(l + 1.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 0.094:\\
\;\;\;\;\ell \cdot \left(1 - w\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\ell + 1\right) + -1\\
\end{array}
\end{array}
if w < 0.094Initial program 99.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
add-sqr-sqrt37.0%
sqrt-unprod81.6%
sqr-neg81.6%
sqrt-unprod44.6%
add-sqr-sqrt81.3%
add-sqr-sqrt81.3%
sqrt-unprod81.3%
add-sqr-sqrt44.6%
sqrt-unprod81.3%
sqr-neg81.3%
sqrt-unprod36.7%
add-sqr-sqrt67.0%
pow167.0%
exp-neg67.0%
inv-pow67.0%
pow-prod-up98.0%
metadata-eval98.0%
metadata-eval98.0%
metadata-eval98.0%
Applied egg-rr98.0%
Taylor expanded in l around 0 98.0%
Taylor expanded in w around 0 74.7%
mul-1-neg74.7%
*-lft-identity74.7%
distribute-rgt-neg-out74.7%
*-commutative74.7%
distribute-rgt-in74.7%
sub-neg74.7%
Simplified74.7%
if 0.094 < w Initial program 95.7%
exp-neg95.7%
associate-/r/95.7%
clear-num95.7%
clear-num95.7%
associate-/r/95.7%
exp-neg95.7%
add-sqr-sqrt95.7%
sqrt-unprod95.7%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
sqr-neg0.0%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
pow10.0%
exp-neg0.0%
inv-pow0.0%
pow-prod-up100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Applied egg-rr5.2%
remove-double-div5.2%
expm1-log1p-u5.2%
expm1-udef91.7%
log1p-udef91.7%
rem-exp-log91.7%
+-commutative91.7%
Applied egg-rr91.7%
Final simplification77.7%
(FPCore (w l) :precision binary64 (if (<= w -160.0) (* w (- l)) l))
double code(double w, double l) {
double tmp;
if (w <= -160.0) {
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 <= (-160.0d0)) 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 <= -160.0) {
tmp = w * -l;
} else {
tmp = l;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -160.0: tmp = w * -l else: tmp = l return tmp
function code(w, l) tmp = 0.0 if (w <= -160.0) tmp = Float64(w * Float64(-l)); else tmp = l; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -160.0) tmp = w * -l; else tmp = l; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -160.0], N[(w * (-l)), $MachinePrecision], l]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -160:\\
\;\;\;\;w \cdot \left(-\ell\right)\\
\mathbf{else}:\\
\;\;\;\;\ell\\
\end{array}
\end{array}
if w < -160Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
add-sqr-sqrt0.0%
sqrt-unprod45.5%
sqr-neg45.5%
sqrt-unprod45.5%
add-sqr-sqrt45.5%
add-sqr-sqrt45.5%
sqrt-unprod45.5%
add-sqr-sqrt45.5%
sqrt-unprod45.5%
sqr-neg45.5%
sqrt-unprod0.0%
add-sqr-sqrt0.1%
pow10.1%
exp-neg0.1%
inv-pow0.1%
pow-prod-up98.5%
metadata-eval98.5%
metadata-eval98.5%
metadata-eval98.5%
Applied egg-rr98.5%
Taylor expanded in w around 0 24.4%
mul-1-neg24.4%
unsub-neg24.4%
Simplified24.4%
Taylor expanded in w around inf 24.4%
mul-1-neg24.4%
*-commutative24.4%
distribute-rgt-neg-in24.4%
Simplified24.4%
if -160 < w Initial program 98.6%
Taylor expanded in w around 0 75.3%
Final simplification62.2%
(FPCore (w l) :precision binary64 (* l (- 1.0 w)))
double code(double w, double l) {
return l * (1.0 - w);
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l * (1.0d0 - w)
end function
public static double code(double w, double l) {
return l * (1.0 - w);
}
def code(w, l): return l * (1.0 - w)
function code(w, l) return Float64(l * Float64(1.0 - w)) end
function tmp = code(w, l) tmp = l * (1.0 - w); end
code[w_, l_] := N[(l * N[(1.0 - w), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell \cdot \left(1 - w\right)
\end{array}
Initial program 99.0%
exp-neg99.0%
associate-*l/99.0%
*-lft-identity99.0%
Simplified99.0%
add-sqr-sqrt47.5%
sqrt-unprod84.1%
sqr-neg84.1%
sqrt-unprod36.6%
add-sqr-sqrt83.9%
add-sqr-sqrt83.9%
sqrt-unprod83.9%
add-sqr-sqrt36.6%
sqrt-unprod66.7%
sqr-neg66.7%
sqrt-unprod30.1%
add-sqr-sqrt55.0%
pow155.0%
exp-neg55.0%
inv-pow55.0%
pow-prod-up97.6%
metadata-eval97.6%
metadata-eval97.6%
metadata-eval97.6%
Applied egg-rr97.6%
Taylor expanded in l around 0 97.6%
Taylor expanded in w around 0 61.9%
mul-1-neg61.9%
*-lft-identity61.9%
distribute-rgt-neg-out61.9%
*-commutative61.9%
distribute-rgt-in61.9%
sub-neg61.9%
Simplified61.9%
Final simplification61.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.0%
Taylor expanded in w around 0 56.8%
Final simplification56.8%
herbie shell --seed 2023309
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))