Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


CMPSC/Mathematics 451

MATLAB Assignment Two

Fall 2021


You are to write a MATLAB function to find the cube root of a complex number.

        In general, a complex number is represented as

where and are real numbers and i is the imaginary unit. In MATLAB (or Octave), you can compose out of and from the statement

and recover and from using

        Given the complex number we are looking for a root of

where is described in (1). You are to use this function to compute the cube root of a using Newton’s method for two variables.

        To do that, we represent the complex numbers and a as vectors with two real components. That is the vectors

represent in (1) and .

        Then we write f() as a function of the two real numbers and parameterized by the two real numbers a1 and a2. Equation (2) my be written

where and are real valued functions. For f(z) to be zero, both g1(, ) and g2(, ) must be zero since the real and imaginary parts separate. If we let

then

is equivalent to (2).

        The first thing you need to do in this assignment is to identify g1(, ; a) and g2(, ; a) to create the function Gcubrt(, a) and implement it in MATLAB. You then need to compute the Jacobian

and create the matrix valued function Jcubrt() in MATLAB.

        Using these two functions, create a MATLAB function with the first three lines are

function [z, niter] = ComCubrt(a)

avec=[real(a); imag(a)]; % Represent the complex number a as the vector avec zvec=avec; % Just make a the initial guess for its cube root

Here a is a complex number and z is one of its cube roots. The parameter niter is the number of iterations required. ComCubrt(a) finds from a using Newton’s method for two variables.

        The last line of ComCubrt should be

so that you can return a complex number as your answer.

        Your iteration will produce a sequence of 2-vectors which terminates when

or

where

and is the value from the MATLAB eps command. For debugging reasons, do no more than 25 iterations. Of course, do not keep all of the iterates , just keep the two most recent ones so that you implement the termination criteria.

        Use your routine to find the cube roots of a = 3 + 4i, 10 5i, 1 + 2i.