# On IRS-Assisted Covert Communication with a Friendly UAV
## 4 Optimization Algorithm
### Optimization of UAV Trajectory  
For a given \(P\) and \(\hat{P}_{u}\), the alternative to (24) is  
\[\max_{Q}\frac{1}{T}\sum_{t=1}^{T}\log_{2}\left(1+\frac{A[t]}{ \frac{\left(1-P_{out}^{s}[t]\right)\beta_{0}\hat{P}_{u}[t]}{H^{2}+\|c[t]-w_{2} \|^{2}}+\sigma_{b}^{2}}\right), \tag{47}\] \[s.t.\] \[\xi^{*}[t]\geq 1-\varepsilon,\] (48) \[0\|c[t+1]-c[t]\|^{2}\leq D^{2},\] (49) \[c[T]=c_{F},c[1]=c_{A}, \tag{50}\]  
where \(A[t]=P_{a}[t]\beta_{0}^{2}M^{2}/d_{IB}^{x}[t]d_{AI}^{x}[t]\) and (47) and (48) are non convex. According to (21), (36) can be rewritten as  
\[H^{2}+\|c[t]-w_{W}\|^{2}\leq\frac{\varepsilon\hat{P}_{u}[t]\beta_{0}}{P_{a}[t ]\big{|}h_{IW}^{H}[t]\Theta[t]h_{AI}[t]\big{|}^{2}}. \tag{51}\]  
The right side of (51) is a constant with all known variables, and the left side of (51) includes the variables to be optimized. The distance between the UAV and Bob or Willie can be expressed as \(d_{l}[t]=\sqrt{H^{2}+\big{\|}c[t]-w_{j}\big{\|}^{2}}\), where \(l=\{UB,UW\}\) and \(j=\{B,W\}\). For \(d_{l}^{2}[t]\), we have  
\[d_{l}^{2}[t]=H^{2}+\big{\|}c[t]-w_{j}\big{\|}=\big{(}x[t]-x_{j}\big{)}^{2}+ \big{(}y[t]-y_{j}\big{)}^{2}+H^{2}. \tag{52}\]  
The first-order partial derivatives of \(d_{l}^{2}[t]\) with respect to \(x[t]\) and \(y[t]\) are respectively expressed as  
\[\frac{\partial d_{l}^{2}[t]}{\partial x[t]}=2\big{(}x[t]-x_{j}\big{)} \tag{53}\]  
and  
\[\frac{\partial d_{l}^{2}[t]}{\partial y[t]}=2\big{(}y[t]-y_{j}\big{)}. \tag{54}\]  
According to (53) and (54), we have  
\[\frac{\partial^{2}d_{l}^{2}[t]}{\partial x^{2}[t]}=\frac{\partial^{2}d_{l}^{2 }[t]}{\partial y^{2}[t]}=2 \tag{55}\]and \[s.t.\]0 (56) Therefore, the Hessian matrix \(\
abla^{2}d_{l}^{2}[t]\) can be obtained with (53)-(56), provided by \[\
abla^{2}d_{l}^{2}[t]=\left( \begin{array}{cc}\frac{\partial^{2}d_{l}^{2}[t] }{\partial x^{2}[t]}&\frac{\partial^{2}d_{l}^{2}[t]}{\partial x[t]y[t]}\\ \frac{\partial^{2}d_{l}^{2}[t]}{\partial y[t]x[t]}&\frac{\partial^{2}d_{l}^{2} [t]}{\partial y[t]x[t]}\\ \end{array} \right)=\left( \begin{array}{cc}2&0\\ 0&2\\ \end{array} \right).\] (57)  
Due to \(\frac{\partial^{2}d_{l}^{2}[t]}{\partial x^{2}[t]}>0\) and \(\frac{\partial^{2}d_{l}^{2}[t]}{\partial y[t]}>0\), the Hessian matrix \(\
abla^{2}d_{l}^{2}[t]\) is a positive definite matrix, which means that \(d_{l}^{2}[t]\) is a convex function. The left side of the inequality in (51) is consequently a convex function; thus, (48) can be replaced by a convex function. For (47), we can relax the objective function by introducing relaxation variables \(u\triangleq\{u[t],\forall t\}\) and \(v\triangleq\{v[t],\forall t\}\). Therefore, (47) can be rewritten as  
\[\max_{Q,u,v}\frac{1}{T}\sum_{t=1}^{T}u[t], \tag{58}\] \[s.t.\] (59) \[u[t]\leq\log_{2}\left(1+\frac{A[t]}{\frac{\left(1-P_{out}^{*}[t] \right)\delta_{0}\tilde{P}_{u}[t]}{v[t]}+\sigma_{b}^{2}}\right),\] (60) \[H^{2}+\left\|c[t]-w_{W}\right\|^{2}\geq v[t],\] (61) \[\left\|c[t+1]-c[t]\right\|^{2}\leq D^{2},\] (62) \[c[T]=c_{F},c[1]=c_{A}, \tag{63}\]  
where \(B[t]=\varepsilon\tilde{P}_{u}[t]\beta_{0}\Big{/}P_{a}[t]\big{|}h_{IW}^{H}[t] \Theta[t]h_{AI}[t]\big{|}^{2}\). Here, (61) is a non-convex function, while the left side of (61) is convex; thus, we can obtain a global lower bound estimate for the original function using first-order Taylor expansion of the convex function. After conducting Taylor expansion of \(H^{2}+\left\|c[t]-w_{W}\right\|^{2}\) at \(c_{0}\triangleq\{c_{0}[t],\forall t\}\), we have  
\[\left\|c[t]-w_{W}\right\|^{2}+H^{2}\geq\left\|c_{0}[t]-w_{W}\right\|^{2}+H^{2 }+2(c_{0}[t]-w_{W})^{T}(c[t]-c_{0}[t])\triangleq F(c[t]). \tag{64}\]  
According to (58), (64) can be rephrased as  
\[\max_{C,u,v}\frac{1}{T}\sum_{t=1}^{T}u[t], \tag{65}\] \[s.t.\] \[H^{2}+\left\|c[t]-w_{W}\right\|^{2}\leq B[t],\] (66) \[s.t.\]0 (67) \[s.t.\]1 (68) \[s.t.\]2 (69) \[s.t.\]3  
When expressed in this manner, the objective function and constraints of problem (65) are both convex; thus, (65) is convex, and can be solved using the CVX solver to obtain the optimal flight trajectory of the UAV.