Solution (source code)

= Solution

Use the ordered basis $(p_x,p_y,p_z)$ at the origin. Choose $z$ as the principal improper-rotation axis, $x,y$ along the two $C_2^\prime$ axes, and the diagonal mirror planes as $x=\pm y$. Use active operations with $\hat U(g)f(\mathbf r)=f(g^{-1}\mathbf r)$, so the matrix columns give the transformed orbitals. For these real p orbitals the matrices are the ordinary vector transformation matrices.

One representative from each <D2d molecular point group> class is
$$
\begin{aligned}
D(E)&=\begin{pmatrix}1&0&0\\0&1&0\\0&0&1\end{pmatrix},\\
D(S_4^+)&=\begin{pmatrix}0&-1&0\\1&0&0\\0&0&-1\end{pmatrix},\\
D(C_2(z))&=\begin{pmatrix}-1&0&0\\0&-1&0\\0&0&1\end{pmatrix},\\
D(C_2(x))&=\begin{pmatrix}1&0&0\\0&-1&0\\0&0&-1\end{pmatrix},\\
D(\sigma_{x=y})&=\begin{pmatrix}0&1&0\\1&0&0\\0&0&1\end{pmatrix}.
\end{aligned}
$$
For example $S_4^+$ sends $p_x\mapsto p_y$, $p_y\mapsto-p_x$ and $p_z\mapsto-p_z$. Choosing the opposite sense of $S_4$ transposes its xy block but leaves every character and the final decomposition unchanged.