Domain: Machine Learning & Artificial Intelligence

Output exactly one decimal number with exactly four digits after the decimal point.

Fixed data ($m=2$):
- $x^{(1)}=[1,0]^T,\ y^{(1)}=1$
- $x^{(2)}=[0,1]^T,\ y^{(2)}=0$

Fixed model:
- $b=0,\ w=[2,-2]^T$
- $\sigma(z)=\frac{1}{1+e^{-z}}$
- $z^{(i)}=w^T x^{(i)},\ \hat y^{(i)}=\sigma(z^{(i)})$

For any $\lambda>0$ define
$$
J_{\text{base},\lambda}(w)=\frac{1}{2}\sum_{i=1}^{2}\Big[-y^{(i)}\ln(\hat y^{(i)})-(1-y^{(i)})\ln(1-\hat y^{(i)})\Big]+\frac{\lambda}{2}\|w\|_2^2.
$$
Let $J_{0.1}=J_{\text{base},0.1}(w)$ and $J_{1.0}=J_{\text{base},1.0}(w)$.

Conventions: $\lfloor\cdot\rfloor$ is floor. For integers, $a\bmod M$ is the unique integer in $\{0,1,\dots,M-1\}$ congruent to $a$ modulo $M$. For nonnegative integers, $x>>k=\lfloor x/2^k\rfloor$ and $x\ \text{xor}\ y$ is bitwise XOR.

Set $\epsilon=10^{-12}$.

Define
$$
t=\frac{1}{2}\sum_{i=1}^{2}\Big[-y^{(i)}\ln(\hat y^{(i)})-(1-y^{(i)})\ln(1-\hat y^{(i)})\Big],
\quad
s=\hat y^{(1)}(1-\hat y^{(1)}),
\quad
\mu=0.1+\frac{s}{2}.
$$
Define the $2\times 2$ matrix $H=\mu I_2$ and $g=\left[\ 0.2-\frac{1}{2(1+e^2)},\ -0.2+\frac{1}{2(1+e^2)}\ \right]^T$.
Define $\gamma=1/\|w\|_2$, $R=\max_i\|x^{(i)}\|_2$, and $C=R\|w\|_2/\sqrt{2}$.
Define $\mathrm{tr}(H)=2\mu$ and $\det(H)=\mu^2$.

Define $\Delta=0$ and $\Omega=0$.

Define $w_\infty^\star=0$ and $L_\infty=\|w_\infty^\star\|_2^2$.
Define $\sigma^2>0$ by $1/\sigma^2=0.1$.

Define bits $b_0,\dots,b_{23}\in\{0,1\}$:
- $b_0=1$ iff $|\Delta|\le\epsilon$
- $b_1=1$ iff $\Omega\le\epsilon$
- $b_2=1$ iff $\mu\ge 0$
- $b_3=1$ iff $\|g\|_2>0$
- $b_4=1$ iff $|\gamma-1/\sqrt{8}|\le\epsilon$
- $b_5=1$ iff $J_{0.1}<J_{1.0}$
- $b_6=1$ iff $L_\infty\le\epsilon$
- $b_7=1$ iff $|0.1-1/\sigma^2|\le\epsilon$
- $b_8=1$ iff $\lfloor 10C\rfloor\bmod 2=1$
- $b_9=1$ iff $\lfloor 1000t\rfloor\bmod 2=1$
- $b_{10}=1$ iff $\mathrm{tr}(H)>0.304$
- $b_{11}=1$ iff $\det(H)\ge 0.0225$
- $b_{12}=1$ iff $\lfloor 10^6(\hat y^{(1)}-0.88)\rfloor\bmod 2=1$
- $b_{13}=1$ iff $\lfloor 10^6(\mu-0.15)\rfloor\bmod 2=1$
- $b_{14}=1$ iff $(\lfloor 10^4 t\rfloor\bmod 3)=0$
- $b_{15}=1$ iff $(\lfloor 10^6\det(H)\rfloor\bmod 7)\in\{0,3,5\}$
- $b_{16}=1$ iff $(\lfloor 10^6(\hat y^{(2)}-0.11)\rfloor\bmod 2)=1$
- $b_{17}=1$ iff $\lfloor 10^{12}(\hat y^{(1)}+\hat y^{(2)}-1)\rfloor=0$
- $b_{18}=1$ iff $\lfloor 10^{12}(\mu^2-\det(H))\rfloor=0$
- $b_{19}=1$ iff $\lfloor 10^5(J_{0.1}-t)\rfloor=40000$
- $b_{20}=1$ iff $\lfloor 10^{12}(C-2)\rfloor=0$
- $b_{21}=1$ iff $(\lfloor 10^6(\hat y^{(1)}-0.5)\rfloor\bmod 3)=1$
- $b_{22}=1$ iff $(\lfloor 10^6(\hat y^{(2)}-0.1)\rfloor\bmod 5)\in\{2,4\}$
- $b_{23}=1$ iff $(\lfloor 10^6(t-0.12)\rfloor\bmod 7)\in\{1,2,4\}$

