
(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.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 (/ 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 97.4%
Final simplification97.4%
(FPCore (w l) :precision binary64 (if (<= w 1.25e-5) (- l (* w l)) (/ 1.0 (+ (/ w l) (/ 1.0 l)))))
double code(double w, double l) {
double tmp;
if (w <= 1.25e-5) {
tmp = l - (w * l);
} else {
tmp = 1.0 / ((w / l) + (1.0 / l));
}
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 = 1.0d0 / ((w / l) + (1.0d0 / l))
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 = 1.0 / ((w / l) + (1.0 / l));
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 1.25e-5: tmp = l - (w * l) else: tmp = 1.0 / ((w / l) + (1.0 / l)) return tmp
function code(w, l) tmp = 0.0 if (w <= 1.25e-5) tmp = Float64(l - Float64(w * l)); else tmp = Float64(1.0 / Float64(Float64(w / l) + Float64(1.0 / l))); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 1.25e-5) tmp = l - (w * l); else tmp = 1.0 / ((w / l) + (1.0 / l)); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 1.25e-5], N[(l - N[(w * l), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(w / l), $MachinePrecision] + N[(1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 1.25 \cdot 10^{-5}:\\
\;\;\;\;\ell - w \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{w}{\ell} + \frac{1}{\ell}}\\
\end{array}
\end{array}
if w < 1.25000000000000006e-5Initial program 99.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in w around 0 98.0%
Taylor expanded in w around 0 70.9%
+-commutative70.9%
mul-1-neg70.9%
unsub-neg70.9%
Simplified70.9%
if 1.25000000000000006e-5 < w Initial program 99.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in w around 0 94.9%
clear-num94.9%
inv-pow94.9%
Applied egg-rr94.9%
unpow-194.9%
Simplified94.9%
Taylor expanded in w around 0 50.1%
Final simplification66.7%
(FPCore (w l) :precision binary64 (if (<= w -0.4) (* w (- l)) (* l (+ w 1.0))))
double code(double w, double l) {
double tmp;
if (w <= -0.4) {
tmp = w * -l;
} else {
tmp = l * (w + 1.0);
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (w <= (-0.4d0)) then
tmp = w * -l
else
tmp = l * (w + 1.0d0)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -0.4) {
tmp = w * -l;
} else {
tmp = l * (w + 1.0);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.4: tmp = w * -l else: tmp = l * (w + 1.0) return tmp
function code(w, l) tmp = 0.0 if (w <= -0.4) tmp = Float64(w * Float64(-l)); else tmp = Float64(l * Float64(w + 1.0)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.4) tmp = w * -l; else tmp = l * (w + 1.0); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.4], N[(w * (-l)), $MachinePrecision], N[(l * N[(w + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.4:\\
\;\;\;\;w \cdot \left(-\ell\right)\\
\mathbf{else}:\\
\;\;\;\;\ell \cdot \left(w + 1\right)\\
\end{array}
\end{array}
if w < -0.40000000000000002Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in w around 0 98.7%
Taylor expanded in w around 0 23.9%
+-commutative23.9%
mul-1-neg23.9%
unsub-neg23.9%
Simplified23.9%
Taylor expanded in w around inf 23.9%
associate-*r*23.9%
neg-mul-123.9%
Simplified23.9%
if -0.40000000000000002 < w Initial program 99.5%
exp-neg99.5%
associate-*l/99.5%
*-lft-identity99.5%
Simplified99.5%
Taylor expanded in w around 0 96.8%
Taylor expanded in w around 0 70.8%
+-commutative70.8%
mul-1-neg70.8%
unsub-neg70.8%
Simplified70.8%
cancel-sign-sub-inv70.8%
distribute-lft-neg-in70.8%
*-commutative70.8%
distribute-lft-neg-in70.8%
add-sqr-sqrt33.1%
sqrt-unprod70.7%
sqr-neg70.7%
sqrt-unprod37.7%
add-sqr-sqrt70.8%
distribute-rgt1-in70.8%
Applied egg-rr70.8%
Final simplification57.3%
(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.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
Taylor expanded in w around 0 97.4%
Taylor expanded in w around 0 57.2%
+-commutative57.2%
mul-1-neg57.2%
unsub-neg57.2%
Simplified57.2%
Final simplification57.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(w * Float64(-l)) end
function tmp = code(w, l) tmp = w * -l; end
code[w_, l_] := N[(w * (-l)), $MachinePrecision]
\begin{array}{l}
\\
w \cdot \left(-\ell\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 97.4%
Taylor expanded in w around 0 57.2%
+-commutative57.2%
mul-1-neg57.2%
unsub-neg57.2%
Simplified57.2%
Taylor expanded in w around inf 9.8%
associate-*r*9.8%
neg-mul-19.8%
Simplified9.8%
Final simplification9.8%
(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 97.4%
Taylor expanded in w around 0 57.2%
+-commutative57.2%
mul-1-neg57.2%
unsub-neg57.2%
Simplified57.2%
cancel-sign-sub-inv57.2%
distribute-lft-neg-in57.2%
distribute-rgt-neg-in57.2%
add-sqr-sqrt30.4%
sqrt-unprod66.5%
sqr-neg66.5%
sqrt-unprod26.8%
add-sqr-sqrt50.5%
log1p-expm1-u27.9%
Applied egg-rr27.9%
Taylor expanded in w around inf 3.1%
Final simplification3.1%
herbie shell --seed 2023243
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))