
(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 (let* ((t_0 (sqrt (exp w)))) (/ (/ (pow l (exp w)) (pow (cbrt t_0) 3.0)) t_0)))
double code(double w, double l) {
double t_0 = sqrt(exp(w));
return (pow(l, exp(w)) / pow(cbrt(t_0), 3.0)) / t_0;
}
public static double code(double w, double l) {
double t_0 = Math.sqrt(Math.exp(w));
return (Math.pow(l, Math.exp(w)) / Math.pow(Math.cbrt(t_0), 3.0)) / t_0;
}
function code(w, l) t_0 = sqrt(exp(w)) return Float64(Float64((l ^ exp(w)) / (cbrt(t_0) ^ 3.0)) / t_0) end
code[w_, l_] := Block[{t$95$0 = N[Sqrt[N[Exp[w], $MachinePrecision]], $MachinePrecision]}, N[(N[(N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision] / N[Power[N[Power[t$95$0, 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{e^{w}}\\
\frac{\frac{{\ell}^{\left(e^{w}\right)}}{{\left(\sqrt[3]{t_0}\right)}^{3}}}{t_0}
\end{array}
\end{array}
Initial program 99.7%
*-commutative99.7%
exp-neg99.7%
div-inv99.7%
add-sqr-sqrt99.7%
associate-/r*99.7%
Applied egg-rr99.7%
add-cube-cbrt99.7%
pow399.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (w l) :precision binary64 (let* ((t_0 (sqrt (exp w)))) (/ (/ (pow l (exp w)) t_0) t_0)))
double code(double w, double l) {
double t_0 = sqrt(exp(w));
return (pow(l, exp(w)) / t_0) / t_0;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: t_0
t_0 = sqrt(exp(w))
code = ((l ** exp(w)) / t_0) / t_0
end function
public static double code(double w, double l) {
double t_0 = Math.sqrt(Math.exp(w));
return (Math.pow(l, Math.exp(w)) / t_0) / t_0;
}
def code(w, l): t_0 = math.sqrt(math.exp(w)) return (math.pow(l, math.exp(w)) / t_0) / t_0
function code(w, l) t_0 = sqrt(exp(w)) return Float64(Float64((l ^ exp(w)) / t_0) / t_0) end
function tmp = code(w, l) t_0 = sqrt(exp(w)); tmp = ((l ^ exp(w)) / t_0) / t_0; end
code[w_, l_] := Block[{t$95$0 = N[Sqrt[N[Exp[w], $MachinePrecision]], $MachinePrecision]}, N[(N[(N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{e^{w}}\\
\frac{\frac{{\ell}^{\left(e^{w}\right)}}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 99.7%
*-commutative99.7%
exp-neg99.7%
div-inv99.7%
add-sqr-sqrt99.7%
associate-/r*99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (w l) :precision binary64 (* (pow l (exp w)) (/ (- -1.0) (exp w))))
double code(double w, double l) {
return pow(l, exp(w)) * (-(-1.0) / exp(w));
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = (l ** exp(w)) * (-(-1.0d0) / exp(w))
end function
public static double code(double w, double l) {
return Math.pow(l, Math.exp(w)) * (-(-1.0) / Math.exp(w));
}
def code(w, l): return math.pow(l, math.exp(w)) * (-(-1.0) / math.exp(w))
function code(w, l) return Float64((l ^ exp(w)) * Float64(Float64(-(-1.0)) / exp(w))) end
function tmp = code(w, l) tmp = (l ^ exp(w)) * (-(-1.0) / exp(w)); end
code[w_, l_] := N[(N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision] * N[((--1.0) / N[Exp[w], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\ell}^{\left(e^{w}\right)} \cdot \frac{--1}{e^{w}}
\end{array}
Initial program 99.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
frac-2neg99.7%
div-inv99.7%
Applied egg-rr99.7%
Taylor expanded in w around inf 99.7%
Final simplification99.7%
(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(Float64(-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}
\\
{\ell}^{\left(e^{w}\right)} \cdot e^{-w}
\end{array}
Initial program 99.7%
Final simplification99.7%
(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.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (w l) :precision binary64 (if (or (<= w -0.7) (not (<= w 1000.0))) (exp (- w)) (* l (exp w))))
double code(double w, double l) {
double tmp;
if ((w <= -0.7) || !(w <= 1000.0)) {
tmp = exp(-w);
} else {
tmp = l * exp(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.7d0)) .or. (.not. (w <= 1000.0d0))) then
tmp = exp(-w)
else
tmp = l * exp(w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if ((w <= -0.7) || !(w <= 1000.0)) {
tmp = Math.exp(-w);
} else {
tmp = l * Math.exp(w);
}
return tmp;
}
def code(w, l): tmp = 0 if (w <= -0.7) or not (w <= 1000.0): tmp = math.exp(-w) else: tmp = l * math.exp(w) return tmp
function code(w, l) tmp = 0.0 if ((w <= -0.7) || !(w <= 1000.0)) tmp = exp(Float64(-w)); else tmp = Float64(l * exp(w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if ((w <= -0.7) || ~((w <= 1000.0))) tmp = exp(-w); else tmp = l * exp(w); end tmp_2 = tmp; end
code[w_, l_] := If[Or[LessEqual[w, -0.7], N[Not[LessEqual[w, 1000.0]], $MachinePrecision]], N[Exp[(-w)], $MachinePrecision], N[(l * N[Exp[w], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.7 \lor \neg \left(w \leq 1000\right):\\
\;\;\;\;e^{-w}\\
\mathbf{else}:\\
\;\;\;\;\ell \cdot e^{w}\\
\end{array}
\end{array}
if w < -0.69999999999999996 or 1e3 < w Initial program 100.0%
*-commutative100.0%
exp-neg100.0%
div-inv100.0%
add-sqr-sqrt100.0%
associate-/r*100.0%
Applied egg-rr100.0%
associate-/l/100.0%
pow-to-exp100.0%
add-sqr-sqrt100.0%
div-exp100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in w around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
if -0.69999999999999996 < w < 1e3Initial program 99.5%
Taylor expanded in w around 0 97.2%
expm1-log1p-u93.4%
expm1-udef48.1%
add-sqr-sqrt25.3%
sqrt-unprod48.1%
sqr-neg48.1%
sqrt-unprod22.8%
add-sqr-sqrt48.1%
Applied egg-rr48.1%
expm1-def93.4%
expm1-log1p97.2%
*-commutative97.2%
Simplified97.2%
Final simplification98.4%
(FPCore (w l) :precision binary64 (if (or (<= w -0.72) (not (<= w 640.0))) (exp (- w)) (+ l (* l w))))
double code(double w, double l) {
double tmp;
if ((w <= -0.72) || !(w <= 640.0)) {
tmp = exp(-w);
} else {
tmp = l + (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.72d0)) .or. (.not. (w <= 640.0d0))) then
tmp = exp(-w)
else
tmp = l + (l * w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if ((w <= -0.72) || !(w <= 640.0)) {
tmp = Math.exp(-w);
} else {
tmp = l + (l * w);
}
return tmp;
}
def code(w, l): tmp = 0 if (w <= -0.72) or not (w <= 640.0): tmp = math.exp(-w) else: tmp = l + (l * w) return tmp
function code(w, l) tmp = 0.0 if ((w <= -0.72) || !(w <= 640.0)) tmp = exp(Float64(-w)); else tmp = Float64(l + Float64(l * w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if ((w <= -0.72) || ~((w <= 640.0))) tmp = exp(-w); else tmp = l + (l * w); end tmp_2 = tmp; end
code[w_, l_] := If[Or[LessEqual[w, -0.72], N[Not[LessEqual[w, 640.0]], $MachinePrecision]], N[Exp[(-w)], $MachinePrecision], N[(l + N[(l * w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.72 \lor \neg \left(w \leq 640\right):\\
\;\;\;\;e^{-w}\\
\mathbf{else}:\\
\;\;\;\;\ell + \ell \cdot w\\
\end{array}
\end{array}
if w < -0.71999999999999997 or 640 < w Initial program 100.0%
*-commutative100.0%
exp-neg100.0%
div-inv100.0%
add-sqr-sqrt100.0%
associate-/r*100.0%
Applied egg-rr100.0%
associate-/l/100.0%
pow-to-exp100.0%
add-sqr-sqrt100.0%
div-exp100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in w around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
if -0.71999999999999997 < w < 640Initial program 99.5%
Taylor expanded in w around 0 97.2%
expm1-log1p-u93.4%
expm1-udef48.1%
add-sqr-sqrt25.3%
sqrt-unprod48.1%
sqr-neg48.1%
sqrt-unprod22.8%
add-sqr-sqrt48.1%
Applied egg-rr48.1%
expm1-def93.4%
expm1-log1p97.2%
*-commutative97.2%
Simplified97.2%
Taylor expanded in w around 0 97.2%
*-commutative97.2%
Simplified97.2%
Final simplification98.4%
(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.7%
exp-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
Simplified99.7%
Taylor expanded in w around 0 98.4%
Final simplification98.4%
(FPCore (w l) :precision binary64 (- l (* l w)))
double code(double w, double l) {
return l - (l * w);
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l - (l * w)
end function
public static double code(double w, double l) {
return l - (l * w);
}
def code(w, l): return l - (l * w)
function code(w, l) return Float64(l - Float64(l * w)) end
function tmp = code(w, l) tmp = l - (l * w); end
code[w_, l_] := N[(l - N[(l * w), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell - \ell \cdot w
\end{array}
Initial program 99.7%
Taylor expanded in w around 0 98.4%
Taylor expanded in w around 0 65.8%
+-commutative65.8%
mul-1-neg65.8%
unsub-neg65.8%
*-commutative65.8%
Simplified65.8%
Final simplification65.8%
(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.7%
*-commutative99.7%
exp-neg99.7%
div-inv99.7%
add-sqr-sqrt99.7%
associate-/r*99.7%
Applied egg-rr99.7%
Taylor expanded in w around 0 59.2%
Final simplification59.2%
herbie shell --seed 2023189
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))