## 3 Optimization Problem Solving
### Optimizing the IRS Phase Shift for a Given BS Transmit Beamforming  
Given the BS transmit beamforming, problem P1 is reformulated as:  
\[ \begin{array}{l}\text{P3}:\max_{\mathbf{\Theta}}\text{ log}_{2}\bigg{(}1+\frac{|(h_{r}^{H}\mathbf{\Theta}G+h_{d}^{H})|_{r}^{2}}{e^{2}} \bigg{)}\\ \text{s.t.}\text{ C2}:|v_{n}|=1\quad\forall n=1,\cdots,\text{N}\end{array}  \tag{23}\]  
Problem P3 can be rewritten as:  
\[ \begin{array}{l}\text{P3}-1:\max_{\mathbf{\Theta}}\Big{|}\Big{(}h_{r}^{H}\mathbf{ \Theta}G+h_{d}^{H}\Big{)}\!\!\!f\Big{|}^{2}\\ \text{s.t.}\text{ C2}:|v_{n}|=1\quad\forall n=1,\cdots,\text{N}\end{array}  \tag{24}\]  
Using the properties of diagonal matrices, we have \(\mathbf{h}_{r}^{H}\mathbf{\Theta}\mathbf{G}=\mathbf{V}^{H}\text{diag}\Big{(}h_{r}^{H}\Big{)} \mathbf{G}\). \[\Big{|}\Big{(}\mathbf{h}_{r}^{H}\mathbf{\Theta}\mathbf{G}+\mathbf{h}_{d}^{H}\Big{)}\!\!\!f\Big{|} ^{2}=\Big{|}\Big{(}\mathbf{V}^{H}\text{diag}\Big{(}\mathbf{h}_{r}^{H}\Big{)}\mathbf{G}+h_ {d}^{H}\Big{)}\!\!\!f\Big{|}^{2}, \tag{25}\]  
Let \(\mathbf{F}=\mathbf{f}\mathbf{f}^{H}\). Issue P3-1 is reissued as:  
\[ \begin{array}{l}\text{P3}-2:\underset{\mathbf{\
abla}}{\text{min}}\!\!\!f_{\text{ C}}(\mathbf{V})=-\mathbf{V}^{H}\mathbf{\
abla}\mathbf{V}-\mathbf{V}^{H}\mathbf{\mathsf{b}}-\mathbf{b}^{H} \mathbf{V}\\ \text{s.t.}\ |v_{n}|=1\quad\forall n=1,\cdots,\text{N},\end{array}  \tag{26}\]  
where \(\mathbf{\mathsf{Y}}\)\(=\text{diag}\Big{(}\mathbf{h}_{r}^{H}\Big{)}\mathbf{G}\mathbf{F}\mathbf{G}^{H}\text{diag}(\mathbf{h}_{r})\), \(\mathbf{\mathsf{b}}\)\(=\text{diag}\Big{(}\mathbf{h}_{r}^{H}\Big{)}\mathbf{G}\mathbf{H}_{d}\). Problem P3-2 is solved using the Riemann Conjugate Gradient (RCG) algorithm [36]. The main idea of the RCG algorithm is to generalize the conjugate gradient method from Euclidean space to manifold space, and its main task is to compute the Euclidean gradient. The RCG algorithm has three key steps in each iteration:  
1. Compute the Riemannian gradient: the Riemannian gradient is a tangent vector (direction) of the fastest-growing objective function, and the Riemannian gradient is the Euclidean orthogonal projection of the Euclidean gradient \(\
abla\!\!\!f_{\text{C}}\) onto the complex circle: \[\text{grad}\!\!\!f_{\text{C}}=\
abla\!\!\!f_{\text{C}}-\text{Re}\{\
abla\!\! \!f_{\text{C}}\circ\mathbf{V}^{*}\}\circ\mathbf{V},\] (27) where the Euclidean gradient is: \[\
abla\!\!f_{\text{C}}=2(\mathbf{\mathsf{Y}}\mathbf{\mathsf{V}}+\mathbf{\mathsf{b}}),\] (28)
2. Search direction: using the obtained Riemannian gradient, the optimization of Euclidean spaces is extended to manifold spaces. The search directions \(\eta_{i}\) and \(\eta_{i+1}\) are located in different tangent spaces. Thus, mapping the tangent vector \(\eta_{i}\) from \(T_{\mathbf{\mathsf{V}}_{i}}\mathcal{M}\) to \(T_{\mathbf{\mathsf{V}}_{i+1}}\mathcal{M}\) requires a transmission operation \(\mathcal{I}_{\mathbf{\mathsf{V}}_{i}\rightarrow\mathbf{\mathsf{V}}_{i+1}}(\eta_{i})\), i.e., the tangent vector conjugate to \(\text{grad}\!\!\!f_{\text{C}}\) can be found as the search direction direction \[ \begin{array}{l}\
abla\!\!\!f_{\text{C}}=2(\mathbf{\mathsf{Y}}\mathbf{\mathsf{V}}+ \mathbf{\mathsf{b}})\mathcal{I}_{\mathbf{\mathsf{V}}_{i}\rightarrow\mathbf{\mathsf{V}}_{i+ 1}}(\eta_{i}):T_{\mathbf{\mathsf{V}}_{i}}\mathcal{M}\mapsto T_{\mathbf{\mathsf{V}}_{i+ 1}}\mathcal{M}:\\ \eta_{i}\mapsto\eta_{i}-\text{Re}\{\eta_{i}\circ\mathbf{\mathsf{V}}_{i+1}^{*}\} \circ\mathbf{\mathsf{V}}_{i+1}\end{array} \] (29) The search directions are updated for: \[\eta_{i+1}=-\text{grad}\!\!\!f_{\text{C}}+\tau_{i}\cdot\mathcal{I}_{\mathbf{ \mathsf{V}}_{i}\rightarrow\mathbf{\mathsf{V}}_{i+1}}(\eta_{i}),\] (30) where \(\tau_{i}\) is the Polak-Ribiere parameter. 3. Retraction: After determining the search direction \(\eta_{i}\), it is necessary to determine the Armijo step size \(\beta_{i}\), and the resulting point \(\beta_{i}\cdot\eta_{i}\) may leave the stream. The resultingpoint may leave the manifold.