## 4 Mathematical Formulation of the Optimization Problem
### Transmission Power Requirements for Terminal-HAP-Satellite Path  
For the terminal-to-HAP and the HAP-to-satellite (T-H-S) path, _i.e._, the indirect or relay link, if it assumed that the decode-and-forward (DF) is used at the HAP end, then the overall BER of the relay link can be given by:  
\[\rho_{e,r}=(1-\rho_{e,2})\rho_{e,3}+(1-\rho_{e,3})\rho_{e,2} \tag{10}\]  
where \(\rho_{e,2}\) denotes the BER of the T-H relay link and \(\rho_{e,3}\) denotes the BER of the H-S relay link. \(\rho_{e,2}\) can be obtained by Equation (3). Due to the AWGN channel of \(h_{3}\), the BER of DPSK in the H-S link can be obtained as:  
\[\rho_{e,3}=\frac{1}{2}\exp(-\gamma_{3}) \tag{11}\]  
Since the BER values are small (_circa_\(10^{-6}\)), the values of BER \(\rho_{e,2}\) and \(\rho_{e,3}\) will be much larger than that of \(\rho_{e,2}\times\rho_{e,3}\). The overall BER can be approximated as \(\rho_{e,r}=\rho_{e,2}+\rho_{e,3}\). Let \(P_{s,2}\) and \(P_{s,3}\) denote the transmission power of the terminal for the T-H relay link and the transmission power of the HAP for the H-S relay link, respectively. With the BER maintaining minimum levels \(\rho_{e,3}=\epsilon_{3}\), \(\rho_{e,2}=\epsilon_{2}\) and \(\epsilon_{2}+\epsilon_{3}=\epsilon\), the minimum total transmission power can be obtained by:  
\[\{\hat{P}_{s,2},\hat{P}_{s,3}\}=arg\min_{P_{s,2}}\left\{P_{s,2}+P_{s,3}\right\} \tag{12}\]  
where \(\hat{P}_{s,2}\) and \(\hat{P}_{s,3}\) denote the optimal transmission powers of the T-H link and H-S link, respectively. According to Equation (11), the transmission power \(P_{s,3}\) can be represented as:  
\[P_{s,3}=\frac{-R_{b,3}L_{m,3}(d_{3})N_{0}BO_{o}}{\alpha_{3}G_{s,3}G_{r,3}}ln(2( \epsilon-\epsilon_{2})) \tag{13}\]  
where \(\epsilon_{2}=\frac{(1+\kappa_{2})}{2(1+\kappa_{2}+\gamma_{2})}\exp\left(\frac {-\kappa_{2}\gamma_{2}}{1+\kappa_{2}+\gamma_{2}}\right)\) is the BER of the corresponding T-H relay link, with \(\gamma_{2}=\alpha_{2}P_{s,2}G_{s,2}G_{r,2}/(R_{b,2}L_{m}(d_{2})N_{0}BO_{o})\). It can be found that \(P_{s,3}\) is a function of the independent variable \(P_{s,2}\). If the total transmission power is \(P_{r}=P_{s,2}+P_{s,3}\), the first order derivative of \(P_{r}\) can be derived as follows:  
With the overall BER of the T-H-S path maintained at a minimum level \(\epsilon_{2}+\epsilon_{3}=\epsilon\), the mean received SNR for the satellite can be represented as:  
\[\gamma_{3}=\frac{\alpha_{3}E_{b}}{N_{0}}=\frac{\alpha_{3}P_{s,3}G_{s,3}G_{r,3 }}{R_{b,3}L_{m}(d_{3})N_{0}BO_{o}} \tag{14}\]  
Substituting Equation (14) into Equation (11), the BER for the H-S relay transmission is given by:  
\[\rho_{e,3}=\frac{1}{2}\exp(-\gamma_{3})=\frac{1}{2}\exp\left(-\frac{\alpha_{3} P_{s,3}G_{s,3}G_{r,3}}{R_{b,3}L_{m}(d_{3})N_{0}BO_{o}}\right) \tag{15}\]  
Based on Equation (10), the BER for the H-S relay transmission is \(\rho_{e,3}=\epsilon-\epsilon_{2}\), and the transmission power \(P_{s,3}\) has been given by Equation (13). The BER \(\epsilon_{2}\) is determined by the transmission power \(P_{s,2}\) of the terminal for the T-H relay transmission, which can be written as:\[\rho_{e,2}=\frac{(1+\kappa_{2})}{2(1+\kappa_{2}+\gamma_{2})}\exp\left(\frac{- \kappa_{2}\gamma_{2}}{1+\kappa_{2}+\gamma_{2}}\right)\] \[=\frac{(1+\kappa_{2})}{2(1+\kappa_{2}+\frac{\alpha_{2}P_{s,2}G_{r,2 }}{\kappa_{2}P_{s,2}G_{r,2}})}\times\exp\left(\frac{-\kappa_{2}\frac{\alpha_{2 }P_{s,2}G_{r,2}G_{r,2}}{\kappa_{2}P_{s,2}G_{r,2}}}{1+\kappa_{2}+\frac{\alpha_{ 2}P_{s,2}G_{r,2}}{\kappa_{2}P_{s,2}G_{r,2}})}\right) \tag{16}\]  
Substituting Equation (16) into Equation (13), the first order derivative of \(P_{r}=P_{s,2}+P_{s,3}\) can then be solved as:  
\[