
(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 (/ (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.5%
exp-neg98.5%
associate-*l/98.5%
*-lft-identity98.5%
Simplified98.5%
Final simplification98.5%
(FPCore (w l) :precision binary64 (if (<= w -0.7) (exp (- w)) (if (<= w 440000000.0) (* l (- 1.0 (+ w (* w (* w -0.5))))) 0.0)))
double code(double w, double l) {
double tmp;
if (w <= -0.7) {
tmp = exp(-w);
} else if (w <= 440000000.0) {
tmp = l * (1.0 - (w + (w * (w * -0.5))));
} 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.7d0)) then
tmp = exp(-w)
else if (w <= 440000000.0d0) then
tmp = l * (1.0d0 - (w + (w * (w * (-0.5d0)))))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -0.7) {
tmp = Math.exp(-w);
} else if (w <= 440000000.0) {
tmp = l * (1.0 - (w + (w * (w * -0.5))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.7: tmp = math.exp(-w) elif w <= 440000000.0: tmp = l * (1.0 - (w + (w * (w * -0.5)))) else: tmp = 0.0 return tmp
function code(w, l) tmp = 0.0 if (w <= -0.7) tmp = exp(Float64(-w)); elseif (w <= 440000000.0) tmp = Float64(l * Float64(1.0 - Float64(w + Float64(w * Float64(w * -0.5))))); else tmp = 0.0; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.7) tmp = exp(-w); elseif (w <= 440000000.0) tmp = l * (1.0 - (w + (w * (w * -0.5)))); else tmp = 0.0; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.7], N[Exp[(-w)], $MachinePrecision], If[LessEqual[w, 440000000.0], N[(l * N[(1.0 - N[(w + N[(w * N[(w * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.7:\\
\;\;\;\;e^{-w}\\
\mathbf{elif}\;w \leq 440000000:\\
\;\;\;\;\ell \cdot \left(1 - \left(w + w \cdot \left(w \cdot -0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < -0.69999999999999996Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
remove-double-neg100.0%
neg-sub0100.0%
flip--0.0%
sqr-neg0.0%
remove-double-neg0.0%
remove-double-neg0.0%
sub-neg0.0%
flip-+100.0%
+-commutative100.0%
/-rgt-identity100.0%
metadata-eval100.0%
flip3--0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
Applied egg-rr100.0%
div-inv100.0%
rec-exp100.0%
Applied egg-rr100.0%
exp-neg100.0%
*-lft-identity100.0%
exp-neg100.0%
Simplified100.0%
if -0.69999999999999996 < w < 4.4e8Initial program 96.9%
exp-neg96.9%
associate-*l/96.9%
*-lft-identity96.9%
Simplified96.9%
add-cube-cbrt_binary6494.9%
Applied rewrite-once94.9%
Taylor expanded in w around 0 94.4%
Taylor expanded in w around 0 94.5%
distribute-lft-out94.5%
unpow294.5%
distribute-rgt-out94.5%
metadata-eval94.5%
Simplified94.5%
Taylor expanded in l around 0 94.5%
mul-1-neg94.5%
unsub-neg94.5%
*-commutative94.5%
unpow294.5%
associate-*r*94.5%
Simplified94.5%
if 4.4e8 < w Initial program 100.0%
Applied egg-rr100.0%
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.5%
exp-neg98.5%
associate-*l/98.5%
*-lft-identity98.5%
Simplified98.5%
add-cube-cbrt_binary6497.5%
Applied rewrite-once97.5%
Taylor expanded in w around 0 97.2%
Final simplification97.2%
(FPCore (w l) :precision binary64 (if (<= w 440000000.0) (* l (- 1.0 (+ w (* w (* w -0.5))))) 0.0))
double code(double w, double l) {
double tmp;
if (w <= 440000000.0) {
tmp = l * (1.0 - (w + (w * (w * -0.5))));
} 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 <= 440000000.0d0) then
tmp = l * (1.0d0 - (w + (w * (w * (-0.5d0)))))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 440000000.0) {
tmp = l * (1.0 - (w + (w * (w * -0.5))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 440000000.0: tmp = l * (1.0 - (w + (w * (w * -0.5)))) else: tmp = 0.0 return tmp
function code(w, l) tmp = 0.0 if (w <= 440000000.0) tmp = Float64(l * Float64(1.0 - Float64(w + Float64(w * Float64(w * -0.5))))); else tmp = 0.0; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 440000000.0) tmp = l * (1.0 - (w + (w * (w * -0.5)))); else tmp = 0.0; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 440000000.0], N[(l * N[(1.0 - N[(w + N[(w * N[(w * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 440000000:\\
\;\;\;\;\ell \cdot \left(1 - \left(w + w \cdot \left(w \cdot -0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < 4.4e8Initial program 98.1%
exp-neg98.1%
associate-*l/98.1%
*-lft-identity98.1%
Simplified98.1%
add-cube-cbrt_binary6496.9%
Applied rewrite-once96.9%
Taylor expanded in w around 0 96.6%
Taylor expanded in w around 0 83.0%
distribute-lft-out83.0%
unpow283.0%
distribute-rgt-out83.0%
metadata-eval83.0%
Simplified83.0%
Taylor expanded in l around 0 83.0%
mul-1-neg83.0%
unsub-neg83.0%
*-commutative83.0%
unpow283.0%
associate-*r*83.0%
Simplified83.0%
if 4.4e8 < w Initial program 100.0%
Applied egg-rr100.0%
Final simplification86.0%
(FPCore (w l) :precision binary64 (if (<= w -0.74) (* l (- (* w (* w 0.5)) w)) (if (<= w 440000000.0) l 0.0)))
double code(double w, double l) {
double tmp;
if (w <= -0.74) {
tmp = l * ((w * (w * 0.5)) - w);
} else if (w <= 440000000.0) {
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.74d0)) then
tmp = l * ((w * (w * 0.5d0)) - w)
else if (w <= 440000000.0d0) 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.74) {
tmp = l * ((w * (w * 0.5)) - w);
} else if (w <= 440000000.0) {
tmp = l;
} else {
tmp = 0.0;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.74: tmp = l * ((w * (w * 0.5)) - w) elif w <= 440000000.0: tmp = l else: tmp = 0.0 return tmp
function code(w, l) tmp = 0.0 if (w <= -0.74) tmp = Float64(l * Float64(Float64(w * Float64(w * 0.5)) - w)); elseif (w <= 440000000.0) tmp = l; else tmp = 0.0; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.74) tmp = l * ((w * (w * 0.5)) - w); elseif (w <= 440000000.0) tmp = l; else tmp = 0.0; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.74], N[(l * N[(N[(w * N[(w * 0.5), $MachinePrecision]), $MachinePrecision] - w), $MachinePrecision]), $MachinePrecision], If[LessEqual[w, 440000000.0], l, 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.74:\\
\;\;\;\;\ell \cdot \left(w \cdot \left(w \cdot 0.5\right) - w\right)\\
\mathbf{elif}\;w \leq 440000000:\\
\;\;\;\;\ell\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < -0.73999999999999999Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
add-cube-cbrt_binary64100.0%
Applied rewrite-once100.0%
Taylor expanded in w around 0 100.0%
Taylor expanded in w around 0 65.0%
distribute-lft-out65.0%
unpow265.0%
distribute-rgt-out65.0%
metadata-eval65.0%
Simplified65.0%
Taylor expanded in w around inf 65.0%
*-commutative65.0%
unpow265.0%
associate-*r*65.0%
mul-1-neg65.0%
distribute-rgt-neg-out65.0%
unpow265.0%
*-commutative65.0%
distribute-lft-in65.0%
+-commutative65.0%
unsub-neg65.0%
*-commutative65.0%
unpow265.0%
associate-*l*65.0%
Simplified65.0%
if -0.73999999999999999 < w < 4.4e8Initial program 96.9%
Taylor expanded in w around 0 94.5%
if 4.4e8 < w Initial program 100.0%
Applied egg-rr100.0%
Final simplification86.0%
(FPCore (w l) :precision binary64 (if (<= w -0.5) (* l (* w (* w 0.5))) (if (<= w 440000000.0) l 0.0)))
double code(double w, double l) {
double tmp;
if (w <= -0.5) {
tmp = l * (w * (w * 0.5));
} else if (w <= 440000000.0) {
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.5d0)) then
tmp = l * (w * (w * 0.5d0))
else if (w <= 440000000.0d0) 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.5) {
tmp = l * (w * (w * 0.5));
} else if (w <= 440000000.0) {
tmp = l;
} else {
tmp = 0.0;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.5: tmp = l * (w * (w * 0.5)) elif w <= 440000000.0: tmp = l else: tmp = 0.0 return tmp
function code(w, l) tmp = 0.0 if (w <= -0.5) tmp = Float64(l * Float64(w * Float64(w * 0.5))); elseif (w <= 440000000.0) tmp = l; else tmp = 0.0; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.5) tmp = l * (w * (w * 0.5)); elseif (w <= 440000000.0) tmp = l; else tmp = 0.0; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.5], N[(l * N[(w * N[(w * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[w, 440000000.0], l, 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.5:\\
\;\;\;\;\ell \cdot \left(w \cdot \left(w \cdot 0.5\right)\right)\\
\mathbf{elif}\;w \leq 440000000:\\
\;\;\;\;\ell\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < -0.5Initial program 100.0%
exp-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
add-cube-cbrt_binary64100.0%
Applied rewrite-once100.0%
Taylor expanded in w around 0 100.0%
Taylor expanded in w around 0 65.0%
distribute-lft-out65.0%
unpow265.0%
distribute-rgt-out65.0%
metadata-eval65.0%
Simplified65.0%
Taylor expanded in w around inf 65.0%
*-commutative65.0%
unpow265.0%
associate-*r*65.0%
associate-*l*65.0%
Simplified65.0%
if -0.5 < w < 4.4e8Initial program 96.9%
Taylor expanded in w around 0 94.5%
if 4.4e8 < w Initial program 100.0%
Applied egg-rr100.0%
Final simplification86.0%
(FPCore (w l) :precision binary64 (if (<= w 0.215) (- l (* l w)) 0.0))
double code(double w, double l) {
double tmp;
if (w <= 0.215) {
tmp = l - (l * 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.215d0) then
tmp = l - (l * w)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 0.215) {
tmp = l - (l * w);
} else {
tmp = 0.0;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 0.215: tmp = l - (l * w) else: tmp = 0.0 return tmp
function code(w, l) tmp = 0.0 if (w <= 0.215) tmp = Float64(l - Float64(l * w)); else tmp = 0.0; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 0.215) tmp = l - (l * w); else tmp = 0.0; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 0.215], N[(l - N[(l * w), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 0.215:\\
\;\;\;\;\ell - \ell \cdot w\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < 0.214999999999999997Initial program 99.6%
exp-neg99.6%
associate-*l/99.6%
*-lft-identity99.6%
Simplified99.6%
add-cube-cbrt_binary6498.3%
Applied rewrite-once98.3%
Taylor expanded in w around 0 98.0%
Taylor expanded in w around 0 72.5%
mul-1-neg72.5%
unsub-neg72.5%
Simplified72.5%
if 0.214999999999999997 < w Initial program 93.9%
Applied egg-rr94.0%
Final simplification76.6%
(FPCore (w l) :precision binary64 (if (<= w 440000000.0) 1.0 0.0))
double code(double w, double l) {
double tmp;
if (w <= 440000000.0) {
tmp = 1.0;
} 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 <= 440000000.0d0) then
tmp = 1.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= 440000000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 440000000.0: tmp = 1.0 else: tmp = 0.0 return tmp
function code(w, l) tmp = 0.0 if (w <= 440000000.0) tmp = 1.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 440000000.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 440000000.0], 1.0, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 440000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < 4.4e8Initial program 98.1%
exp-neg98.1%
associate-*l/98.1%
*-lft-identity98.1%
Simplified98.1%
remove-double-neg98.1%
neg-sub098.1%
flip--59.1%
sqr-neg59.1%
remove-double-neg59.1%
remove-double-neg59.1%
sub-neg59.1%
flip-+98.1%
+-commutative98.1%
/-rgt-identity98.1%
metadata-eval98.1%
flip3--0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
Applied egg-rr42.6%
Taylor expanded in w around 0 4.8%
if 4.4e8 < w Initial program 100.0%
Applied egg-rr100.0%
Final simplification21.9%
(FPCore (w l) :precision binary64 (if (<= w 440000000.0) l 0.0))
double code(double w, double l) {
double tmp;
if (w <= 440000000.0) {
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 <= 440000000.0d0) 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 <= 440000000.0) {
tmp = l;
} else {
tmp = 0.0;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= 440000000.0: tmp = l else: tmp = 0.0 return tmp
function code(w, l) tmp = 0.0 if (w <= 440000000.0) tmp = l; else tmp = 0.0; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= 440000000.0) tmp = l; else tmp = 0.0; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, 440000000.0], l, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 440000000:\\
\;\;\;\;\ell\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < 4.4e8Initial program 98.1%
Taylor expanded in w around 0 59.1%
if 4.4e8 < w Initial program 100.0%
Applied egg-rr100.0%
Final simplification66.5%
(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 98.5%
Applied egg-rr20.3%
Final simplification20.3%
herbie shell --seed 2023297
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))