There are two real signals in the form of $A_i sin(wt+p_i), i=1,2$. Suppose frequency $w$ of both the signals is the same and amplitude $A_i$ and phase $p_i$ are different. The first signal has unknown $A$ and $p$, but they are constant in the time of observation (for simplicity only, actually they aren't). The second signal is under control. We only have it's difference $x(t) = s_1(t)-s_2(t)$. Some iterative algorithm is needed to minimize power of $x(t)$. So $x(t)$ is available input and $A_2(t)$, $p_2(t)$ are parameters under control.

The question is: is it some robust and rapid algorithm for jointly control both amplitude and phase to minimize power of $x(t)$? My idea was to implement complex gradient method: phase and amplitude at each step are represented as a complex number $C(t)$. Signal $s_2(t)$ can be set as $Re[C(t) exp(iwt)]$. But I can't understand how to define cost function and gradient in this case and also this approach seems to be computationally redundant. Any ideas?

Thanks in advance!


1 Answer 1


I assume you do everything in discrete time. If I understood correctly then the observed signal is


where $s(n)$ is a sinusoidal signal with frequency $\omega_0$ and unknown amplitude and phase. The parameters $A$ and $\phi$ are to be optimized such that the power of $x(n)$ is minimized. In a real-time algorithm you can define the cost function as the sum of $x^2(n)$ over a fixed length $N$:


where $n$ is the current sample. For a steepest descent algorithm you need the gradient:

$$\frac{\partial F}{\partial A}=-2\sum_{k=n-N+1}^{n}x(k)\sin(\omega_0k+\phi)\\ \frac{\partial F}{\partial \phi}=-2A\sum_{k=n-N+1}^{n}x(k)\cos(\omega_0k+\phi)$$

The parameters are now updated in the following way:

$$A_n=A_{n-1}-\mu\frac{\partial F_{n-1}}{\partial A}\\ \phi_n=\phi_{n-1}-\mu\frac{\partial F_{n-1}}{\partial \phi}$$

where $\mu$ is the step size. Note that in every iteration you need to recompute the gradients with the current values of $A$ and $\phi$.

The figure below is a simulation of this gradient algorithm with the unknown signal $s(n)=2\sin(\pi n/3+\pi/2)$, $N=50$, $\mu=0.01$, and with zero initialization of both amplitude and phase (amplitude $A$ in blue, phase $\phi$ in green).

enter image description here

  • $\begingroup$ I'm working at the algorithm you've written above (thanks) and I've made slight modification in phase updating equation: $\phi_n = \phi_{n-1} - \mu_{\phi} \cdot \pi \cdot sign(\frac{\partial{F_{n-1}}}{\partial{\phi_{n-1}}})$. So it works less rapidly but more robustly. And phase updating is no longer depends on initial amplitude difference between the signals which is the case (about 60 dB or even more). Some operations are performed in analog so very high stability is of interest. Matt, do you think it is the right way? $\endgroup$
    – Serj
    Commented Jul 10, 2014 at 7:18
  • $\begingroup$ @Serj: The sign algorithm (as you use it for the phase) is normally used for computational efficiency, not so much for improved robustness. It is probably better to include the current estimated amplitude in the update of the phase. I'm not sure what you mean by 'amplitude difference' because the difference is not used in the algorithm. But having said that, if your version works well then it's of course OK to use it. Just do a lot of testing with realistic signals. $\endgroup$
    – Matt L.
    Commented Jul 10, 2014 at 7:30
  • $\begingroup$ I mean that if for example $A_0 = 1$ then amplitude of $s$ could be 60 dB higher or more. And the problem was: I must estimate the order of $s$ amplitude to adjust phase updating. But $s$ is totally unknown. But thanks! Yeah, you're fully right - hardware realization will show is it rigth or not. $\endgroup$
    – Serj
    Commented Jul 10, 2014 at 7:38
  • $\begingroup$ @Serj: OK, but you could initially choose $A_0=0$, so you can directly observe $s$ (because $s=x$) and get an initial estimate of the actual amplitude as a starting value for the iteration. $\endgroup$
    – Matt L.
    Commented Jul 10, 2014 at 7:40
  • $\begingroup$ I've thought about it, but as I've said there is analog part in signal path so when input signal power is pretty big, ADC works in overloading (probably I should write it in the question above). That's why we can't achieve $s$ directly to measure its power. Estimating power by the level of non-linear distortions seems to me unsound. $\endgroup$
    – Serj
    Commented Jul 10, 2014 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.