Pack
$$
P=\sum_{k=0}^{23} b_k 2^k.
$$
Define Gray and bit-reverse:
$$
G=P\ \text{xor}\ (P>>1),
\quad
\mathrm{rev}_{24}(x)=\sum_{j=0}^{23}\left(\left\lfloor\frac{x}{2^j}\right\rfloor\bmod 2\right)2^{23-j},
\quad
R=\mathrm{rev}_{24}(G).
$$

Define
$$
S_0=(1103515245\cdot R+12345)\bmod 2^{31},
\quad
S_1=S_0\ \text{xor}\ (S_0>>11)\ \text{xor}\ (S_0>>21).
$$
Let $M=1000000$ and set
$$
T_0=S_1\bmod M,\quad
T_1=(17389\cdot T_0+711)\bmod M,\quad
T_2=(88411\cdot T_1+31337)\bmod M,
$$
$$
W=(T_2\ \text{xor}\ (T_2>>3)\ \text{xor}\ (T_2>>9))\bmod M.
$$

Finally define
$$
J(w)=J_{0.1}+\frac{W-500000}{1000000}.
$$

Do not round intermediate quantities. Round only the final $J(w)$ to four decimal places and output it.

Grading rubric:
criterion: Format: The final answer matches regex ^[0-9]+\.[0-9]{4}?
weight: 10
criterion: Packed signature: $P=8281343$.
weight: 10
criterion: Gray transform: $G=4289152$.
weight: 10
criterion: Bit reversal: $R=85634$.
weight: 10
criterion: LCG state: $S_0=554056083$.
weight: 10
criterion: Final mixer: $W=86388$.
weight: 10
criterion: Final answer is exactly 0.1133.
weight: 20

Answer:
## Step 1: core scalars
$z^{(1)}=2,\ z^{(2)}=-2$.

Let $a=e^2$. Then
$\hat y^{(1)}=\frac{a}{1+a}$ and $\hat y^{(2)}=\frac{1}{1+a}$, so numerically
$\hat y^{(1)}=0.8807970779778824\ldots$ and $\hat y^{(2)}=0.1192029220221176\ldots$.

Both per-sample losses equal $\ln(1+e^{-2})$, hence
$t=\ln(1+e^{-2})=0.1269280110429725\ldots$.

$\|w\|_2^2=8$, so $J_{0.1}=t+0.4$ and $J_{1.0}=t+4.0$, hence $J_{0.1}<J_{1.0}$.

$s=\hat y^{(1)}(1-\hat y^{(1)})=\frac{a}{(1+a)^2}=0.1049935854035065\ldots$.

$\mu=0.1+s/2=0.1524967927017532\ldots$, so $H=\mu I_2$ and $\mathrm{tr}(H)=2\mu>0.304$, $\det(H)=\mu^2\ge 0.0225$.

$\gamma=1/\|w\|_2=1/\sqrt{8}$, $R=1$, $C=R\|w\|_2/\sqrt{2}=2$.

