
(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 98.9%
Final simplification98.9%
(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 98.9%
exp-neg98.9%
associate-*l/98.9%
*-lft-identity98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (w l) :precision binary64 (/ l (cbrt (exp w))))
double code(double w, double l) {
return l / cbrt(exp(w));
}
public static double code(double w, double l) {
return l / Math.cbrt(Math.exp(w));
}
function code(w, l) return Float64(l / cbrt(exp(w))) end
code[w_, l_] := N[(l / N[Power[N[Exp[w], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\ell}{\sqrt[3]{e^{w}}}
\end{array}
Initial program 98.9%
*-commutative98.9%
exp-neg98.9%
div-inv98.9%
add-cube-cbrt98.9%
associate-/r*98.9%
pow298.9%
Applied egg-rr98.9%
Taylor expanded in w around 0 97.3%
Final simplification97.3%
(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 98.9%
exp-neg98.9%
associate-*l/98.9%
*-lft-identity98.9%
Simplified98.9%
add-sqr-sqrt98.5%
unpow-prod-down98.5%
Applied egg-rr98.5%
pow-sqr98.5%
Simplified98.5%
Taylor expanded in w around 0 97.3%
Final simplification97.3%
(FPCore (w l) :precision binary64 (* (- 1.0 (* w w)) (/ l (+ w 1.0))))
double code(double w, double l) {
return (1.0 - (w * w)) * (l / (w + 1.0));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = (1.0d0 - (w * w)) * (l / (w + 1.0d0))
end function
public static double code(double w, double l) {
return (1.0 - (w * w)) * (l / (w + 1.0));
}
def code(w, l): return (1.0 - (w * w)) * (l / (w + 1.0))
function code(w, l) return Float64(Float64(1.0 - Float64(w * w)) * Float64(l / Float64(w + 1.0))) end
function tmp = code(w, l) tmp = (1.0 - (w * w)) * (l / (w + 1.0)); end
code[w_, l_] := N[(N[(1.0 - N[(w * w), $MachinePrecision]), $MachinePrecision] * N[(l / N[(w + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - w \cdot w\right) \cdot \frac{\ell}{w + 1}
\end{array}
Initial program 98.9%
Taylor expanded in w around 0 58.4%
*-commutative58.4%
mul-1-neg58.4%
+-commutative58.4%
sub-neg58.4%
Simplified58.4%
Taylor expanded in l around 0 58.7%
associate-*r*58.4%
*-commutative58.4%
distribute-lft-out--58.4%
log-pow32.5%
*-rgt-identity32.5%
*-commutative32.5%
Simplified32.5%
Taylor expanded in l around inf 65.4%
neg-mul-165.4%
unsub-neg65.4%
Simplified65.4%
flip--72.7%
associate-*r/74.9%
metadata-eval74.9%
+-commutative74.9%
Applied egg-rr74.9%
associate-/l*72.7%
associate-/r/69.9%
Simplified69.9%
Final simplification69.9%
(FPCore (w l) :precision binary64 (/ l (/ (+ w 1.0) (- 1.0 (* w w)))))
double code(double w, double l) {
return l / ((w + 1.0) / (1.0 - (w * w)));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l / ((w + 1.0d0) / (1.0d0 - (w * w)))
end function
public static double code(double w, double l) {
return l / ((w + 1.0) / (1.0 - (w * w)));
}
def code(w, l): return l / ((w + 1.0) / (1.0 - (w * w)))
function code(w, l) return Float64(l / Float64(Float64(w + 1.0) / Float64(1.0 - Float64(w * w)))) end
function tmp = code(w, l) tmp = l / ((w + 1.0) / (1.0 - (w * w))); end
code[w_, l_] := N[(l / N[(N[(w + 1.0), $MachinePrecision] / N[(1.0 - N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\ell}{\frac{w + 1}{1 - w \cdot w}}
\end{array}
Initial program 98.9%
Taylor expanded in w around 0 58.4%
*-commutative58.4%
mul-1-neg58.4%
+-commutative58.4%
sub-neg58.4%
Simplified58.4%
Taylor expanded in l around 0 58.7%
associate-*r*58.4%
*-commutative58.4%
distribute-lft-out--58.4%
log-pow32.5%
*-rgt-identity32.5%
*-commutative32.5%
Simplified32.5%
Taylor expanded in l around inf 65.4%
neg-mul-165.4%
unsub-neg65.4%
Simplified65.4%
flip--72.7%
associate-*r/74.9%
metadata-eval74.9%
+-commutative74.9%
Applied egg-rr74.9%
associate-/l*72.7%
Simplified72.7%
Final simplification72.7%
(FPCore (w l) :precision binary64 (/ (* l (- 1.0 (* w w))) (+ w 1.0)))
double code(double w, double l) {
return (l * (1.0 - (w * w))) / (w + 1.0);
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = (l * (1.0d0 - (w * w))) / (w + 1.0d0)
end function
public static double code(double w, double l) {
return (l * (1.0 - (w * w))) / (w + 1.0);
}
def code(w, l): return (l * (1.0 - (w * w))) / (w + 1.0)
function code(w, l) return Float64(Float64(l * Float64(1.0 - Float64(w * w))) / Float64(w + 1.0)) end
function tmp = code(w, l) tmp = (l * (1.0 - (w * w))) / (w + 1.0); end
code[w_, l_] := N[(N[(l * N[(1.0 - N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(w + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\ell \cdot \left(1 - w \cdot w\right)}{w + 1}
\end{array}
Initial program 98.9%
Taylor expanded in w around 0 58.4%
*-commutative58.4%
mul-1-neg58.4%
+-commutative58.4%
sub-neg58.4%
Simplified58.4%
Taylor expanded in l around 0 58.7%
associate-*r*58.4%
*-commutative58.4%
distribute-lft-out--58.4%
log-pow32.5%
*-rgt-identity32.5%
*-commutative32.5%
Simplified32.5%
Taylor expanded in l around inf 65.4%
neg-mul-165.4%
unsub-neg65.4%
Simplified65.4%
*-commutative65.4%
flip--72.7%
associate-*l/74.9%
metadata-eval74.9%
+-commutative74.9%
Applied egg-rr74.9%
Final simplification74.9%
(FPCore (w l) :precision binary64 (if (<= w -0.0085) (* w (- l)) l))
double code(double w, double l) {
double tmp;
if (w <= -0.0085) {
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.0085d0)) 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.0085) {
tmp = w * -l;
} else {
tmp = l;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.0085: tmp = w * -l else: tmp = l return tmp
function code(w, l) tmp = 0.0 if (w <= -0.0085) tmp = Float64(w * Float64(-l)); else tmp = l; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.0085) tmp = w * -l; else tmp = l; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.0085], N[(w * (-l)), $MachinePrecision], l]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.0085:\\
\;\;\;\;w \cdot \left(-\ell\right)\\
\mathbf{else}:\\
\;\;\;\;\ell\\
\end{array}
\end{array}
if w < -0.0085000000000000006Initial program 99.7%
Taylor expanded in w around 0 2.0%
*-commutative2.0%
mul-1-neg2.0%
+-commutative2.0%
sub-neg2.0%
Simplified2.0%
Taylor expanded in l around 0 2.0%
associate-*r*2.0%
*-commutative2.0%
distribute-lft-out--2.0%
log-pow1.9%
*-rgt-identity1.9%
*-commutative1.9%
Simplified1.9%
Taylor expanded in l around inf 27.9%
neg-mul-127.9%
unsub-neg27.9%
Simplified27.9%
Taylor expanded in w around inf 27.9%
mul-1-neg27.9%
*-commutative27.9%
distribute-rgt-neg-in27.9%
Simplified27.9%
if -0.0085000000000000006 < w Initial program 98.5%
Taylor expanded in w around 0 79.9%
Final simplification65.7%
(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 98.9%
Taylor expanded in w around 0 58.4%
*-commutative58.4%
mul-1-neg58.4%
+-commutative58.4%
sub-neg58.4%
Simplified58.4%
Taylor expanded in l around 0 58.7%
associate-*r*58.4%
*-commutative58.4%
distribute-lft-out--58.4%
log-pow32.5%
*-rgt-identity32.5%
*-commutative32.5%
Simplified32.5%
Taylor expanded in l around inf 65.4%
neg-mul-165.4%
unsub-neg65.4%
Simplified65.4%
Final simplification65.4%
(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 98.9%
Taylor expanded in w around 0 59.2%
Final simplification59.2%
herbie shell --seed 2023252
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))