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

In matlab Newton\'s Method Create an m-file newtLast.m that applies Newton\'s Me

ID: 3802511 • Letter: I

Question

In matlab Newton's Method

Create an m-file newtLast.m that applies Newton's Method until f(z) is below a predefined tolerance toi-ie-6. The function newtLast.m should take as an input z and returns the approximate root z and the number of iterations it needed to converge. Create two subfunctions f and fp in the same m-file that defines the function f(z) = z^3 - 3^z and its derivative, respectively. Calculate the number of iterations for Newton's Method to converge for the complex numbers with Real part: 200 equally spaced points between -5 and 8 Complex part: 200 equally spaced points between -8 and 8 You may want to use the Matlab command meshgrid. Visualize the number of iterations per starting point z by using the Matlab command imagesc. You may want to change the colormap settings.

Explanation / Answer

Matlab code:

clc; clear all;close all;
format long;
r = linspace(-5,8,200);
imag = linspace(-8,8,200);
allzs = [];
iterations = [];
for n = 1:size(r,2)
z=r(n) + 1i*imag(n); % input z
allzs = [allzs, z];
h = (z^3 + 3^z)/(3*z^2 + log(3)*3^z);
i = 1;  
while(abs(z^3 + 3^z) > 10^-6 )
h = (z^3 + 3^z)/(3*z^2 + log(3)*3^z);
z = z - h;
i=i+1;
end
iterations = [iterations,i];
end
C = [0 2 4 ; 8 10 12; 16 18 20 ];
imagesc(allzs,iterations,C)

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