Calculating the nth Roots of 1
Use the Live Editor to experiment with MATLAB code interactively. Add controls to show
students how important parameters affect the analysis. To add controls, go to the Live
Editor tab, click the Controls button, and select from the available options.
We can use this last equation to find the nth roots of 1. For example, for any value of n, we
can use the formula above with values of k= 0...n− 1. We can use this MATLAB code to
experiment with different values of n:
n = 6;
roots = zeros(1, n);
for k = 0:n-1
roots(k+1) = cos(2*k*pi/n) + 1i*sin(2*k*pi/n); % Calculate the roots
end
disp(roots')
1.0000 + 0.0000i
0.5000 - 0.8660i
-0.5000 - 0.8660i
-1.0000 - 0.0000i
-0.5000 + 0.8660i
0.5000 + 0.8660i
Plotting the roots in the complex plane shows that the roots are equally spaced around
the unit circle at intervals of 2 π/n.
cla
plot(cos(range),sin(range),'k') % Plot the unit circle
hold on
plot(real(roots),imag(roots),'ro') % Plot the roots
19 Live Scripts and Functions