# Maximization of Average Achievable Rate for NOMA-UAV Dual-User Communication System Assisted by RIS
## 4 Proposed Algorithm
### RIS Phase Shift Optimization  
When we fix the UAV power \(P_{1,2}\) and UAV flight trajectory \(Q\), we can rewrite \(H_{1}[k]\) as  
\[h_{g1}^{H}\Theta_{1}[k]h_{ur}[k]=\frac{\sqrt{\epsilon_{0}}\sum_{m=0}^{M_{2}-1} \sum_{n=0}^{M_{2}-1}\lvert h_{rg_{1}(m,n)}\rvert e^{j\beta_{1(m,n)}[k]}}{d_{ur }^{\frac{n}{K}}[k]}, \tag{19}\]  
and through the integration of phase can be drawn \(\beta_{1(m,n)}[k]=\theta_{1(m,n)}[k]-\eta_{1(m,n)}-\frac{2\pi}{\lambda}d_{ \lambda ur}^{(m,n)}[k]\). According to [27], the equivalent maximum channel gain is achieved when the phases of \(h_{ug_{1}}\) and \(h_{rg_{1}}^{H}\Theta_{1}[k]h_{ur}[k]\) are aligned. Then we can derive it from  
\[\theta_{1(m,n)}[k]=arg(\widetilde{h}_{1})[k]+\eta_{1(m,n)}+\frac{2\pi}{ \lambda}d\chi_{ur}^{(m,n)}[k], \tag{20}\]  
Using the same method, we can express the \(H_{2}[k]\) as  
\[h_{rg_{2}}^{H}\Theta_{2}[k]h_{ur}[k]=\frac{\sqrt{\epsilon_{0}}\sum_{m=0}^{M_{ 2}-1}\sum_{n=0}^{M_{2}-1}\lvert h_{rg_{2}(m,n)}\rvert e^{j\beta_{2(m,n)}[k]}}{ d_{ur}^{\frac{n}{K}}[k]}, \tag{21}\]  
where \(\beta_{2(m,n)}[k]=\theta_{2(m,n)}[k]-\eta_{2(m,n)}-\frac{2\pi}{\lambda}d_{ \lambda ur}^{(m,n)}[k]\). We align the phase of RIS to User 1. According to the literature [28], we align the RIS phase with User 1, as the positions of User 1 and User 2 differ, resulting in a phase difference. So we make \(\theta_{1(m,n)}[k]=\theta_{2(m,n)}[k]\) and put \(\theta_{1(m,n)}[k]\) into \(\beta_{2(m,n)}[k]\), we can get  
\[\beta_{2(m,n)}[k]=arg(\widetilde{h}_{1})[k]+\eta_{1(m,n)}-\eta_{2(m,n)}, \tag{22}\]Because of mathematical formulae \(\left|e^{\beta}\right|=1\), we can rewrite \(H_{1}\) and \(H_{2}\) as  
\[H_{1}[k]=\left(\frac{\sqrt{c_{0}}\left|\widetilde{h_{1}}\right|}{d_{itg_{1}}^{ \frac{\delta}{2}}[k]}+\frac{\sqrt{c_{0}}\sum\limits_{m=0}^{M_{x}-1}\sum\limits_ {n=0}^{M_{x}-1}\left|h_{{\rm{rg}}_{1},(m,n)}\right|}{d_{it}^{\frac{\delta}{2}}[ k]}\right)^{2}, \tag{23}\]  
\[H_{2}[k]=\left(\frac{\sqrt{c_{0}}\left|\widetilde{h_{2}}\right|}{d_{itg_{2}}^{ \frac{\delta}{2}}[k]}+\frac{\sqrt{c_{0}}\sum\limits_{m=0}^{M_{x}-1}\sum\limits _{n=0}^{M_{x}-1}\left|h_{{\rm{rg}}_{2},(m,n)}\right|}{d_{it}^{\frac{\delta}{2} }[k]}\right)^{2}. \tag{24}\]  
RIS can be equipped with high-precision phase control modules (e.g., varactor diodes) that independently adjust the phase of each reflection unit. In this paper, an alternating iterative iterative solution method is employed to ensure smooth and continuous phase adjustment, while the UAV's continuity constraints are incorporated to prevent system instability. Therefore, continuous-phase operation is feasible.  
Quantization phase shifts introduce errors that affect the accuracy, stability, and complexity of the optimization problem, particularly at lower quantization levels (e.g., 2-bit and 4-bit), where larger quantization errors can degrade convergence speed and algorithm accuracy. Additionally, lower quantization levels reduce the signal-to-noise ratio and increase the bit error rate, potentially limiting the achievable transmission rate.  
This section focuses on UAV trajectory optimization. Following this, we will address the UAV power allocation problem.