
(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 8 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)))
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.7%
exp-neg99.7%
remove-double-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
remove-double-neg99.7%
Simplified99.7%
(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.7%
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.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.1%
(FPCore (w l) :precision binary64 (if (<= w 0.9) (+ l (* l (* w (+ (* w (+ 0.5 (* w -0.16666666666666666))) -1.0)))) (* w (/ l w))))
double code(double w, double l) {
double tmp;
if (w <= 0.9) {
tmp = l + (l * (w * ((w * (0.5 + (w * -0.16666666666666666))) + -1.0)));
} else {
tmp = w * (l / w);
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (w <= 0.9d0) then
tmp = l + (l * (w * ((w * (0.5d0 + (w * (-0.16666666666666666d0)))) + (-1.0d0))))
else
tmp = w * (l / w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 0.9) {
tmp = l + (l * (w * ((w * (0.5 + (w * -0.16666666666666666))) + -1.0)));
} else {
tmp = w * (l / w);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 0.9: tmp = l + (l * (w * ((w * (0.5 + (w * -0.16666666666666666))) + -1.0))) else: tmp = w * (l / w) return tmp
function code(w, l) tmp = 0.0 if (w <= 0.9) tmp = Float64(l + Float64(l * Float64(w * Float64(Float64(w * Float64(0.5 + Float64(w * -0.16666666666666666))) + -1.0)))); else tmp = Float64(w * Float64(l / w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.9) tmp = l + (l * (w * ((w * (0.5 + (w * -0.16666666666666666))) + -1.0))); else tmp = w * (l / w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 0.9], N[(l + N[(l * N[(w * N[(N[(w * N[(0.5 + N[(w * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(w * N[(l / w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 0.9:\\
\;\;\;\;\ell + \ell \cdot \left(w \cdot \left(w \cdot \left(0.5 + w \cdot -0.16666666666666666\right) + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;w \cdot \frac{\ell}{w}\\
\end{array}
\end{array}
if w < 0.900000000000000022Initial program 99.6%
Taylor expanded in w around 0 98.2%
Taylor expanded in w around 0 91.2%
Taylor expanded in l around 0 93.3%
if 0.900000000000000022 < w Initial program 100.0%
Taylor expanded in w around 0 3.5%
neg-mul-13.5%
+-commutative3.5%
sub-neg3.5%
Simplified3.5%
Taylor expanded in w around inf 3.5%
Taylor expanded in w around 0 43.5%
Final simplification85.7%
(FPCore (w l) :precision binary64 (if (<= w 11500.0) (+ l (* l (* w (+ (* w 0.5) -1.0)))) (* w (/ l w))))
double code(double w, double l) {
double tmp;
if (w <= 11500.0) {
tmp = l + (l * (w * ((w * 0.5) + -1.0)));
} else {
tmp = w * (l / w);
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (w <= 11500.0d0) then
tmp = l + (l * (w * ((w * 0.5d0) + (-1.0d0))))
else
tmp = w * (l / w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 11500.0) {
tmp = l + (l * (w * ((w * 0.5) + -1.0)));
} else {
tmp = w * (l / w);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 11500.0: tmp = l + (l * (w * ((w * 0.5) + -1.0))) else: tmp = w * (l / w) return tmp
function code(w, l) tmp = 0.0 if (w <= 11500.0) tmp = Float64(l + Float64(l * Float64(w * Float64(Float64(w * 0.5) + -1.0)))); else tmp = Float64(w * Float64(l / w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 11500.0) tmp = l + (l * (w * ((w * 0.5) + -1.0))); else tmp = w * (l / w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 11500.0], N[(l + N[(l * N[(w * N[(N[(w * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(w * N[(l / w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 11500:\\
\;\;\;\;\ell + \ell \cdot \left(w \cdot \left(w \cdot 0.5 + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;w \cdot \frac{\ell}{w}\\
\end{array}
\end{array}
if w < 11500Initial program 99.6%
Taylor expanded in w around 0 97.8%
Taylor expanded in w around 0 90.8%
Taylor expanded in l around 0 92.9%
Taylor expanded in w around 0 88.2%
*-commutative88.2%
Simplified88.2%
if 11500 < w Initial program 100.0%
Taylor expanded in w around 0 3.4%
neg-mul-13.4%
+-commutative3.4%
sub-neg3.4%
Simplified3.4%
Taylor expanded in w around inf 3.4%
Taylor expanded in w around 0 44.5%
Final simplification81.7%
(FPCore (w l) :precision binary64 (if (<= w 1.0) (- l (* l w)) (* w (/ l w))))
double code(double w, double l) {
double tmp;
if (w <= 1.0) {
tmp = l - (l * w);
} else {
tmp = w * (l / w);
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (w <= 1.0d0) then
tmp = l - (l * w)
else
tmp = w * (l / w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 1.0) {
tmp = l - (l * w);
} else {
tmp = w * (l / w);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 1.0: tmp = l - (l * w) else: tmp = w * (l / w) return tmp
function code(w, l) tmp = 0.0 if (w <= 1.0) tmp = Float64(l - Float64(l * w)); else tmp = Float64(w * Float64(l / w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 1.0) tmp = l - (l * w); else tmp = w * (l / w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 1.0], N[(l - N[(l * w), $MachinePrecision]), $MachinePrecision], N[(w * N[(l / w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 1:\\
\;\;\;\;\ell - \ell \cdot w\\
\mathbf{else}:\\
\;\;\;\;w \cdot \frac{\ell}{w}\\
\end{array}
\end{array}
if w < 1Initial program 99.6%
Taylor expanded in w around 0 98.2%
Taylor expanded in w around 0 76.2%
mul-1-neg76.2%
unsub-neg76.2%
Simplified76.2%
if 1 < w Initial program 100.0%
Taylor expanded in w around 0 3.5%
neg-mul-13.5%
+-commutative3.5%
sub-neg3.5%
Simplified3.5%
Taylor expanded in w around inf 3.5%
Taylor expanded in w around 0 43.5%
(FPCore (w l) :precision binary64 (if (<= w 1e-16) l (* w (/ l w))))
double code(double w, double l) {
double tmp;
if (w <= 1e-16) {
tmp = l;
} else {
tmp = w * (l / w);
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (w <= 1d-16) then
tmp = l
else
tmp = w * (l / w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 1e-16) {
tmp = l;
} else {
tmp = w * (l / w);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 1e-16: tmp = l else: tmp = w * (l / w) return tmp
function code(w, l) tmp = 0.0 if (w <= 1e-16) tmp = l; else tmp = Float64(w * Float64(l / w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 1e-16) tmp = l; else tmp = w * (l / w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 1e-16], l, N[(w * N[(l / w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 10^{-16}:\\
\;\;\;\;\ell\\
\mathbf{else}:\\
\;\;\;\;w \cdot \frac{\ell}{w}\\
\end{array}
\end{array}
if w < 9.9999999999999998e-17Initial program 99.8%
Taylor expanded in w around 0 99.4%
Taylor expanded in w around 0 67.3%
if 9.9999999999999998e-17 < w Initial program 99.0%
Taylor expanded in w around 0 7.5%
neg-mul-17.5%
+-commutative7.5%
sub-neg7.5%
Simplified7.5%
Taylor expanded in w around inf 7.5%
Taylor expanded in w around 0 42.5%
(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.7%
Taylor expanded in w around 0 98.1%
Taylor expanded in w around 0 57.4%
herbie shell --seed 2024089
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))