Question

The purpose of this question is to calculate the three cubic roots of a complex number. A complex number is of the form a + i
Enter the real part of the complex number: 5. Enter the imaginary part of the complex number: 2. The complex number is (5+2j)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

% Matlab program to calculate the three cubic roots of a complex number

% input of a and b
a = input(' Enter the real part of the complex number : ');
while(a == 0) % check if a is 0
a = input(' a cannot be 0. Enter the real part of the complex number : ');
end
b = input(' Enter the imaginary part of the complex number : ');
% print the complex number
fprintf(' The complex number is (%g+%gj)',a,b);
theta = atan(b/a); % calculate theta
r = a/cos(theta); % calculate r
% calculate the roots
root1 = (r^(1/3))*((cos(theta/3))+(1i*sin(theta/3)));
root2 = (r^(1/3))*((cos((2*pi+theta)/3))+(1i*sin((2*pi+theta)/3)));
root3 = (r^(1/3))*((cos((4*pi+theta)/3))+(1i*sin((4*pi+theta)/3)));
% print the output
fprintf(' root1 = %f%+fj',real(root1),imag(root1));
fprintf(' root1^3 = %f%+fj',real(root1^3),imag(root1^3));
fprintf(' root2 = %f%+fj',real(root2),imag(root2));
fprintf(' root2^3 = %f%+fj',real(root2^3),imag(root2^3));
fprintf(' root3 = %f%+fj',real(root3),imag(root3));
fprintf(' root3^3 = %f%+fj ',real(root3^3),imag(root3^3));
%end of program

Output:

Enter the real part of the complex number 6.75 Enter the imaginary part of the complex number : 4.37 The complex number is (6

Add a comment
Know the answer?
Add Answer to:
The purpose of this question is to calculate the three cubic roots of a complex number....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT