
(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 99.8%
Final simplification99.8%
(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.8%
exp-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Final simplification99.8%
(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.8%
exp-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in w around 0 98.8%
Final simplification98.8%
(FPCore (w l) :precision binary64 (if (<= w 0.021) (+ l (- (* l (* w w)) (* w l))) (/ (/ (* l l) l) (+ w 1.0))))
double code(double w, double l) {
double tmp;
if (w <= 0.021) {
tmp = l + ((l * (w * w)) - (w * l));
} else {
tmp = ((l * l) / 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.021d0) then
tmp = l + ((l * (w * w)) - (w * l))
else
tmp = ((l * l) / l) / (w + 1.0d0)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 0.021) {
tmp = l + ((l * (w * w)) - (w * l));
} else {
tmp = ((l * l) / l) / (w + 1.0);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 0.021: tmp = l + ((l * (w * w)) - (w * l)) else: tmp = ((l * l) / l) / (w + 1.0) return tmp
function code(w, l) tmp = 0.0 if (w <= 0.021) tmp = Float64(l + Float64(Float64(l * Float64(w * w)) - Float64(w * l))); else tmp = Float64(Float64(Float64(l * l) / l) / Float64(w + 1.0)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.021) tmp = l + ((l * (w * w)) - (w * l)); else tmp = ((l * l) / l) / (w + 1.0); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 0.021], N[(l + N[(N[(l * N[(w * w), $MachinePrecision]), $MachinePrecision] - N[(w * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(l * l), $MachinePrecision] / l), $MachinePrecision] / N[(w + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 0.021:\\
\;\;\;\;\ell + \left(\ell \cdot \left(w \cdot w\right) - w \cdot \ell\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\ell \cdot \ell}{\ell}}{w + 1}\\
\end{array}
\end{array}
if w < 0.0210000000000000013Initial program 99.8%
*-commutative99.8%
exp-neg99.8%
div-inv99.8%
add-cube-cbrt99.8%
associate-/r*99.8%
cbrt-unprod99.8%
prod-exp99.8%
Applied egg-rr99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in w around 0 66.6%
Taylor expanded in w around 0 66.2%
Taylor expanded in w around 0 88.2%
+-commutative88.2%
mul-1-neg88.2%
unsub-neg88.2%
unpow288.2%
Simplified88.2%
if 0.0210000000000000013 < w Initial program 100.0%
*-commutative100.0%
exp-neg100.0%
div-inv100.0%
add-cube-cbrt100.0%
associate-/r*100.0%
cbrt-unprod100.0%
prod-exp100.0%
Applied egg-rr100.0%
associate-/l/100.0%
Simplified100.0%
Taylor expanded in w around 0 100.0%
Taylor expanded in w around 0 5.2%
Applied egg-rr53.8%
Final simplification84.1%
(FPCore (w l) :precision binary64 (if (<= w -29.0) (+ l (- (* l (* w w)) (* w l))) (/ l (+ (+ w 1.0) (* (* w w) 0.5)))))
double code(double w, double l) {
double tmp;
if (w <= -29.0) {
tmp = l + ((l * (w * w)) - (w * l));
} else {
tmp = l / ((w + 1.0) + ((w * w) * 0.5));
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (w <= (-29.0d0)) then
tmp = l + ((l * (w * w)) - (w * l))
else
tmp = l / ((w + 1.0d0) + ((w * w) * 0.5d0))
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -29.0) {
tmp = l + ((l * (w * w)) - (w * l));
} else {
tmp = l / ((w + 1.0) + ((w * w) * 0.5));
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -29.0: tmp = l + ((l * (w * w)) - (w * l)) else: tmp = l / ((w + 1.0) + ((w * w) * 0.5)) return tmp
function code(w, l) tmp = 0.0 if (w <= -29.0) tmp = Float64(l + Float64(Float64(l * Float64(w * w)) - Float64(w * l))); else tmp = Float64(l / Float64(Float64(w + 1.0) + Float64(Float64(w * w) * 0.5))); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -29.0) tmp = l + ((l * (w * w)) - (w * l)); else tmp = l / ((w + 1.0) + ((w * w) * 0.5)); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -29.0], N[(l + N[(N[(l * N[(w * w), $MachinePrecision]), $MachinePrecision] - N[(w * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(l / N[(N[(w + 1.0), $MachinePrecision] + N[(N[(w * w), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -29:\\
\;\;\;\;\ell + \left(\ell \cdot \left(w \cdot w\right) - w \cdot \ell\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\ell}{\left(w + 1\right) + \left(w \cdot w\right) \cdot 0.5}\\
\end{array}
\end{array}
if w < -29Initial program 100.0%
*-commutative100.0%
exp-neg100.0%
div-inv100.0%
add-cube-cbrt100.0%
associate-/r*100.0%
cbrt-unprod100.0%
prod-exp100.0%
Applied egg-rr100.0%
associate-/l/100.0%
Simplified100.0%
Taylor expanded in w around 0 1.1%
Taylor expanded in w around 0 1.0%
Taylor expanded in w around 0 68.1%
+-commutative68.1%
mul-1-neg68.1%
unsub-neg68.1%
unpow268.1%
Simplified68.1%
if -29 < w Initial program 99.7%
*-commutative99.7%
exp-neg99.7%
div-inv99.7%
add-cube-cbrt99.7%
associate-/r*99.7%
cbrt-unprod99.7%
prod-exp99.7%
Applied egg-rr99.7%
associate-/l/99.7%
Simplified99.7%
Taylor expanded in w around 0 99.0%
associate-+r+99.0%
*-commutative99.0%
unpow299.0%
Simplified99.0%
Taylor expanded in w around 0 92.1%
Final simplification85.2%
(FPCore (w l) :precision binary64 (if (<= w 0.024) (- l (* w l)) (/ (/ (* l l) l) (+ w 1.0))))
double code(double w, double l) {
double tmp;
if (w <= 0.024) {
tmp = l - (w * l);
} else {
tmp = ((l * l) / 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.024d0) then
tmp = l - (w * l)
else
tmp = ((l * l) / l) / (w + 1.0d0)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 0.024) {
tmp = l - (w * l);
} else {
tmp = ((l * l) / l) / (w + 1.0);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 0.024: tmp = l - (w * l) else: tmp = ((l * l) / l) / (w + 1.0) return tmp
function code(w, l) tmp = 0.0 if (w <= 0.024) tmp = Float64(l - Float64(w * l)); else tmp = Float64(Float64(Float64(l * l) / l) / Float64(w + 1.0)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.024) tmp = l - (w * l); else tmp = ((l * l) / l) / (w + 1.0); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 0.024], N[(l - N[(w * l), $MachinePrecision]), $MachinePrecision], N[(N[(N[(l * l), $MachinePrecision] / l), $MachinePrecision] / N[(w + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 0.024:\\
\;\;\;\;\ell - w \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\ell \cdot \ell}{\ell}}{w + 1}\\
\end{array}
\end{array}
if w < 0.024Initial program 99.8%
*-commutative99.8%
exp-neg99.8%
div-inv99.8%
add-cube-cbrt99.8%
associate-/r*99.8%
cbrt-unprod99.8%
prod-exp99.8%
Applied egg-rr99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in w around 0 66.6%
Taylor expanded in w around 0 66.2%
Taylor expanded in w around 0 73.8%
mul-1-neg73.8%
unsub-neg73.8%
Simplified73.8%
if 0.024 < w Initial program 100.0%
*-commutative100.0%
exp-neg100.0%
div-inv100.0%
add-cube-cbrt100.0%
associate-/r*100.0%
cbrt-unprod100.0%
prod-exp100.0%
Applied egg-rr100.0%
associate-/l/100.0%
Simplified100.0%
Taylor expanded in w around 0 100.0%
Taylor expanded in w around 0 5.2%
Applied egg-rr53.8%
Final simplification71.4%
(FPCore (w l) :precision binary64 (if (<= w 0.112) (- l (* w l)) (/ l w)))
double code(double w, double l) {
double tmp;
if (w <= 0.112) {
tmp = l - (w * l);
} else {
tmp = 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.112d0) then
tmp = l - (w * l)
else
tmp = l / w
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 0.112) {
tmp = l - (w * l);
} else {
tmp = l / w;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 0.112: tmp = l - (w * l) else: tmp = l / w return tmp
function code(w, l) tmp = 0.0 if (w <= 0.112) tmp = Float64(l - Float64(w * l)); else tmp = Float64(l / w); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.112) tmp = l - (w * l); else tmp = l / w; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 0.112], N[(l - N[(w * l), $MachinePrecision]), $MachinePrecision], N[(l / w), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 0.112:\\
\;\;\;\;\ell - w \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\frac{\ell}{w}\\
\end{array}
\end{array}
if w < 0.112000000000000002Initial program 99.8%
*-commutative99.8%
exp-neg99.8%
div-inv99.8%
add-cube-cbrt99.8%
associate-/r*99.8%
cbrt-unprod99.8%
prod-exp99.8%
Applied egg-rr99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in w around 0 66.6%
Taylor expanded in w around 0 66.2%
Taylor expanded in w around 0 73.8%
mul-1-neg73.8%
unsub-neg73.8%
Simplified73.8%
if 0.112000000000000002 < w Initial program 100.0%
*-commutative100.0%
exp-neg100.0%
div-inv100.0%
add-cube-cbrt100.0%
associate-/r*100.0%
cbrt-unprod100.0%
prod-exp100.0%
Applied egg-rr100.0%
associate-/l/100.0%
Simplified100.0%
Taylor expanded in w around 0 100.0%
Taylor expanded in w around 0 40.4%
Taylor expanded in w around inf 40.4%
Final simplification69.9%
(FPCore (w l) :precision binary64 (if (<= w -0.42) (- l (* w l)) (/ l (+ w 1.0))))
double code(double w, double l) {
double tmp;
if (w <= -0.42) {
tmp = l - (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.42d0)) then
tmp = l - (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.42) {
tmp = l - (w * l);
} else {
tmp = l / (w + 1.0);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.42: tmp = l - (w * l) else: tmp = l / (w + 1.0) return tmp
function code(w, l) tmp = 0.0 if (w <= -0.42) tmp = Float64(l - Float64(w * 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.42) tmp = l - (w * l); else tmp = l / (w + 1.0); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.42], N[(l - N[(w * l), $MachinePrecision]), $MachinePrecision], N[(l / N[(w + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.42:\\
\;\;\;\;\ell - w \cdot \ell\\
\mathbf{else}:\\
\;\;\;\;\frac{\ell}{w + 1}\\
\end{array}
\end{array}
if w < -0.419999999999999984Initial program 100.0%
*-commutative100.0%
exp-neg100.0%
div-inv100.0%
add-cube-cbrt100.0%
associate-/r*100.0%
cbrt-unprod100.0%
prod-exp100.0%
Applied egg-rr100.0%
associate-/l/100.0%
Simplified100.0%
Taylor expanded in w around 0 1.1%
Taylor expanded in w around 0 1.0%
Taylor expanded in w around 0 23.9%
mul-1-neg23.9%
unsub-neg23.9%
Simplified23.9%
if -0.419999999999999984 < w Initial program 99.7%
*-commutative99.7%
exp-neg99.7%
div-inv99.7%
add-cube-cbrt99.7%
associate-/r*99.7%
cbrt-unprod99.7%
prod-exp99.7%
Applied egg-rr99.7%
associate-/l/99.7%
Simplified99.7%
Taylor expanded in w around 0 99.3%
Taylor expanded in w around 0 88.9%
Final simplification69.9%
(FPCore (w l) :precision binary64 (if (<= w 115000.0) l (/ l w)))
double code(double w, double l) {
double tmp;
if (w <= 115000.0) {
tmp = l;
} else {
tmp = 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 <= 115000.0d0) then
tmp = l
else
tmp = l / w
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 115000.0) {
tmp = l;
} else {
tmp = l / w;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 115000.0: tmp = l else: tmp = l / w return tmp
function code(w, l) tmp = 0.0 if (w <= 115000.0) tmp = l; else tmp = Float64(l / w); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 115000.0) tmp = l; else tmp = l / w; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 115000.0], l, N[(l / w), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 115000:\\
\;\;\;\;\ell\\
\mathbf{else}:\\
\;\;\;\;\frac{\ell}{w}\\
\end{array}
\end{array}
if w < 115000Initial program 99.8%
*-commutative99.8%
exp-neg99.8%
div-inv99.8%
add-cube-cbrt98.4%
associate-/l*98.4%
pow298.4%
Applied egg-rr98.4%
Taylor expanded in w around 0 67.1%
if 115000 < w Initial program 100.0%
*-commutative100.0%
exp-neg100.0%
div-inv100.0%
add-cube-cbrt100.0%
associate-/r*100.0%
cbrt-unprod100.0%
prod-exp100.0%
Applied egg-rr100.0%
associate-/l/100.0%
Simplified100.0%
Taylor expanded in w around 0 100.0%
Taylor expanded in w around 0 40.4%
Taylor expanded in w around inf 40.4%
Final simplification64.0%
(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.8%
*-commutative99.8%
exp-neg99.8%
div-inv99.8%
add-cube-cbrt98.5%
associate-/l*98.6%
pow298.6%
Applied egg-rr98.6%
Taylor expanded in w around 0 59.9%
Final simplification59.9%
herbie shell --seed 2023278
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))