
(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 9 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 (/ (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.5%
exp-neg99.5%
remove-double-neg99.5%
associate-*l/99.5%
*-lft-identity99.5%
remove-double-neg99.5%
Simplified99.5%
Final simplification99.5%
(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(Float64(-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}
\\
\ell \cdot e^{-w}
\end{array}
Initial program 99.5%
Taylor expanded in w around 0 98.0%
Final simplification98.0%
(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.5%
exp-neg99.5%
remove-double-neg99.5%
associate-*l/99.5%
*-lft-identity99.5%
remove-double-neg99.5%
Simplified99.5%
Taylor expanded in w around 0 98.0%
Final simplification98.0%
(FPCore (w l) :precision binary64 (if (<= w 0.145) (+ l (* w (- (* l (* w (+ 0.5 (* w -1.1666666666666667)))) l))) 0.0))
double code(double w, double l) {
double tmp;
if (w <= 0.145) {
tmp = l + (w * ((l * (w * (0.5 + (w * -1.1666666666666667)))) - l));
} else {
tmp = 0.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.145d0) then
tmp = l + (w * ((l * (w * (0.5d0 + (w * (-1.1666666666666667d0))))) - l))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 0.145) {
tmp = l + (w * ((l * (w * (0.5 + (w * -1.1666666666666667)))) - l));
} else {
tmp = 0.0;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 0.145: tmp = l + (w * ((l * (w * (0.5 + (w * -1.1666666666666667)))) - l)) else: tmp = 0.0 return tmp
function code(w, l) tmp = 0.0 if (w <= 0.145) tmp = Float64(l + Float64(w * Float64(Float64(l * Float64(w * Float64(0.5 + Float64(w * -1.1666666666666667)))) - l))); else tmp = 0.0; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.145) tmp = l + (w * ((l * (w * (0.5 + (w * -1.1666666666666667)))) - l)); else tmp = 0.0; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 0.145], N[(l + N[(w * N[(N[(l * N[(w * N[(0.5 + N[(w * -1.1666666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 0.145:\\
\;\;\;\;\ell + w \cdot \left(\ell \cdot \left(w \cdot \left(0.5 + w \cdot -1.1666666666666667\right)\right) - \ell\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < 0.14499999999999999Initial program 99.5%
exp-neg99.5%
remove-double-neg99.5%
associate-*l/99.5%
*-lft-identity99.5%
remove-double-neg99.5%
Simplified99.5%
add-sqr-sqrt31.7%
sqrt-unprod84.3%
sqr-neg84.3%
sqrt-unprod52.6%
add-sqr-sqrt83.5%
add-sqr-sqrt83.5%
sqrt-unprod83.5%
exp-neg83.5%
inv-pow83.5%
add-sqr-sqrt52.6%
sqrt-unprod83.5%
sqr-neg83.5%
sqrt-unprod30.9%
add-sqr-sqrt65.7%
pow165.7%
pow-prod-up97.6%
metadata-eval97.6%
metadata-eval97.6%
metadata-eval97.6%
pow197.6%
add-exp-log92.0%
Applied egg-rr92.0%
Taylor expanded in w around 0 85.6%
+-commutative85.6%
*-commutative85.6%
fma-define85.6%
metadata-eval85.6%
associate-*r*85.6%
*-commutative85.6%
associate-*r*85.6%
add-sqr-sqrt0.0%
sqrt-unprod70.6%
mul-1-neg70.6%
mul-1-neg70.6%
sqr-neg70.6%
sqrt-unprod85.6%
add-sqr-sqrt85.6%
Applied egg-rr85.6%
fma-undefine85.6%
distribute-lft-out85.6%
metadata-eval85.6%
Simplified85.6%
Taylor expanded in l around 0 86.4%
if 0.14499999999999999 < w Initial program 100.0%
Taylor expanded in w around 0 100.0%
Taylor expanded in w around 0 5.3%
Simplified100.0%
Final simplification88.7%
(FPCore (w l) :precision binary64 (if (<= w 0.102) (+ l (* w (- (* w (* l 0.5)) l))) 0.0))
double code(double w, double l) {
double tmp;
if (w <= 0.102) {
tmp = l + (w * ((w * (l * 0.5)) - l));
} else {
tmp = 0.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.102d0) then
tmp = l + (w * ((w * (l * 0.5d0)) - l))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 0.102) {
tmp = l + (w * ((w * (l * 0.5)) - l));
} else {
tmp = 0.0;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 0.102: tmp = l + (w * ((w * (l * 0.5)) - l)) else: tmp = 0.0 return tmp
function code(w, l) tmp = 0.0 if (w <= 0.102) tmp = Float64(l + Float64(w * Float64(Float64(w * Float64(l * 0.5)) - l))); else tmp = 0.0; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.102) tmp = l + (w * ((w * (l * 0.5)) - l)); else tmp = 0.0; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 0.102], N[(l + N[(w * N[(N[(w * N[(l * 0.5), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 0.102:\\
\;\;\;\;\ell + w \cdot \left(w \cdot \left(\ell \cdot 0.5\right) - \ell\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < 0.101999999999999993Initial program 99.5%
exp-neg99.5%
remove-double-neg99.5%
associate-*l/99.5%
*-lft-identity99.5%
remove-double-neg99.5%
Simplified99.5%
add-sqr-sqrt31.7%
sqrt-unprod84.3%
sqr-neg84.3%
sqrt-unprod52.6%
add-sqr-sqrt83.5%
add-sqr-sqrt83.5%
sqrt-unprod83.5%
exp-neg83.5%
inv-pow83.5%
add-sqr-sqrt52.6%
sqrt-unprod83.5%
sqr-neg83.5%
sqrt-unprod30.9%
add-sqr-sqrt65.7%
pow165.7%
pow-prod-up97.6%
metadata-eval97.6%
metadata-eval97.6%
metadata-eval97.6%
pow197.6%
add-exp-log92.0%
Applied egg-rr92.0%
Taylor expanded in w around 0 85.6%
+-commutative85.6%
*-commutative85.6%
fma-define85.6%
metadata-eval85.6%
associate-*r*85.6%
*-commutative85.6%
associate-*r*85.6%
add-sqr-sqrt0.0%
sqrt-unprod70.6%
mul-1-neg70.6%
mul-1-neg70.6%
sqr-neg70.6%
sqrt-unprod85.6%
add-sqr-sqrt85.6%
Applied egg-rr85.6%
fma-undefine85.6%
distribute-lft-out85.6%
metadata-eval85.6%
Simplified85.6%
Taylor expanded in w around 0 81.5%
mul-1-neg81.5%
distribute-rgt-neg-in81.5%
distribute-rgt-out81.5%
metadata-eval81.5%
distribute-rgt-neg-in81.5%
metadata-eval81.5%
Simplified81.5%
if 0.101999999999999993 < w Initial program 100.0%
Taylor expanded in w around 0 100.0%
Taylor expanded in w around 0 5.3%
Simplified100.0%
Final simplification84.6%
(FPCore (w l) :precision binary64 (if (<= w -0.061) (* l (- w)) (if (<= w 0.088) l 0.0)))
double code(double w, double l) {
double tmp;
if (w <= -0.061) {
tmp = l * -w;
} else if (w <= 0.088) {
tmp = l;
} else {
tmp = 0.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.061d0)) then
tmp = l * -w
else if (w <= 0.088d0) then
tmp = l
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -0.061) {
tmp = l * -w;
} else if (w <= 0.088) {
tmp = l;
} else {
tmp = 0.0;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.061: tmp = l * -w elif w <= 0.088: tmp = l else: tmp = 0.0 return tmp
function code(w, l) tmp = 0.0 if (w <= -0.061) tmp = Float64(l * Float64(-w)); elseif (w <= 0.088) tmp = l; else tmp = 0.0; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.061) tmp = l * -w; elseif (w <= 0.088) tmp = l; else tmp = 0.0; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.061], N[(l * (-w)), $MachinePrecision], If[LessEqual[w, 0.088], l, 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.061:\\
\;\;\;\;\ell \cdot \left(-w\right)\\
\mathbf{elif}\;w \leq 0.088:\\
\;\;\;\;\ell\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < -0.060999999999999999Initial program 100.0%
Taylor expanded in w around 0 100.0%
Taylor expanded in w around 0 25.5%
Taylor expanded in w around inf 25.5%
associate-*r*25.5%
neg-mul-125.5%
Simplified25.5%
if -0.060999999999999999 < w < 0.087999999999999995Initial program 99.2%
Taylor expanded in w around 0 96.5%
Taylor expanded in w around 0 96.5%
if 0.087999999999999995 < w Initial program 100.0%
Taylor expanded in w around 0 100.0%
Taylor expanded in w around 0 5.3%
Simplified100.0%
Final simplification78.3%
(FPCore (w l) :precision binary64 (if (<= w 0.17) (* l (- 1.0 w)) 0.0))
double code(double w, double l) {
double tmp;
if (w <= 0.17) {
tmp = l * (1.0 - w);
} else {
tmp = 0.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.17d0) then
tmp = l * (1.0d0 - w)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 0.17) {
tmp = l * (1.0 - w);
} else {
tmp = 0.0;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 0.17: tmp = l * (1.0 - w) else: tmp = 0.0 return tmp
function code(w, l) tmp = 0.0 if (w <= 0.17) tmp = Float64(l * Float64(1.0 - w)); else tmp = 0.0; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.17) tmp = l * (1.0 - w); else tmp = 0.0; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 0.17], N[(l * N[(1.0 - w), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 0.17:\\
\;\;\;\;\ell \cdot \left(1 - w\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < 0.170000000000000012Initial program 99.5%
exp-neg99.5%
remove-double-neg99.5%
associate-*l/99.5%
*-lft-identity99.5%
remove-double-neg99.5%
Simplified99.5%
Taylor expanded in w around 0 97.6%
Taylor expanded in w around 0 73.9%
mul-1-neg73.9%
sub-neg73.9%
*-rgt-identity73.9%
distribute-lft-out--73.9%
Simplified73.9%
if 0.170000000000000012 < w Initial program 100.0%
Taylor expanded in w around 0 100.0%
Taylor expanded in w around 0 5.3%
Simplified100.0%
Final simplification78.3%
(FPCore (w l) :precision binary64 (if (<= w 0.12) l 0.0))
double code(double w, double l) {
double tmp;
if (w <= 0.12) {
tmp = l;
} else {
tmp = 0.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.12d0) then
tmp = l
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 0.12) {
tmp = l;
} else {
tmp = 0.0;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 0.12: tmp = l else: tmp = 0.0 return tmp
function code(w, l) tmp = 0.0 if (w <= 0.12) tmp = l; else tmp = 0.0; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.12) tmp = l; else tmp = 0.0; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 0.12], l, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 0.12:\\
\;\;\;\;\ell\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < 0.12Initial program 99.5%
Taylor expanded in w around 0 97.6%
Taylor expanded in w around 0 67.0%
if 0.12 < w Initial program 100.0%
Taylor expanded in w around 0 100.0%
Taylor expanded in w around 0 5.3%
Simplified100.0%
Final simplification72.6%
(FPCore (w l) :precision binary64 0.0)
double code(double w, double l) {
return 0.0;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
code = 0.0d0
end function
public static double code(double w, double l) {
return 0.0;
}
def code(w, l): return 0.0
function code(w, l) return 0.0 end
function tmp = code(w, l) tmp = 0.0; end
code[w_, l_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 99.5%
Taylor expanded in w around 0 98.0%
Taylor expanded in w around 0 56.7%
Simplified19.5%
Final simplification19.5%
herbie shell --seed 2024080
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))