
(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 (* (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.4%
(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.4%
Taylor expanded in w around 0
Simplified98.0%
Taylor expanded in w around inf
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6498.0
Simplified98.0%
Final simplification98.0%
(FPCore (w l) :precision binary64 (if (<= w 1.25e-5) (* l (fma w (fma w (fma w -0.16666666666666666 0.5) -1.0) 1.0)) (* w (/ l w))))
double code(double w, double l) {
double tmp;
if (w <= 1.25e-5) {
tmp = l * fma(w, fma(w, fma(w, -0.16666666666666666, 0.5), -1.0), 1.0);
} else {
tmp = w * (l / w);
}
return tmp;
}
function code(w, l) tmp = 0.0 if (w <= 1.25e-5) tmp = Float64(l * fma(w, fma(w, fma(w, -0.16666666666666666, 0.5), -1.0), 1.0)); else tmp = Float64(w * Float64(l / w)); end return tmp end
code[w_, l_] := If[LessEqual[w, 1.25e-5], N[(l * N[(w * N[(w * N[(w * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(w * N[(l / w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 1.25 \cdot 10^{-5}:\\
\;\;\;\;\ell \cdot \mathsf{fma}\left(w, \mathsf{fma}\left(w, \mathsf{fma}\left(w, -0.16666666666666666, 0.5\right), -1\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;w \cdot \frac{\ell}{w}\\
\end{array}
\end{array}
if w < 1.25000000000000006e-5Initial program 99.8%
Taylor expanded in w around 0
Simplified99.0%
Taylor expanded in w around inf
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6499.0
Simplified99.0%
Taylor expanded in w around 0
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6489.8
Simplified89.8%
if 1.25000000000000006e-5 < w Initial program 97.1%
Taylor expanded in w around 0
Simplified92.4%
Taylor expanded in w around 0
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-*.f643.2
Simplified3.2%
Taylor expanded in w around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f643.2
Simplified3.2%
Taylor expanded in w around 0
lower-/.f6447.0
Simplified47.0%
(FPCore (w l) :precision binary64 (if (<= w 9000000.0) (* l (fma w (fma w 0.5 -1.0) 1.0)) (* w (/ l w))))
double code(double w, double l) {
double tmp;
if (w <= 9000000.0) {
tmp = l * fma(w, fma(w, 0.5, -1.0), 1.0);
} else {
tmp = w * (l / w);
}
return tmp;
}
function code(w, l) tmp = 0.0 if (w <= 9000000.0) tmp = Float64(l * fma(w, fma(w, 0.5, -1.0), 1.0)); else tmp = Float64(w * Float64(l / w)); end return tmp end
code[w_, l_] := If[LessEqual[w, 9000000.0], N[(l * N[(w * N[(w * 0.5 + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(w * N[(l / w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 9000000:\\
\;\;\;\;\ell \cdot \mathsf{fma}\left(w, \mathsf{fma}\left(w, 0.5, -1\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;w \cdot \frac{\ell}{w}\\
\end{array}
\end{array}
if w < 9e6Initial program 99.3%
Taylor expanded in w around 0
Simplified97.7%
Taylor expanded in w around inf
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6497.7
Simplified97.7%
Taylor expanded in w around 0
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f6482.2
Simplified82.2%
if 9e6 < w Initial program 100.0%
Taylor expanded in w around 0
Simplified100.0%
Taylor expanded in w around 0
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-*.f643.3
Simplified3.3%
Taylor expanded in w around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f643.3
Simplified3.3%
Taylor expanded in w around 0
lower-/.f6450.6
Simplified50.6%
(FPCore (w l) :precision binary64 (if (<= w 1.25e-5) (- l (* w l)) (* w (/ l w))))
double code(double w, double l) {
double tmp;
if (w <= 1.25e-5) {
tmp = l - (w * 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 <= 1.25d-5) then
tmp = l - (w * l)
else
tmp = w * (l / w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 1.25e-5) {
tmp = l - (w * l);
} else {
tmp = w * (l / w);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 1.25e-5: tmp = l - (w * l) else: tmp = w * (l / w) return tmp
function code(w, l) tmp = 0.0 if (w <= 1.25e-5) tmp = Float64(l - Float64(w * l)); else tmp = Float64(w * Float64(l / w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 1.25e-5) tmp = l - (w * l); else tmp = w * (l / w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 1.25e-5], N[(l - N[(w * l), $MachinePrecision]), $MachinePrecision], N[(w * N[(l / w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 1.25 \cdot 10^{-5}:\\
\;\;\;\;\ell - w \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;w \cdot \frac{\ell}{w}\\
\end{array}
\end{array}
if w < 1.25000000000000006e-5Initial program 99.8%
Taylor expanded in w around 0
Simplified99.0%
Taylor expanded in w around 0
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-*.f6471.8
Simplified71.8%
if 1.25000000000000006e-5 < w Initial program 97.1%
Taylor expanded in w around 0
Simplified92.4%
Taylor expanded in w around 0
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-*.f643.2
Simplified3.2%
Taylor expanded in w around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f643.2
Simplified3.2%
Taylor expanded in w around 0
lower-/.f6447.0
Simplified47.0%
Final simplification68.2%
(FPCore (w l) :precision binary64 (if (<= w -0.39) (- (* w l)) l))
double code(double w, double l) {
double tmp;
if (w <= -0.39) {
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 <= (-0.39d0)) 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 <= -0.39) {
tmp = -(w * l);
} else {
tmp = l;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.39: tmp = -(w * l) else: tmp = l return tmp
function code(w, l) tmp = 0.0 if (w <= -0.39) tmp = Float64(-Float64(w * l)); else tmp = l; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.39) tmp = -(w * l); else tmp = l; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.39], (-N[(w * l), $MachinePrecision]), l]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.39:\\
\;\;\;\;-w \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\ell\\
\end{array}
\end{array}
if w < -0.39000000000000001Initial program 100.0%
Taylor expanded in w around 0
Simplified100.0%
Taylor expanded in w around 0
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-*.f6422.2
Simplified22.2%
Taylor expanded in w around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
neg-mul-1N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f6422.2
Simplified22.2%
if -0.39000000000000001 < w Initial program 99.1%
Taylor expanded in w around 0
Simplified97.2%
Taylor expanded in w around inf
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6497.2
Simplified97.2%
Taylor expanded in w around 0
Simplified78.8%
Final simplification62.0%
(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.4%
Taylor expanded in w around 0
Simplified98.0%
Taylor expanded in w around 0
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-*.f6461.7
Simplified61.7%
Final simplification61.7%
(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.4%
Taylor expanded in w around 0
Simplified98.0%
Taylor expanded in w around inf
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6498.0
Simplified98.0%
Taylor expanded in w around 0
Simplified56.5%
Final simplification56.5%
herbie shell --seed 2024215
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))