Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider a function/from the complcx plane to the complex plane. Suppose we want

ID: 3403030 • Letter: C

Question

Consider a function/from the complcx plane to the complex plane. Suppose we want to find the zeros of f. Newton's method is a commonly used method for finding zeros of a real valued function over real values. It turns out that Newton's method is also valid for functions of a complex variable. Newton's method to find the zeros of f(z) = 0 is the given by the iteration: Z_n+1 = Z_n - f(Z_n)/f^1(Z_n), for n Greaterthanorequalto 0 and z_0 is an initial guess. 1) Write a MATLAB function that implements Newton's method for finding the zeros a complex valued function f, and that uses an initial guess as an input. Check the code using a function of your choice and verify that the program works. 2) Consider the rectangle R in the complex plane such that -1 lessthanorequalto x lessthanorequalto l-l lessthanorequalto y lessthanorequalto 1 with z = x + iy. Select a large number of values in R and use them as initial values for Newton's method using the function f(z) = z^3 -1. For each initial guess in R, determine to which root it will converge when we apply Newton's method. Keep in mind that the zeros of/are the cubic roots of unity. Color code the roots and .j give a plot of R such that each point that was chosen as an initial value is displayed with the color associated with the root that Newton's method found.

Explanation / Answer

MATLAB code for both the parts.

In the second part, the initial guess values can be changed (by changing the values in the x and y array)

clear all
clc
%% PART 1

f=inline('z^2-1'); % complex function
df=inline('2*z'); % differential of the function
z0=0.5; % initial guess
tolerance=1.0e-6;
zprev=z0;
z = z0 - f(z0)/df(z0);
k = 0;
while abs(z - zprev) > tolerance
zprev = z;
z = z - f(z)/df(z);
k = k + 1;
end

%% PART 2

f=inline('z^3-1');
df=inline('3*z^2');
tolerance=1.0e-6;

x=[0.5 0.75 -0.8 -1 -0.62]; % real part of z
y=[0.4 0.90 0.64 0.3 1]; % imaginary part of z

z0=zeros(1,5);
z_solution=zeros(1,5);
mrk={'d','+','*','.','s'};
clr={'r','b','m','c','g'};

for ii=1:length(x)
z0(1,ii)=sqrt(x(ii)^2+y(ii)^2); % initial guess
zprev=z0(1,ii);
z = z0(1,ii) - f(z0(1,ii))/df(z0(1,ii));
k = 0;
while abs(z - zprev) > tolerance
zprev = z;
z = z - f(z)/df(z);
k = k + 1;
end
z_solution(1,ii)=z;
plot(z0(1,ii),z_solution(1,ii),'LineStyle','none','Marker',mrk{ii},...
'Markersize',10,'Color',clr{ii})
hold on
  
end

xlabel('Initial Guess')
ylabel('Obtained solution')

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote