# Joint Radar and Communications Waveform Design Based on Complementary Sequence Sets
## 3 JRC-CWG and DR-JRC-CWG Design
### JRC-CWG Design with Low Sidelobe Level
#### 3.1.2 JRC-CWG Design Algorithm  
In this section, an algorithm based on the framework of the FR-CG algorithm and the FFT algorithm is applied to solve (10). Define  
\[D\big{(}\mathbf{\Theta}_{g}\big{)}=\left[\sum\limits_{m=1}^{M}\mathbf{x}_{g,m} \odot\mathbf{x}_{g,m}^{*}\right]^{H}\left[\sum\limits_{m=1}^{M}\mathbf{x}_{g, m}\odot\mathbf{x}_{g,m}^{*}\right] \tag{11}\]  
To solve (10), the gradient of \(D\big{(}\mathbf{\Theta}_{g}\big{)}\) with respect to \(\mathbf{\Theta}_{g}\) is required to be derived. To achieve this, the gradient of \(D\big{(}\mathbf{\Theta}_{g}\big{)}\) with respect to \(\theta_{g,m}(n)\) (\(m\leq M_{r}\)) is derived first. According to the definition of the gradient of the real-valued function with respect to complex variables in [44], the gradient of \(D\big{(}\mathbf{\Theta}_{g}\big{)}\) with respect to \(\theta_{g,m}(n)\) is represented as  
\[ \begin{array}{ll}\frac{\partial D\big{(}\mathbf{\Theta}_{g}\big{)}}{\partial \theta_{g,m}(n)}&=\frac{\partial D\big{(}\mathbf{\Theta}_{g}\big{)}}{\partial \theta_{g,m}(n)},\ \frac{\partial s_{g,m}(n)}{\partial\theta_{g,m}(n)}+\frac{\partial D \big{(}\mathbf{\Theta}_{g}\big{)}}{\partial s_{g,m}(n)}\frac{\partial s_{g,m}^{*} (n)}{\partial\theta_{g,m}(n)}\\ &=j\frac{\partial D\big{(}\mathbf{\Theta}_{g}\big{)}}{\partial s_{g,m}(n)}\cdot s _{g,m}(n)-j\frac{\partial D\big{(}\mathbf{\Theta}_{g}\big{)}}{\partial s_{g,m}^{*} (n)}\cdot s_{g,m}^{*}(n)\end{array}  \tag{12}\]  
In (12), \(j\) represents the imaginary unit. According to the chain rule, we can determine that  
\[ \begin{array}{ll}\frac{\partial D\big{(}\mathbf{\Theta}_{g}\big{)}}{\partial s_ {g,m}(n)}&=\sum\limits_{k=1}^{K}\frac{\partial D\big{(}\mathbf{\Theta}_{g}\big{)} }{\partial\gamma_{g}(k)}\frac{\partial\gamma_{g}(k)}{\partial s_{g,m}(k)} \frac{\partial x_{g,m}(k)}{\partial s_{g,m}(n)}\\ &=\sum\limits_{k=1}^{K}\gamma_{g}^{*}(k)x_{g,m}^{*}(k)\tilde{\mathbf{F}}_{K} (k,n)\end{array}  \tag{13}\]  
and  
\[ \begin{array}{ll}\frac{\partial D\big{(}\mathbf{\Theta}_{g}\big{)}}{\partial s _{g,m}^{*}(n)}&=\sum\limits_{k=1}^{K}\frac{\partial D\big{(}\mathbf{\Theta}_{g} \big{)}}{\partial\gamma_{g}^{*}(k)}\frac{\partial\gamma_{g}^{*}(k)}{\partial s _{g,m}^{*}(k)}\frac{\partial x_{g,m}^{*}(k)}{\partial s_{g,m}^{*}(n)}\\ &=\sum\limits_{k=1}^{K}\gamma_{g}(k)x_{g,m}(k)\tilde{\mathbf{F}}_{K}^{*}(k,n) \end{array}  \tag{14}\]  
In (13) and (14), \(\gamma_{g}(k)\) is the \(k\)-th element of \(\gamma_{g}\), and \(\mathbf{\gamma}_{g}=\sum\limits_{m=1}^{M}\mathbf{x}_{g,m}\odot\mathbf{x}_{g,m}^{*}\). From (13) and (14), we can determine that  
\[\frac{\partial D\big{(}\mathbf{\Theta}_{g}\big{)}}{\partial s_{g,m}(n)}=\left[ \frac{\partial D\big{(}\mathbf{\Theta}_{g}\big{)}}{\partial s_{g,m}^{*}(n)}\right]^ {*} \tag{15}\]From (12) to (15), the gradient of \(D\big{(}\mathbf{\Theta}_{g}\big{)}\) with respect to \(\theta_{g,m}\) can be represented as  
\[ \begin{array}{ll}\frac{\partial D\big{(}\mathbf{\Theta}_{g}\big{)}}{\partial\theta_ {g,m}}&=\Big{\{}\mathbf{V}\big{[}\tilde{\mathbf{F}}_{K}\Big{(}2\gamma_{g} \odot\mathbf{x}_{g,m}^{*}\Big{)}\Big{]}\Big{\}}\odot\big{(}j\mathbf{s}_{g,m} \big{)}\\ &+\Big{\{}\mathbf{V}\big{[}\tilde{\mathbf{F}}_{K}^{H}\big{(}2\gamma_{g}\odot \mathbf{x}_{g,m}\big{)}\Big{]}\Big{\}}\odot\big{(}-j\mathbf{s}_{g,m}^{*}\Big{)} \\ &=2\text{Re}\Big{\{}\Big{\{}\mathbf{V}\big{[}\tilde{\mathbf{F}}_{K}\Big{(}2 \gamma_{g}\odot\mathbf{x}_{g,m}^{*}\Big{)}\Big{]}\Big{\}}\odot\big{(}j\mathbf{ s}_{g,m}\big{)}\Big{\}}\end{array}  \tag{16}\]  
where \(\mathbf{V}=\big{[}\mathbf{I}_{N},\mathbf{0}_{N\times(N-1)}\big{]}\). Using (16), the gradient of \(D\big{(}\mathbf{\Theta}_{g}\big{)}\) with respect to \(\mathbf{\Theta}_{g}\) can be calculated, and the FR-CG algorithm can be applied to solve (10). Note that (10) and (16) can be calculated with the FFT algorithm to reduce computational complicity. The detailed algorithm for designing the \(g\)-th JRC-CWG is summarized in Algorithm 1. ```
Input:\(G\), \(M_{c}\), \(M_{r}\), \(N\), the threshold \(\varepsilon\), and WCIs.