Question: Write a MATLAB script that uses your NewtonSqrt function file, to compute the square root of prime numbers in the range of x between 80

Write a MATLAB script that uses your NewtonSqrt function file, to compute the square root of prime numbers in the range of x between 80 and 90. Your script should accomplish the following tasks:

(a) List of all prime numbers between 1 and 100

(b) How many prime numbers are these

(c) Subset of prime numbers from (a) between 80 and 90, using the find function

(d)Use an ifend construct to compute the approximate and Matlabs values of the square roots of the subset of prime numbers in (c), with a delta value of 5E3, and maxit of 5.

Here is the function file:

function NewtonSqrtCS3(x,delta,maxit)

format long %long command is inserted

it=0; % variable 'it' is initialized if nargin<2,delta=5E-6;end if nargin<3, maxit=5; end r=x/2; rold=x; %Use fprintf command as a place holder fprintf(' the estimate for the square root of x is ') %disp(['The approach to sqrt(a) for a=',num2str(a)]); %i=0; while abs((r-rold)/rold)>delta || (it>=delta && it<=maxit) it=it+1; %while i<6 rold=r; %Save old value of r for next convergence r=0.5*(rold+x/rold); disp(r) %i=i+1; end fprintf('%14.6f ', r) %disp('Matlab''s value: ') fprintf('Matlab''s value is: ') disp(sqrt(x))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!