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

The almost universally used algorithm to compute a, where a > 0, is the recursio

ID: 3888756 • Letter: T

Question

The almost universally used algorithm to compute a,
where a > 0, is the recursion

The trick for doing this is to use Newton’s
method to compute 1 a , and then obtain a by multipling by a. Write down your recur-
sion formula for computing 1 a in a manner similar to (3). This formula should only involve
addition/subtraction, multiplication and division by 2.

Try you algorithm on the problem of computing 5. As an initial guess use x 0 = 0.5. Report
the values of x 0 , x 1 ,. . . , x 5 in a nice table and
verify that your algorithm is working by
comparing these numbers to the true value of 5

I've tried:

clc
clear all
iteration = 100;
A = 5;
a=1/A;
x=a/2;
xn=1;
tolerance = 10e-16;
f =@x .5*(xn+a/xn)
while f ~= sqrt(A)* tolerance
    x(n+1) = f(x(n));
end  

x(n+1)

but I've been banging my head and am now probably so confused that I'm missing the obvious.

2 3 rt rt

Explanation / Answer

package bookList;

public class RecursiveSequence {

   public static double recursiveSeq(int i,double x){
      
       double x1=0.0;
           int a=5;
       double r=0.5; // means (r=1/2)
      
       double result= r*(x+(a/x));
      
             System.out.println("X"+i+"   "+x+" , Approximate value     "+result);
        if(i==5) return 0.0;     // we can replace i==5 with i==100 .
        else recursiveSeq(++i,result);     // recursive function.
      
       return 0.0;
   }
  
  
   public static void main(String[] args) {
      
       double x0=0.5;
       int i=0;
         RecursiveSequence.recursiveSeq(i,x0);  

   }
      
}

/*

output:-

X0   0.5 , Approximate value     5.25
X1   5.25 , Approximate value     3.1011904761904763
X2   3.1011904761904763 , Approximate value     2.3567372726441826
X3   2.3567372726441826 , Approximate value     2.239157222737191
X4   2.239157222737191 , Approximate value     2.23607010853285
X5   2.23607010853285 , Approximate value     2.236067977500805


*/

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