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

Problem 4 (1 point. Instructor\'s Initials Edmond Halley, British scientist and

ID: 2291337 • Letter: P

Question

Problem 4 (1 point. Instructor's Initials Edmond Halley, British scientist and mathematician for whom Halley's Comet is named, invented a ast algorithm for computing the square root of any positive number A. Start with an initial guess at the square root xi. Then iterate towards a solution using the following 2 relationships: Kmn® (15-Un(10-3%)) These two calculations are repeated until r converges on a solution. Convergence has occurred whern e (epsilon) is called the convergence criterion, and can be as small as desired. Write a program that takes 3 inputs from the user: 1) The number A for which the square root is desired, 2) the initial guess xi for the square root of A, and 3) a value for e. Test your algorithm by finding the square root of 3 with a convergence criterion of ? = .00001. Start with x,-15. Demonstrate operation to the instructor, and print a copy of the program to attach to the lab.

Explanation / Answer

Write the following code in matlab and run it

clc
clear all

A=input('number for which square root to be found=');

x(1)=input('please enter the intial guesss=');
tol=input('please enter the tolerance criteria=');
n=0; %n denotes the iteration

  
for n=1:1000 % iteration number loopin
y(n)=x(n)^2/A;

  
  
x(n+1)=(x(n)*(15-(y(n)*(10-3*y(n)))))/8; %newton raphson iteration formula
if abs(x(n+1)-x(n))<tol %checks the condition when mismatch is less than 10e-5
fprintf('the final value of x(n+1) is %d and this took iteration %d .',x(n+1),n);
return;
end
end

RESULT

Checking the program for number A=3

number for which square root to be found=3
please enter the intial guesss=1.5
please enter the tolerance criteria=0.00001
the final value of x(n+1) is 1.732051e+00 and this took iteration 3 .

This shows it took three iteration to find square root of 3 =1.732051 with intial guess 1.5 .

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