
(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.6%
Final simplification99.6%
(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 (* (exp (- w)) l))
double code(double w, double l) {
return exp(-w) * l;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = exp(-w) * l
end function
public static double code(double w, double l) {
return Math.exp(-w) * l;
}
def code(w, l): return math.exp(-w) * l
function code(w, l) return Float64(exp(Float64(-w)) * l) end
function tmp = code(w, l) tmp = exp(-w) * l; end
code[w_, l_] := N[(N[Exp[(-w)], $MachinePrecision] * l), $MachinePrecision]
\begin{array}{l}
\\
e^{-w} \cdot \ell
\end{array}
Initial program 99.6%
Taylor expanded in w around 0 98.1%
Final simplification98.1%
(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 98.1%
Final simplification98.1%
(FPCore (w l)
:precision binary64
(let* ((t_0 (- l (+ l l))))
(if (<= w 3.2e-40)
(+ (- l (* w l)) (* 0.5 (* l (* w w))))
(/ (+ (* l l) (* (* w w) (* t_0 (- (+ l l) l)))) (+ l (* w t_0))))))
double code(double w, double l) {
double t_0 = l - (l + l);
double tmp;
if (w <= 3.2e-40) {
tmp = (l - (w * l)) + (0.5 * (l * (w * w)));
} else {
tmp = ((l * l) + ((w * w) * (t_0 * ((l + l) - l)))) / (l + (w * t_0));
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: tmp
t_0 = l - (l + l)
if (w <= 3.2d-40) then
tmp = (l - (w * l)) + (0.5d0 * (l * (w * w)))
else
tmp = ((l * l) + ((w * w) * (t_0 * ((l + l) - l)))) / (l + (w * t_0))
end if
code = tmp
end function
public static double code(double w, double l) {
double t_0 = l - (l + l);
double tmp;
if (w <= 3.2e-40) {
tmp = (l - (w * l)) + (0.5 * (l * (w * w)));
} else {
tmp = ((l * l) + ((w * w) * (t_0 * ((l + l) - l)))) / (l + (w * t_0));
}
return tmp;
}
def code(w, l): t_0 = l - (l + l) tmp = 0 if w <= 3.2e-40: tmp = (l - (w * l)) + (0.5 * (l * (w * w))) else: tmp = ((l * l) + ((w * w) * (t_0 * ((l + l) - l)))) / (l + (w * t_0)) return tmp
function code(w, l) t_0 = Float64(l - Float64(l + l)) tmp = 0.0 if (w <= 3.2e-40) tmp = Float64(Float64(l - Float64(w * l)) + Float64(0.5 * Float64(l * Float64(w * w)))); else tmp = Float64(Float64(Float64(l * l) + Float64(Float64(w * w) * Float64(t_0 * Float64(Float64(l + l) - l)))) / Float64(l + Float64(w * t_0))); end return tmp end
function tmp_2 = code(w, l) t_0 = l - (l + l); tmp = 0.0; if (w <= 3.2e-40) tmp = (l - (w * l)) + (0.5 * (l * (w * w))); else tmp = ((l * l) + ((w * w) * (t_0 * ((l + l) - l)))) / (l + (w * t_0)); end tmp_2 = tmp; end
code[w_, l_] := Block[{t$95$0 = N[(l - N[(l + l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, 3.2e-40], N[(N[(l - N[(w * l), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(l * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(l * l), $MachinePrecision] + N[(N[(w * w), $MachinePrecision] * N[(t$95$0 * N[(N[(l + l), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l + N[(w * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \ell - \left(\ell + \ell\right)\\
\mathbf{if}\;w \leq 3.2 \cdot 10^{-40}:\\
\;\;\;\;\left(\ell - w \cdot \ell\right) + 0.5 \cdot \left(\ell \cdot \left(w \cdot w\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\ell \cdot \ell + \left(w \cdot w\right) \cdot \left(t_0 \cdot \left(\left(\ell + \ell\right) - \ell\right)\right)}{\ell + w \cdot t_0}\\
\end{array}
\end{array}
if w < 3.20000000000000002e-40Initial program 99.6%
Taylor expanded in w around 0 97.9%
Taylor expanded in w around 0 86.6%
neg-mul-186.6%
associate-+r+86.6%
sub-neg86.6%
*-commutative86.6%
unpow286.6%
Simplified86.6%
if 3.20000000000000002e-40 < w Initial program 99.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
Taylor expanded in w around 0 98.8%
Taylor expanded in w around 0 10.8%
mul-1-neg10.8%
unsub-neg10.8%
Simplified10.8%
*-un-lft-identity10.8%
prod-diff10.8%
*-commutative10.8%
fma-neg10.8%
*-un-lft-identity10.8%
add-sqr-sqrt0.0%
sqrt-unprod10.3%
sqr-neg10.3%
sqrt-unprod10.8%
add-sqr-sqrt10.8%
*-commutative10.8%
Applied egg-rr10.8%
*-commutative10.8%
fma-udef10.8%
*-commutative10.8%
distribute-lft-out10.8%
Simplified10.8%
associate-+l-10.8%
flip--17.1%
distribute-lft-out--17.1%
distribute-lft-out--17.1%
distribute-lft-out--17.1%
Applied egg-rr17.1%
swap-sqr28.9%
Simplified28.9%
Final simplification76.4%
(FPCore (w l) :precision binary64 (+ (- l (* w l)) (* 0.5 (* l (* w w)))))
double code(double w, double l) {
return (l - (w * l)) + (0.5 * (l * (w * w)));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = (l - (w * l)) + (0.5d0 * (l * (w * w)))
end function
public static double code(double w, double l) {
return (l - (w * l)) + (0.5 * (l * (w * w)));
}
def code(w, l): return (l - (w * l)) + (0.5 * (l * (w * w)))
function code(w, l) return Float64(Float64(l - Float64(w * l)) + Float64(0.5 * Float64(l * Float64(w * w)))) end
function tmp = code(w, l) tmp = (l - (w * l)) + (0.5 * (l * (w * w))); end
code[w_, l_] := N[(N[(l - N[(w * l), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(l * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\ell - w \cdot \ell\right) + 0.5 \cdot \left(\ell \cdot \left(w \cdot w\right)\right)
\end{array}
Initial program 99.6%
Taylor expanded in w around 0 98.1%
Taylor expanded in w around 0 73.1%
neg-mul-173.1%
associate-+r+73.1%
sub-neg73.1%
*-commutative73.1%
unpow273.1%
Simplified73.1%
Final simplification73.1%
(FPCore (w l) :precision binary64 (- l (+ (* w l) (* (* w w) (* l -0.5)))))
double code(double w, double l) {
return l - ((w * l) + ((w * w) * (l * -0.5)));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l - ((w * l) + ((w * w) * (l * (-0.5d0))))
end function
public static double code(double w, double l) {
return l - ((w * l) + ((w * w) * (l * -0.5)));
}
def code(w, l): return l - ((w * l) + ((w * w) * (l * -0.5)))
function code(w, l) return Float64(l - Float64(Float64(w * l) + Float64(Float64(w * w) * Float64(l * -0.5)))) end
function tmp = code(w, l) tmp = l - ((w * l) + ((w * w) * (l * -0.5))); end
code[w_, l_] := N[(l - N[(N[(w * l), $MachinePrecision] + N[(N[(w * w), $MachinePrecision] * N[(l * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell - \left(w \cdot \ell + \left(w \cdot w\right) \cdot \left(\ell \cdot -0.5\right)\right)
\end{array}
Initial program 99.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in w around 0 98.1%
Taylor expanded in w around 0 73.1%
distribute-lft-out73.1%
unpow273.1%
distribute-rgt-out73.1%
metadata-eval73.1%
Simplified73.1%
Final simplification73.1%
(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.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in w around 0 98.1%
Taylor expanded in w around 0 64.2%
mul-1-neg64.2%
unsub-neg64.2%
Simplified64.2%
Taylor expanded in l around 0 64.2%
Final simplification64.2%
(FPCore (w l) :precision binary64 (- (* w l)))
double code(double w, double l) {
return -(w * l);
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = -(w * l)
end function
public static double code(double w, double l) {
return -(w * l);
}
def code(w, l): return -(w * l)
function code(w, l) return Float64(-Float64(w * l)) end
function tmp = code(w, l) tmp = -(w * l); end
code[w_, l_] := (-N[(w * l), $MachinePrecision])
\begin{array}{l}
\\
-w \cdot \ell
\end{array}
Initial program 99.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in w around 0 98.1%
Taylor expanded in w around 0 64.2%
mul-1-neg64.2%
unsub-neg64.2%
Simplified64.2%
Taylor expanded in w around inf 10.1%
neg-mul-110.1%
distribute-rgt-neg-in10.1%
Simplified10.1%
Final simplification10.1%
(FPCore (w l) :precision binary64 (* w l))
double code(double w, double l) {
return w * l;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = w * l
end function
public static double code(double w, double l) {
return w * l;
}
def code(w, l): return w * l
function code(w, l) return Float64(w * l) end
function tmp = code(w, l) tmp = w * l; end
code[w_, l_] := N[(w * l), $MachinePrecision]
\begin{array}{l}
\\
w \cdot \ell
\end{array}
Initial program 99.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in w around 0 98.1%
Taylor expanded in w around 0 64.2%
mul-1-neg64.2%
unsub-neg64.2%
Simplified64.2%
*-un-lft-identity64.2%
prod-diff57.9%
*-commutative57.9%
fma-neg57.9%
*-un-lft-identity57.9%
add-sqr-sqrt29.1%
sqrt-unprod65.3%
sqr-neg65.3%
sqrt-unprod28.9%
add-sqr-sqrt57.3%
*-commutative57.3%
Applied egg-rr57.3%
*-commutative57.3%
fma-udef57.3%
*-commutative57.3%
distribute-lft-out57.3%
Simplified57.3%
Taylor expanded in w around inf 2.9%
*-commutative2.9%
sub-neg2.9%
neg-mul-12.9%
distribute-rgt-out2.9%
metadata-eval2.9%
*-rgt-identity2.9%
Simplified2.9%
Final simplification2.9%
herbie shell --seed 2023292
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))