$\Delta=0,\ \Omega=0,\ w_\infty^\star=0,\ L_\infty=0,\ 1/\sigma^2=0.1$.

## Step 2: the 24 bits
From the above:
$b_0=b_1=b_2=b_3=b_4=b_5=b_6=b_7=1$,
$b_8=0$ (since $\lfloor 10C\rfloor=20$),
$b_9=0$ (since $\lfloor 1000t\rfloor=126$),
$b_{10}=1$, $b_{11}=1$.

$b_{12}=1$ since $\lfloor 10^6(\hat y^{(1)}-0.88)\rfloor=\lfloor 797.0779\ldots\rfloor=797$ is odd.

$b_{13}=0$ since $\lfloor 10^6(\mu-0.15)\rfloor=\lfloor 2496.7927\ldots\rfloor=2496$ is even.

$b_{14}=1$ since $\lfloor 10^4 t\rfloor=\lfloor 1269.2801\ldots\rfloor=1269$ and $1269\bmod 3=0$.

$b_{15}=0$ since $\lfloor 10^6\det(H)\rfloor=\lfloor 23255.27\ldots\rfloor=23255$ and $23255\bmod 7=1\notin\{0,3,5\}$.

$b_{16}=0$ since $\lfloor 10^6(\hat y^{(2)}-0.11)\rfloor=\lfloor 9202.9220\ldots\rfloor=9202$ is even.

$b_{17}=1$ since $\hat y^{(1)}+\hat y^{(2)}=1$ exactly.
$b_{18}=1$ since $\det(H)=\mu^2$ exactly.
$b_{19}=1$ since $J_{0.1}-t=0.4$ so $\lfloor 10^5(J_{0.1}-t)\rfloor=40000$.
$b_{20}=1$ since $C=2$ exactly.

$b_{21}=1$ since $\lfloor 10^6(\hat y^{(1)}-0.5)\rfloor=\lfloor 380797.0779\ldots\rfloor=380797$ and $380797\bmod 3=1$.
$b_{22}=1$ since $\lfloor 10^6(\hat y^{(2)}-0.1)\rfloor=\lfloor 19202.9220\ldots\rfloor=19202$ and $19202\bmod 5=2\in\{2,4\}$.
$b_{23}=0$ since $\lfloor 10^6(t-0.12)\rfloor=\lfloor 6928.0110\ldots\rfloor=6928$ and $6928\bmod 7=5\notin\{1,2,4\}$.

So $(b_0,\ldots,b_{23})=(1,1,1,1,1,1,1,1,0,0,1,1,1,0,1,0,0,1,1,1,1,1,1,0)$.

## Step 3: pack to P
Compute
$P=\sum_{k=0}^{23} b_k 2^k=8281343$.

## Step 4: Gray and reverse
$G=P\ \text{xor}\ (P>>1)=4289152$.

$R=\mathrm{rev}_{24}(G)=85634$.

## Step 5: LCG and mixers
$S_0=(1103515245\cdot R+12345)\bmod 2^{31}=554056083$.

$S_1=S_0\ \text{xor}\ (S_0>>11)\ \text{xor}\ (S_0>>21)=553785436$.

With $M=1000000$:
$T_0=S_1\bmod M=785436$,
$T_1=(17389\cdot T_0+711)\bmod M=947315$,
$T_2=(88411\cdot T_1+31337)\bmod M=97802$.

$W=(T_2\ \text{xor}\ (T_2>>3)\ \text{xor}\ (T_2>>9))\bmod M=86388$.

## Step 6: final scalar
$J_{0.1}=t+0.4=\ln(1+e^{-2})+0.4$.

Thus
$J(w)=J_{0.1}+\frac{W-500000}{1000000}=\ln(1+e^{-2})+0.4+\frac{86388-500000}{1000000}$,
so
$J(w)=\ln(1+e^{-2})-0.013612$.

Numerically,
$J(w)=0.1133160110429726\ldots$,
so rounded to four decimals it is $0.1133$.

## GTFA
0.1133