
(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 5 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 (if (<= l 1.22e-8) (* (- 1.0 w) (pow l (+ 1.0 w))) (* (fma (- (* 0.5 w) 1.0) w 1.0) (pow l (fma (fma 0.5 w 1.0) w 1.0)))))
double code(double w, double l) {
double tmp;
if (l <= 1.22e-8) {
tmp = (1.0 - w) * pow(l, (1.0 + w));
} else {
tmp = fma(((0.5 * w) - 1.0), w, 1.0) * pow(l, fma(fma(0.5, w, 1.0), w, 1.0));
}
return tmp;
}
function code(w, l) tmp = 0.0 if (l <= 1.22e-8) tmp = Float64(Float64(1.0 - w) * (l ^ Float64(1.0 + w))); else tmp = Float64(fma(Float64(Float64(0.5 * w) - 1.0), w, 1.0) * (l ^ fma(fma(0.5, w, 1.0), w, 1.0))); end return tmp end
code[w_, l_] := If[LessEqual[l, 1.22e-8], N[(N[(1.0 - w), $MachinePrecision] * N[Power[l, N[(1.0 + w), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.5 * w), $MachinePrecision] - 1.0), $MachinePrecision] * w + 1.0), $MachinePrecision] * N[Power[l, N[(N[(0.5 * w + 1.0), $MachinePrecision] * w + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.22 \cdot 10^{-8}:\\
\;\;\;\;\left(1 - w\right) \cdot {\ell}^{\left(1 + w\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot w - 1, w, 1\right) \cdot {\ell}^{\left(\mathsf{fma}\left(\mathsf{fma}\left(0.5, w, 1\right), w, 1\right)\right)}\\
\end{array}
\end{array}
if l < 1.22e-8Initial program 99.9%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6475.3
Applied rewrites75.3%
Taylor expanded in w around 0
lower-+.f6499.9
Applied rewrites99.9%
if 1.22e-8 < l Initial program 97.8%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6483.5
Applied rewrites83.5%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6499.4
Applied rewrites99.4%
(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 (if (<= l 1.22e-8) (* (- 1.0 w) (pow l (+ 1.0 w))) (* (- 1.0 w) (pow l (fma (fma 0.5 w 1.0) w 1.0)))))
double code(double w, double l) {
double tmp;
if (l <= 1.22e-8) {
tmp = (1.0 - w) * pow(l, (1.0 + w));
} else {
tmp = (1.0 - w) * pow(l, fma(fma(0.5, w, 1.0), w, 1.0));
}
return tmp;
}
function code(w, l) tmp = 0.0 if (l <= 1.22e-8) tmp = Float64(Float64(1.0 - w) * (l ^ Float64(1.0 + w))); else tmp = Float64(Float64(1.0 - w) * (l ^ fma(fma(0.5, w, 1.0), w, 1.0))); end return tmp end
code[w_, l_] := If[LessEqual[l, 1.22e-8], N[(N[(1.0 - w), $MachinePrecision] * N[Power[l, N[(1.0 + w), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - w), $MachinePrecision] * N[Power[l, N[(N[(0.5 * w + 1.0), $MachinePrecision] * w + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.22 \cdot 10^{-8}:\\
\;\;\;\;\left(1 - w\right) \cdot {\ell}^{\left(1 + w\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - w\right) \cdot {\ell}^{\left(\mathsf{fma}\left(\mathsf{fma}\left(0.5, w, 1\right), w, 1\right)\right)}\\
\end{array}
\end{array}
if l < 1.22e-8Initial program 99.9%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6475.3
Applied rewrites75.3%
Taylor expanded in w around 0
lower-+.f6499.9
Applied rewrites99.9%
if 1.22e-8 < l Initial program 97.8%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6465.4
Applied rewrites65.4%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6497.5
Applied rewrites97.5%
(FPCore (w l) :precision binary64 (* (- 1.0 w) (pow l (+ 1.0 w))))
double code(double w, double l) {
return (1.0 - w) * pow(l, (1.0 + w));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = (1.0d0 - w) * (l ** (1.0d0 + w))
end function
public static double code(double w, double l) {
return (1.0 - w) * Math.pow(l, (1.0 + w));
}
def code(w, l): return (1.0 - w) * math.pow(l, (1.0 + w))
function code(w, l) return Float64(Float64(1.0 - w) * (l ^ Float64(1.0 + w))) end
function tmp = code(w, l) tmp = (1.0 - w) * (l ^ (1.0 + w)); end
code[w_, l_] := N[(N[(1.0 - w), $MachinePrecision] * N[Power[l, N[(1.0 + w), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - w\right) \cdot {\ell}^{\left(1 + w\right)}
\end{array}
Initial program 99.0%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6471.2
Applied rewrites71.2%
Taylor expanded in w around 0
lower-+.f6485.0
Applied rewrites85.0%
(FPCore (w l) :precision binary64 (* (- w) (pow l (+ 1.0 w))))
double code(double w, double l) {
return -w * pow(l, (1.0 + w));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = -w * (l ** (1.0d0 + w))
end function
public static double code(double w, double l) {
return -w * Math.pow(l, (1.0 + w));
}
def code(w, l): return -w * math.pow(l, (1.0 + w))
function code(w, l) return Float64(Float64(-w) * (l ^ Float64(1.0 + w))) end
function tmp = code(w, l) tmp = -w * (l ^ (1.0 + w)); end
code[w_, l_] := N[((-w) * N[Power[l, N[(1.0 + w), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-w\right) \cdot {\ell}^{\left(1 + w\right)}
\end{array}
Initial program 99.0%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6471.2
Applied rewrites71.2%
Taylor expanded in w around 0
lower-+.f6485.0
Applied rewrites85.0%
Taylor expanded in w around inf
Applied rewrites32.7%
herbie shell --seed 2024326
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))