To calculate the nth root of a complex number without using the nthroot
function in MATLAB, you can use the following steps:
a+bi
and store it in variables a
and b
.n
for the nth root and store it in a variable n
.r
) and argument (theta
) of the complex number using the formulas:
x
) and imaginary (y
) parts of the nth root using the formulas:
x+yi
.Here is the implementation in MATLAB:
main.m673 chars26 lines
It's important to note that due to the nature of complex numbers, there can be multiple solutions for the nth root. The above code calculates only one of the possible roots.
gistlibby LogSnag