
(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 12 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 (pow l (cbrt (exp (+ w w)))) (cbrt (exp w))) (exp w)))
double code(double w, double l) {
return pow(pow(l, cbrt(exp((w + w)))), cbrt(exp(w))) / exp(w);
}
public static double code(double w, double l) {
return Math.pow(Math.pow(l, Math.cbrt(Math.exp((w + w)))), Math.cbrt(Math.exp(w))) / Math.exp(w);
}
function code(w, l) return Float64(((l ^ cbrt(exp(Float64(w + w)))) ^ cbrt(exp(w))) / exp(w)) end
code[w_, l_] := N[(N[Power[N[Power[l, N[Power[N[Exp[N[(w + w), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision], N[Power[N[Exp[w], $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision] / N[Exp[w], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left({\ell}^{\left(\sqrt[3]{e^{w + w}}\right)}\right)}^{\left(\sqrt[3]{e^{w}}\right)}}{e^{w}}
\end{array}
Initial program 99.0%
exp-neg99.0%
remove-double-neg99.0%
associate-*l/99.0%
*-lft-identity99.0%
remove-double-neg99.0%
Simplified99.0%
Taylor expanded in l around inf 93.9%
add-cube-cbrt93.9%
pow393.9%
Applied egg-rr97.8%
rem-cube-cbrt99.0%
add-cube-cbrt98.9%
pow-unpow98.9%
cbrt-unprod99.0%
prod-exp99.0%
Applied egg-rr99.0%
(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%
(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%
remove-double-neg99.0%
associate-*l/99.0%
*-lft-identity99.0%
remove-double-neg99.0%
Simplified99.0%
(FPCore (w l)
:precision binary64
(if (<= w 0.057)
(+
l
(*
w
(-
(*
w
(+ (* w (- (- (* l 0.5) l) (* l 0.6666666666666666))) (- l (* l 0.5))))
l)))
(sqrt (* l l))))
double code(double w, double l) {
double tmp;
if (w <= 0.057) {
tmp = l + (w * ((w * ((w * (((l * 0.5) - l) - (l * 0.6666666666666666))) + (l - (l * 0.5)))) - l));
} else {
tmp = sqrt((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.057d0) then
tmp = l + (w * ((w * ((w * (((l * 0.5d0) - l) - (l * 0.6666666666666666d0))) + (l - (l * 0.5d0)))) - l))
else
tmp = sqrt((l * l))
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 0.057) {
tmp = l + (w * ((w * ((w * (((l * 0.5) - l) - (l * 0.6666666666666666))) + (l - (l * 0.5)))) - l));
} else {
tmp = Math.sqrt((l * l));
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 0.057: tmp = l + (w * ((w * ((w * (((l * 0.5) - l) - (l * 0.6666666666666666))) + (l - (l * 0.5)))) - l)) else: tmp = math.sqrt((l * l)) return tmp
function code(w, l) tmp = 0.0 if (w <= 0.057) tmp = Float64(l + Float64(w * Float64(Float64(w * Float64(Float64(w * Float64(Float64(Float64(l * 0.5) - l) - Float64(l * 0.6666666666666666))) + Float64(l - Float64(l * 0.5)))) - l))); else tmp = sqrt(Float64(l * l)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.057) tmp = l + (w * ((w * ((w * (((l * 0.5) - l) - (l * 0.6666666666666666))) + (l - (l * 0.5)))) - l)); else tmp = sqrt((l * l)); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 0.057], N[(l + N[(w * N[(N[(w * N[(N[(w * N[(N[(N[(l * 0.5), $MachinePrecision] - l), $MachinePrecision] - N[(l * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(l - N[(l * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(l * l), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 0.057:\\
\;\;\;\;\ell + w \cdot \left(w \cdot \left(w \cdot \left(\left(\ell \cdot 0.5 - \ell\right) - \ell \cdot 0.6666666666666666\right) + \left(\ell - \ell \cdot 0.5\right)\right) - \ell\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\ell \cdot \ell}\\
\end{array}
\end{array}
if w < 0.0570000000000000021Initial program 99.7%
exp-neg99.7%
remove-double-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
remove-double-neg99.7%
Simplified99.7%
Taylor expanded in w around 0 98.5%
Taylor expanded in w around 0 87.0%
*-commutative87.0%
metadata-eval87.0%
distribute-rgt-out87.0%
metadata-eval87.0%
associate-*r*87.0%
*-commutative87.0%
metadata-eval87.0%
distribute-rgt-out87.0%
associate-+l+87.0%
add-sqr-sqrt0.0%
sqrt-unprod71.0%
mul-1-neg71.0%
mul-1-neg71.0%
sqr-neg71.0%
sqrt-unprod87.1%
add-sqr-sqrt87.1%
Applied egg-rr87.1%
*-rgt-identity87.1%
distribute-lft-out87.1%
metadata-eval87.1%
Simplified87.1%
if 0.0570000000000000021 < w Initial program 95.1%
add-sqr-sqrt95.1%
sqrt-unprod95.1%
add-sqr-sqrt0.0%
sqrt-unprod2.4%
sqr-neg2.4%
sqrt-unprod2.4%
add-sqr-sqrt2.4%
pow12.4%
exp-neg2.4%
inv-pow2.4%
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-rr46.1%
Final simplification80.5%
(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(Float64(-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}
\\
\ell \cdot e^{-w}
\end{array}
Initial program 99.0%
Taylor expanded in w around 0 97.6%
Final simplification97.6%
(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%
remove-double-neg99.0%
associate-*l/99.0%
*-lft-identity99.0%
remove-double-neg99.0%
Simplified99.0%
Taylor expanded in w around 0 97.6%
(FPCore (w l)
:precision binary64
(+
l
(*
w
(-
(*
w
(+ (* w (- (- (* l 0.5) l) (* l 0.6666666666666666))) (- l (* l 0.5))))
l))))
double code(double w, double l) {
return l + (w * ((w * ((w * (((l * 0.5) - l) - (l * 0.6666666666666666))) + (l - (l * 0.5)))) - l));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l + (w * ((w * ((w * (((l * 0.5d0) - l) - (l * 0.6666666666666666d0))) + (l - (l * 0.5d0)))) - l))
end function
public static double code(double w, double l) {
return l + (w * ((w * ((w * (((l * 0.5) - l) - (l * 0.6666666666666666))) + (l - (l * 0.5)))) - l));
}
def code(w, l): return l + (w * ((w * ((w * (((l * 0.5) - l) - (l * 0.6666666666666666))) + (l - (l * 0.5)))) - l))
function code(w, l) return Float64(l + Float64(w * Float64(Float64(w * Float64(Float64(w * Float64(Float64(Float64(l * 0.5) - l) - Float64(l * 0.6666666666666666))) + Float64(l - Float64(l * 0.5)))) - l))) end
function tmp = code(w, l) tmp = l + (w * ((w * ((w * (((l * 0.5) - l) - (l * 0.6666666666666666))) + (l - (l * 0.5)))) - l)); end
code[w_, l_] := N[(l + N[(w * N[(N[(w * N[(N[(w * N[(N[(N[(l * 0.5), $MachinePrecision] - l), $MachinePrecision] - N[(l * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(l - N[(l * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell + w \cdot \left(w \cdot \left(w \cdot \left(\left(\ell \cdot 0.5 - \ell\right) - \ell \cdot 0.6666666666666666\right) + \left(\ell - \ell \cdot 0.5\right)\right) - \ell\right)
\end{array}
Initial program 99.0%
exp-neg99.0%
remove-double-neg99.0%
associate-*l/99.0%
*-lft-identity99.0%
remove-double-neg99.0%
Simplified99.0%
Taylor expanded in w around 0 97.6%
Taylor expanded in w around 0 73.5%
*-commutative73.5%
metadata-eval73.5%
distribute-rgt-out73.5%
metadata-eval73.5%
associate-*r*73.5%
*-commutative73.5%
metadata-eval73.5%
distribute-rgt-out73.5%
associate-+l+73.5%
add-sqr-sqrt0.0%
sqrt-unprod60.0%
mul-1-neg60.0%
mul-1-neg60.0%
sqr-neg60.0%
sqrt-unprod73.5%
add-sqr-sqrt73.5%
Applied egg-rr73.5%
*-rgt-identity73.5%
distribute-lft-out73.5%
metadata-eval73.5%
Simplified73.5%
Final simplification73.5%
(FPCore (w l) :precision binary64 (+ l (* w (- (* w (- (- l (* l 0.5)) (* w (* l 0.8333333333333334)))) l))))
double code(double w, double l) {
return l + (w * ((w * ((l - (l * 0.5)) - (w * (l * 0.8333333333333334)))) - l));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l + (w * ((w * ((l - (l * 0.5d0)) - (w * (l * 0.8333333333333334d0)))) - l))
end function
public static double code(double w, double l) {
return l + (w * ((w * ((l - (l * 0.5)) - (w * (l * 0.8333333333333334)))) - l));
}
def code(w, l): return l + (w * ((w * ((l - (l * 0.5)) - (w * (l * 0.8333333333333334)))) - l))
function code(w, l) return Float64(l + Float64(w * Float64(Float64(w * Float64(Float64(l - Float64(l * 0.5)) - Float64(w * Float64(l * 0.8333333333333334)))) - l))) end
function tmp = code(w, l) tmp = l + (w * ((w * ((l - (l * 0.5)) - (w * (l * 0.8333333333333334)))) - l)); end
code[w_, l_] := N[(l + N[(w * N[(N[(w * N[(N[(l - N[(l * 0.5), $MachinePrecision]), $MachinePrecision] - N[(w * N[(l * 0.8333333333333334), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell + w \cdot \left(w \cdot \left(\left(\ell - \ell \cdot 0.5\right) - w \cdot \left(\ell \cdot 0.8333333333333334\right)\right) - \ell\right)
\end{array}
Initial program 99.0%
exp-neg99.0%
remove-double-neg99.0%
associate-*l/99.0%
*-lft-identity99.0%
remove-double-neg99.0%
Simplified99.0%
Taylor expanded in w around 0 97.6%
Taylor expanded in w around 0 73.5%
distribute-rgt-out73.5%
add-sqr-sqrt73.5%
sqrt-unprod55.3%
sqr-neg55.3%
mul-1-neg55.3%
mul-1-neg55.3%
sqrt-unprod0.0%
add-sqr-sqrt73.5%
mul-1-neg73.5%
cancel-sign-sub-inv73.5%
distribute-rgt-out73.5%
metadata-eval73.5%
*-commutative73.5%
distribute-rgt-out73.5%
fma-neg73.5%
*-un-lft-identity73.5%
*-commutative73.5%
*-commutative73.5%
*-un-lft-identity73.5%
distribute-rgt-out73.5%
Applied egg-rr73.5%
fma-undefine73.5%
neg-mul-173.5%
distribute-neg-in73.5%
distribute-lft-out73.5%
distribute-rgt-neg-in73.5%
metadata-eval73.5%
metadata-eval73.5%
Simplified73.5%
Final simplification73.5%
(FPCore (w l) :precision binary64 (- l (* w (+ l (* w (- (* l 0.5) l))))))
double code(double w, double l) {
return l - (w * (l + (w * ((l * 0.5) - l))));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l - (w * (l + (w * ((l * 0.5d0) - l))))
end function
public static double code(double w, double l) {
return l - (w * (l + (w * ((l * 0.5) - l))));
}
def code(w, l): return l - (w * (l + (w * ((l * 0.5) - l))))
function code(w, l) return Float64(l - Float64(w * Float64(l + Float64(w * Float64(Float64(l * 0.5) - l))))) end
function tmp = code(w, l) tmp = l - (w * (l + (w * ((l * 0.5) - l)))); end
code[w_, l_] := N[(l - N[(w * N[(l + N[(w * N[(N[(l * 0.5), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell - w \cdot \left(\ell + w \cdot \left(\ell \cdot 0.5 - \ell\right)\right)
\end{array}
Initial program 99.0%
exp-neg99.0%
remove-double-neg99.0%
associate-*l/99.0%
*-lft-identity99.0%
remove-double-neg99.0%
Simplified99.0%
Taylor expanded in w around 0 97.6%
Taylor expanded in w around 0 69.4%
Final simplification69.4%
(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.0%
exp-neg99.0%
remove-double-neg99.0%
associate-*l/99.0%
*-lft-identity99.0%
remove-double-neg99.0%
Simplified99.0%
Taylor expanded in w around 0 97.6%
Taylor expanded in w around 0 62.4%
mul-1-neg62.4%
*-commutative62.4%
unsub-neg62.4%
*-commutative62.4%
Simplified62.4%
(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 58.0%
(FPCore (w l) :precision binary64 1.0)
double code(double w, double l) {
return 1.0;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = 1.0d0
end function
public static double code(double w, double l) {
return 1.0;
}
def code(w, l): return 1.0
function code(w, l) return 1.0 end
function tmp = code(w, l) tmp = 1.0; end
code[w_, l_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.0%
exp-neg99.0%
associate-/r/98.8%
Applied egg-rr57.8%
add-sqr-sqrt57.5%
associate-/r*57.5%
metadata-eval57.5%
sqrt-div57.7%
remove-double-div57.7%
/-rgt-identity57.7%
/-rgt-identity57.7%
add-exp-log53.7%
add-sqr-sqrt24.9%
sqrt-unprod27.4%
log-rec27.4%
log-rec27.4%
sqr-neg27.4%
sqrt-unprod2.1%
add-sqr-sqrt4.4%
add-exp-log4.4%
Applied egg-rr4.4%
*-inverses4.4%
Simplified4.4%
herbie shell --seed 2024097
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))