
(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 7 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
(let* ((t_0 (/ (* (* l w) (log l)) (exp w)))
(t_1 (/ (* (log l) (* w (- l))) (exp w))))
(if (<= w -1.25e+236)
t_1
(if (<= w -5e+195)
t_0
(if (<= w -2e+141)
t_1
(if (<= w -3.7e+112)
t_0
(if (or (<= w -11.2) (not (<= w 0.007)))
t_1
(+ l (* l (* w (+ (log l) -1.0)))))))))))
double code(double w, double l) {
double t_0 = ((l * w) * log(l)) / exp(w);
double t_1 = (log(l) * (w * -l)) / exp(w);
double tmp;
if (w <= -1.25e+236) {
tmp = t_1;
} else if (w <= -5e+195) {
tmp = t_0;
} else if (w <= -2e+141) {
tmp = t_1;
} else if (w <= -3.7e+112) {
tmp = t_0;
} else if ((w <= -11.2) || !(w <= 0.007)) {
tmp = t_1;
} else {
tmp = l + (l * (w * (log(l) + -1.0)));
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((l * w) * log(l)) / exp(w)
t_1 = (log(l) * (w * -l)) / exp(w)
if (w <= (-1.25d+236)) then
tmp = t_1
else if (w <= (-5d+195)) then
tmp = t_0
else if (w <= (-2d+141)) then
tmp = t_1
else if (w <= (-3.7d+112)) then
tmp = t_0
else if ((w <= (-11.2d0)) .or. (.not. (w <= 0.007d0))) then
tmp = t_1
else
tmp = l + (l * (w * (log(l) + (-1.0d0))))
end if
code = tmp
end function
public static double code(double w, double l) {
double t_0 = ((l * w) * Math.log(l)) / Math.exp(w);
double t_1 = (Math.log(l) * (w * -l)) / Math.exp(w);
double tmp;
if (w <= -1.25e+236) {
tmp = t_1;
} else if (w <= -5e+195) {
tmp = t_0;
} else if (w <= -2e+141) {
tmp = t_1;
} else if (w <= -3.7e+112) {
tmp = t_0;
} else if ((w <= -11.2) || !(w <= 0.007)) {
tmp = t_1;
} else {
tmp = l + (l * (w * (Math.log(l) + -1.0)));
}
return tmp;
}
def code(w, l): t_0 = ((l * w) * math.log(l)) / math.exp(w) t_1 = (math.log(l) * (w * -l)) / math.exp(w) tmp = 0 if w <= -1.25e+236: tmp = t_1 elif w <= -5e+195: tmp = t_0 elif w <= -2e+141: tmp = t_1 elif w <= -3.7e+112: tmp = t_0 elif (w <= -11.2) or not (w <= 0.007): tmp = t_1 else: tmp = l + (l * (w * (math.log(l) + -1.0))) return tmp
function code(w, l) t_0 = Float64(Float64(Float64(l * w) * log(l)) / exp(w)) t_1 = Float64(Float64(log(l) * Float64(w * Float64(-l))) / exp(w)) tmp = 0.0 if (w <= -1.25e+236) tmp = t_1; elseif (w <= -5e+195) tmp = t_0; elseif (w <= -2e+141) tmp = t_1; elseif (w <= -3.7e+112) tmp = t_0; elseif ((w <= -11.2) || !(w <= 0.007)) tmp = t_1; else tmp = Float64(l + Float64(l * Float64(w * Float64(log(l) + -1.0)))); end return tmp end
function tmp_2 = code(w, l) t_0 = ((l * w) * log(l)) / exp(w); t_1 = (log(l) * (w * -l)) / exp(w); tmp = 0.0; if (w <= -1.25e+236) tmp = t_1; elseif (w <= -5e+195) tmp = t_0; elseif (w <= -2e+141) tmp = t_1; elseif (w <= -3.7e+112) tmp = t_0; elseif ((w <= -11.2) || ~((w <= 0.007))) tmp = t_1; else tmp = l + (l * (w * (log(l) + -1.0))); end tmp_2 = tmp; end
code[w_, l_] := Block[{t$95$0 = N[(N[(N[(l * w), $MachinePrecision] * N[Log[l], $MachinePrecision]), $MachinePrecision] / N[Exp[w], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Log[l], $MachinePrecision] * N[(w * (-l)), $MachinePrecision]), $MachinePrecision] / N[Exp[w], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, -1.25e+236], t$95$1, If[LessEqual[w, -5e+195], t$95$0, If[LessEqual[w, -2e+141], t$95$1, If[LessEqual[w, -3.7e+112], t$95$0, If[Or[LessEqual[w, -11.2], N[Not[LessEqual[w, 0.007]], $MachinePrecision]], t$95$1, N[(l + N[(l * N[(w * N[(N[Log[l], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(\ell \cdot w\right) \cdot \log \ell}{e^{w}}\\
t_1 := \frac{\log \ell \cdot \left(w \cdot \left(-\ell\right)\right)}{e^{w}}\\
\mathbf{if}\;w \leq -1.25 \cdot 10^{+236}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;w \leq -5 \cdot 10^{+195}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;w \leq -2 \cdot 10^{+141}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;w \leq -3.7 \cdot 10^{+112}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;w \leq -11.2 \lor \neg \left(w \leq 0.007\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\ell + \ell \cdot \left(w \cdot \left(\log \ell + -1\right)\right)\\
\end{array}
\end{array}
if w < -1.24999999999999993e236 or -4.9999999999999998e195 < w < -2.00000000000000003e141 or -3.70000000000000004e112 < w < -11.199999999999999 or 0.00700000000000000015 < w Initial program 98.7%
exp-neg98.7%
remove-double-neg98.7%
associate-*l/98.7%
*-lft-identity98.7%
remove-double-neg98.7%
Simplified98.7%
Taylor expanded in w around 0 46.2%
associate-*r*46.2%
Simplified46.2%
Taylor expanded in w around inf 46.2%
associate-*r*46.2%
*-commutative46.2%
Simplified46.2%
add-sqr-sqrt46.2%
sqrt-unprod36.1%
sqr-neg36.1%
sqrt-unprod0.0%
add-sqr-sqrt76.6%
distribute-lft-neg-out76.6%
distribute-rgt-neg-in76.6%
neg-sub076.6%
Applied egg-rr76.6%
neg-sub076.6%
distribute-rgt-neg-in76.6%
Simplified76.6%
if -1.24999999999999993e236 < w < -4.9999999999999998e195 or -2.00000000000000003e141 < w < -3.70000000000000004e112Initial program 100.0%
exp-neg100.0%
remove-double-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in w around 0 77.8%
associate-*r*77.8%
Simplified77.8%
Taylor expanded in w around inf 77.8%
associate-*r*77.8%
*-commutative77.8%
Simplified77.8%
if -11.199999999999999 < w < 0.00700000000000000015Initial program 99.9%
exp-neg99.9%
remove-double-neg99.9%
associate-*l/99.9%
*-lft-identity99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in w around 0 100.0%
Taylor expanded in l around 0 100.0%
Final simplification90.3%
(FPCore (w l)
:precision binary64
(let* ((t_0 (/ (* (* l w) (log l)) (exp w)))
(t_1 (/ (* (log l) (* w (- l))) (exp w)))
(t_2 (* l (* w (+ (log l) -1.0)))))
(if (<= w -1.3e+236)
(+ l (fabs t_2))
(if (<= w -4e+196)
t_0
(if (<= w -2e+141)
t_1
(if (<= w -1e+111)
t_0
(if (or (<= w -0.25) (not (<= w 0.007))) t_1 (+ l t_2))))))))
double code(double w, double l) {
double t_0 = ((l * w) * log(l)) / exp(w);
double t_1 = (log(l) * (w * -l)) / exp(w);
double t_2 = l * (w * (log(l) + -1.0));
double tmp;
if (w <= -1.3e+236) {
tmp = l + fabs(t_2);
} else if (w <= -4e+196) {
tmp = t_0;
} else if (w <= -2e+141) {
tmp = t_1;
} else if (w <= -1e+111) {
tmp = t_0;
} else if ((w <= -0.25) || !(w <= 0.007)) {
tmp = t_1;
} else {
tmp = l + t_2;
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((l * w) * log(l)) / exp(w)
t_1 = (log(l) * (w * -l)) / exp(w)
t_2 = l * (w * (log(l) + (-1.0d0)))
if (w <= (-1.3d+236)) then
tmp = l + abs(t_2)
else if (w <= (-4d+196)) then
tmp = t_0
else if (w <= (-2d+141)) then
tmp = t_1
else if (w <= (-1d+111)) then
tmp = t_0
else if ((w <= (-0.25d0)) .or. (.not. (w <= 0.007d0))) then
tmp = t_1
else
tmp = l + t_2
end if
code = tmp
end function
public static double code(double w, double l) {
double t_0 = ((l * w) * Math.log(l)) / Math.exp(w);
double t_1 = (Math.log(l) * (w * -l)) / Math.exp(w);
double t_2 = l * (w * (Math.log(l) + -1.0));
double tmp;
if (w <= -1.3e+236) {
tmp = l + Math.abs(t_2);
} else if (w <= -4e+196) {
tmp = t_0;
} else if (w <= -2e+141) {
tmp = t_1;
} else if (w <= -1e+111) {
tmp = t_0;
} else if ((w <= -0.25) || !(w <= 0.007)) {
tmp = t_1;
} else {
tmp = l + t_2;
}
return tmp;
}
def code(w, l): t_0 = ((l * w) * math.log(l)) / math.exp(w) t_1 = (math.log(l) * (w * -l)) / math.exp(w) t_2 = l * (w * (math.log(l) + -1.0)) tmp = 0 if w <= -1.3e+236: tmp = l + math.fabs(t_2) elif w <= -4e+196: tmp = t_0 elif w <= -2e+141: tmp = t_1 elif w <= -1e+111: tmp = t_0 elif (w <= -0.25) or not (w <= 0.007): tmp = t_1 else: tmp = l + t_2 return tmp
function code(w, l) t_0 = Float64(Float64(Float64(l * w) * log(l)) / exp(w)) t_1 = Float64(Float64(log(l) * Float64(w * Float64(-l))) / exp(w)) t_2 = Float64(l * Float64(w * Float64(log(l) + -1.0))) tmp = 0.0 if (w <= -1.3e+236) tmp = Float64(l + abs(t_2)); elseif (w <= -4e+196) tmp = t_0; elseif (w <= -2e+141) tmp = t_1; elseif (w <= -1e+111) tmp = t_0; elseif ((w <= -0.25) || !(w <= 0.007)) tmp = t_1; else tmp = Float64(l + t_2); end return tmp end
function tmp_2 = code(w, l) t_0 = ((l * w) * log(l)) / exp(w); t_1 = (log(l) * (w * -l)) / exp(w); t_2 = l * (w * (log(l) + -1.0)); tmp = 0.0; if (w <= -1.3e+236) tmp = l + abs(t_2); elseif (w <= -4e+196) tmp = t_0; elseif (w <= -2e+141) tmp = t_1; elseif (w <= -1e+111) tmp = t_0; elseif ((w <= -0.25) || ~((w <= 0.007))) tmp = t_1; else tmp = l + t_2; end tmp_2 = tmp; end
code[w_, l_] := Block[{t$95$0 = N[(N[(N[(l * w), $MachinePrecision] * N[Log[l], $MachinePrecision]), $MachinePrecision] / N[Exp[w], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Log[l], $MachinePrecision] * N[(w * (-l)), $MachinePrecision]), $MachinePrecision] / N[Exp[w], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(l * N[(w * N[(N[Log[l], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, -1.3e+236], N[(l + N[Abs[t$95$2], $MachinePrecision]), $MachinePrecision], If[LessEqual[w, -4e+196], t$95$0, If[LessEqual[w, -2e+141], t$95$1, If[LessEqual[w, -1e+111], t$95$0, If[Or[LessEqual[w, -0.25], N[Not[LessEqual[w, 0.007]], $MachinePrecision]], t$95$1, N[(l + t$95$2), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(\ell \cdot w\right) \cdot \log \ell}{e^{w}}\\
t_1 := \frac{\log \ell \cdot \left(w \cdot \left(-\ell\right)\right)}{e^{w}}\\
t_2 := \ell \cdot \left(w \cdot \left(\log \ell + -1\right)\right)\\
\mathbf{if}\;w \leq -1.3 \cdot 10^{+236}:\\
\;\;\;\;\ell + \left|t\_2\right|\\
\mathbf{elif}\;w \leq -4 \cdot 10^{+196}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;w \leq -2 \cdot 10^{+141}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;w \leq -1 \cdot 10^{+111}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;w \leq -0.25 \lor \neg \left(w \leq 0.007\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\ell + t\_2\\
\end{array}
\end{array}
if w < -1.3e236Initial program 100.0%
exp-neg100.0%
remove-double-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in w around 0 1.8%
add-sqr-sqrt1.8%
sqrt-unprod79.9%
pow279.9%
sub-neg79.9%
distribute-rgt-in21.5%
neg-mul-121.5%
*-commutative21.5%
distribute-rgt-in79.9%
distribute-lft-in79.9%
associate-*r*79.9%
*-commutative79.9%
Applied egg-rr79.9%
unpow279.9%
rem-sqrt-square60.6%
associate-*r*64.6%
+-commutative64.6%
Simplified64.6%
if -1.3e236 < w < -3.9999999999999998e196 or -2.00000000000000003e141 < w < -9.99999999999999957e110Initial program 100.0%
exp-neg100.0%
remove-double-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in w around 0 77.8%
associate-*r*77.8%
Simplified77.8%
Taylor expanded in w around inf 77.8%
associate-*r*77.8%
*-commutative77.8%
Simplified77.8%
if -3.9999999999999998e196 < w < -2.00000000000000003e141 or -9.99999999999999957e110 < w < -0.25 or 0.00700000000000000015 < w Initial program 98.3%
exp-neg98.3%
remove-double-neg98.3%
associate-*l/98.3%
*-lft-identity98.3%
remove-double-neg98.3%
Simplified98.3%
Taylor expanded in w around 0 49.4%
associate-*r*49.4%
Simplified49.4%
Taylor expanded in w around inf 49.4%
associate-*r*49.4%
*-commutative49.4%
Simplified49.4%
add-sqr-sqrt49.4%
sqrt-unprod43.3%
sqr-neg43.3%
sqrt-unprod0.0%
add-sqr-sqrt81.8%
distribute-lft-neg-out81.8%
distribute-rgt-neg-in81.8%
neg-sub081.8%
Applied egg-rr81.8%
neg-sub081.8%
distribute-rgt-neg-in81.8%
Simplified81.8%
if -0.25 < w < 0.00700000000000000015Initial program 99.9%
exp-neg99.9%
remove-double-neg99.9%
associate-*l/99.9%
*-lft-identity99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in w around 0 100.0%
Taylor expanded in l around 0 100.0%
Final simplification90.5%
(FPCore (w l) :precision binary64 (if (or (<= w -1.05e+238) (and (not (<= w -1.55e+109)) (<= w 1.0))) (* l (- 1.0 w)) (/ (* (* l w) (log l)) (exp w))))
double code(double w, double l) {
double tmp;
if ((w <= -1.05e+238) || (!(w <= -1.55e+109) && (w <= 1.0))) {
tmp = l * (1.0 - w);
} else {
tmp = ((l * w) * log(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 <= (-1.05d+238)) .or. (.not. (w <= (-1.55d+109))) .and. (w <= 1.0d0)) then
tmp = l * (1.0d0 - w)
else
tmp = ((l * w) * log(l)) / exp(w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if ((w <= -1.05e+238) || (!(w <= -1.55e+109) && (w <= 1.0))) {
tmp = l * (1.0 - w);
} else {
tmp = ((l * w) * Math.log(l)) / Math.exp(w);
}
return tmp;
}
def code(w, l): tmp = 0 if (w <= -1.05e+238) or (not (w <= -1.55e+109) and (w <= 1.0)): tmp = l * (1.0 - w) else: tmp = ((l * w) * math.log(l)) / math.exp(w) return tmp
function code(w, l) tmp = 0.0 if ((w <= -1.05e+238) || (!(w <= -1.55e+109) && (w <= 1.0))) tmp = Float64(l * Float64(1.0 - w)); else tmp = Float64(Float64(Float64(l * w) * log(l)) / exp(w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if ((w <= -1.05e+238) || (~((w <= -1.55e+109)) && (w <= 1.0))) tmp = l * (1.0 - w); else tmp = ((l * w) * log(l)) / exp(w); end tmp_2 = tmp; end
code[w_, l_] := If[Or[LessEqual[w, -1.05e+238], And[N[Not[LessEqual[w, -1.55e+109]], $MachinePrecision], LessEqual[w, 1.0]]], N[(l * N[(1.0 - w), $MachinePrecision]), $MachinePrecision], N[(N[(N[(l * w), $MachinePrecision] * N[Log[l], $MachinePrecision]), $MachinePrecision] / N[Exp[w], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -1.05 \cdot 10^{+238} \lor \neg \left(w \leq -1.55 \cdot 10^{+109}\right) \land w \leq 1:\\
\;\;\;\;\ell \cdot \left(1 - w\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\ell \cdot w\right) \cdot \log \ell}{e^{w}}\\
\end{array}
\end{array}
if w < -1.05000000000000004e238 or -1.54999999999999996e109 < w < 1Initial program 99.9%
exp-neg99.9%
remove-double-neg99.9%
associate-*l/99.9%
*-lft-identity99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in w around 0 74.1%
add-log-exp39.5%
*-commutative39.5%
exp-to-pow39.5%
Applied egg-rr39.5%
Taylor expanded in l around inf 84.1%
neg-mul-184.1%
unsub-neg84.1%
Simplified84.1%
if -1.05000000000000004e238 < w < -1.54999999999999996e109 or 1 < w Initial program 98.1%
exp-neg98.1%
remove-double-neg98.1%
associate-*l/98.1%
*-lft-identity98.1%
remove-double-neg98.1%
Simplified98.1%
Taylor expanded in w around 0 74.2%
associate-*r*74.2%
Simplified74.2%
Taylor expanded in w around inf 74.2%
associate-*r*74.2%
*-commutative74.2%
Simplified74.2%
Final simplification82.0%
(FPCore (w l)
:precision binary64
(if (<= l 1.8e+21)
(/ (+ l (* (* l w) (log l))) (exp w))
(if (<= l 1e+39)
(/ (* (log l) (* w (- l))) (exp w))
(* l (+ 1.0 (* w (- -1.0 (log l))))))))
double code(double w, double l) {
double tmp;
if (l <= 1.8e+21) {
tmp = (l + ((l * w) * log(l))) / exp(w);
} else if (l <= 1e+39) {
tmp = (log(l) * (w * -l)) / exp(w);
} else {
tmp = l * (1.0 + (w * (-1.0 - log(l))));
}
return tmp;
}
real(8) function code(w, l)
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (l <= 1.8d+21) then
tmp = (l + ((l * w) * log(l))) / exp(w)
else if (l <= 1d+39) then
tmp = (log(l) * (w * -l)) / exp(w)
else
tmp = l * (1.0d0 + (w * ((-1.0d0) - log(l))))
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (l <= 1.8e+21) {
tmp = (l + ((l * w) * Math.log(l))) / Math.exp(w);
} else if (l <= 1e+39) {
tmp = (Math.log(l) * (w * -l)) / Math.exp(w);
} else {
tmp = l * (1.0 + (w * (-1.0 - Math.log(l))));
}
return tmp;
}
def code(w, l): tmp = 0 if l <= 1.8e+21: tmp = (l + ((l * w) * math.log(l))) / math.exp(w) elif l <= 1e+39: tmp = (math.log(l) * (w * -l)) / math.exp(w) else: tmp = l * (1.0 + (w * (-1.0 - math.log(l)))) return tmp
function code(w, l) tmp = 0.0 if (l <= 1.8e+21) tmp = Float64(Float64(l + Float64(Float64(l * w) * log(l))) / exp(w)); elseif (l <= 1e+39) tmp = Float64(Float64(log(l) * Float64(w * Float64(-l))) / exp(w)); else tmp = Float64(l * Float64(1.0 + Float64(w * Float64(-1.0 - log(l))))); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (l <= 1.8e+21) tmp = (l + ((l * w) * log(l))) / exp(w); elseif (l <= 1e+39) tmp = (log(l) * (w * -l)) / exp(w); else tmp = l * (1.0 + (w * (-1.0 - log(l)))); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[l, 1.8e+21], N[(N[(l + N[(N[(l * w), $MachinePrecision] * N[Log[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Exp[w], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1e+39], N[(N[(N[Log[l], $MachinePrecision] * N[(w * (-l)), $MachinePrecision]), $MachinePrecision] / N[Exp[w], $MachinePrecision]), $MachinePrecision], N[(l * N[(1.0 + N[(w * N[(-1.0 - N[Log[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.8 \cdot 10^{+21}:\\
\;\;\;\;\frac{\ell + \left(\ell \cdot w\right) \cdot \log \ell}{e^{w}}\\
\mathbf{elif}\;\ell \leq 10^{+39}:\\
\;\;\;\;\frac{\log \ell \cdot \left(w \cdot \left(-\ell\right)\right)}{e^{w}}\\
\mathbf{else}:\\
\;\;\;\;\ell \cdot \left(1 + w \cdot \left(-1 - \log \ell\right)\right)\\
\end{array}
\end{array}
if l < 1.8e21Initial program 99.8%
exp-neg99.8%
remove-double-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
remove-double-neg99.8%
Simplified99.8%
Taylor expanded in w around 0 97.3%
associate-*r*97.3%
Simplified97.3%
if 1.8e21 < l < 9.9999999999999994e38Initial program 90.0%
exp-neg90.0%
remove-double-neg90.0%
associate-*l/90.0%
*-lft-identity90.0%
remove-double-neg90.0%
Simplified90.0%
Taylor expanded in w around 0 20.2%
associate-*r*20.2%
Simplified20.2%
Taylor expanded in w around inf 0.6%
associate-*r*0.6%
*-commutative0.6%
Simplified0.6%
add-sqr-sqrt0.6%
sqrt-unprod0.6%
sqr-neg0.6%
sqrt-unprod0.0%
add-sqr-sqrt71.0%
distribute-lft-neg-out71.0%
distribute-rgt-neg-in71.0%
neg-sub071.0%
Applied egg-rr71.0%
neg-sub071.0%
distribute-rgt-neg-in71.0%
Simplified71.0%
if 9.9999999999999994e38 < l Initial program 100.0%
exp-neg100.0%
remove-double-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in w around 0 60.0%
sub-neg60.0%
distribute-rgt-in60.0%
*-commutative60.0%
associate-*r*60.0%
Applied egg-rr60.0%
add-sqr-sqrt1.9%
sqrt-unprod2.0%
sqr-neg2.0%
sqrt-unprod0.0%
add-sqr-sqrt41.9%
distribute-lft-neg-out41.9%
distribute-rgt-neg-in41.9%
neg-sub041.9%
Applied egg-rr85.0%
neg-sub041.9%
distribute-rgt-neg-in41.9%
Simplified85.0%
Taylor expanded in l around 0 85.0%
distribute-lft-in85.0%
*-rgt-identity85.0%
neg-mul-185.0%
+-commutative85.0%
distribute-lft-in85.0%
mul-1-neg85.0%
distribute-rgt-neg-in85.0%
associate-*r*85.0%
*-commutative85.0%
associate-*r*85.0%
*-commutative85.0%
distribute-rgt-neg-in85.0%
distribute-rgt-in85.0%
fma-define85.0%
distribute-lft-neg-in85.0%
sub-neg85.0%
*-commutative85.0%
Simplified85.0%
Final simplification91.5%
(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 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 59.0%
add-log-exp32.1%
*-commutative32.1%
exp-to-pow32.1%
Applied egg-rr32.1%
Taylor expanded in l around inf 68.4%
neg-mul-168.4%
unsub-neg68.4%
Simplified68.4%
Final simplification68.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 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 59.8%
Final simplification59.8%
herbie shell --seed 2024053
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))