(2 votes, average: 5.00 out of 5)

# Using CORDIC for phase and magnitude computation

by on December 16, 2007

In a previous post (here), we looked at using CORDIC (Co-ordinate Rotation by DIgital Computer) for understanding how a complex number $\mathbf{X}$ can be rotated by an angle $\theta$ without using actual multipliers. Let us know try to understand how we can use CORDIC for finding the phase and magnitude of a complex number.

Basics

The CORDIC algorithm is built on successively multiplying the complex number $\mathbf{X}$, by $\mathbf{Y} =1 + j2^{-k}$. As can be noticed, as the elements of $\mathbf{Y}$ can be represented in powers of 2, the multiplication can be achieved by using the appropriate ‘bit shift’. For further details, please refer to the previous post (CORDIC for phase rotation).

Finding the magnitude and phase

It is reasonably obvious that the multiplying a complex number $\mathbf{X}$ by $e^{j\theta}$ does not change the magnitude of $\mathbf{X}$.

Given so, if phase rotation of $\mathbf{X}$ results in $\mathbf{Z}$, and the imaginary component of $\mathbf{Z}$ is 0, then the real part of $\mathbf{Z}$ stores the magnitude of $\mathbf{X}$.

To put in equations, if

$\mathbf{Z}=\mathbf{X}e^{j\theta}$, where $\Im \left[{\mathbf{Z}}\right]=0$,

then,

$\Re \left[{\mathbf{Z}}\right]=|\mathbf{X}|$ (real part of $\mathbf{Z}$ is the magnitude of $\mathbf{X}$)

$\theta = -\angle\left[{X}\right]$ (the rotation angle $\theta$ is the negative of the phase of $\mathbf{X}$)

This is the fundamental idea behind finding the magnitude and phase of a complex number using CORDIC.

The sequence of events is as shown below:

(a) The input complex number is subject to a series of phase rotations.

(b) The sign of the phase rotation is the negative of the sign of imaginary component of $\mathbf{Z}$.

(c) After multiple iterations, imaginary component of $\mathbf{Z}$ tends to zero.

(d) Then, the real part of the new complex vector represents the magnitude and the cumulative phase value represents the negative of the phase of $\mathbf{X}$.

Figure: Flow chart for the operations involved in using CORDIC for computing phase and magnitude

The reference phase $\alpha_k=\angle\left[1+j2^{-k}\right]$ (phase of $1+j2^{-k}$).

The scaling factor of 1.64676025786545 is to remove the ‘gain’ following successive rotations by $1 + sj2^{-k}$. Please look at the previous post on CORDIC (here) for details.

Note:

If the input complex number lies in the second or third quadrant, it needs to be first shifted to the first/fourth quadrant before we start the sequence of events shown in the figure above (as the CORDIC range is limited to around +/-90 degrees). This can be achieved by multiplication by $j$ or $-j$, as appropriate.

## Simulation model

Simple Matlab/Octave script for computing the phase and magnitude of a complex number using the CORDIC approach. Quick comparison indicate that the computed and acutal values are closely matching.

Reference

[DSPGURU-CORDIC] CORDIC FAQ in dspGuru(TM)

Hope this helps.

Krishna

D id you like this article? Make sure that you do not miss a new article by subscribing to RSS feed OR subscribing to e-mail newsletter. Note: Subscribing via e-mail entitles you to download the free e-Book on BER of BPSK/QPSK/16QAM/16PSK in AWGN.