Question: While - Iterate until My Solut Let's consider the following sequence: 1. 1.3.12 17 2'12 Which is defined by: x1 = 1,x2= X-1 + for

 While - Iterate until My Solut Let's consider the following sequence:1. 1.3.12 17 2'12 Which is defined by: x1 = 1,x2= X-1

While - Iterate until My Solut Let's consider the following sequence: 1. 1.3.12 17 2'12 Which is defined by: x1 = 1,x2= X-1 + for k= 2,3,4,...N X-1 Let's break this down before we make use of the sequence. Everytime we increase k, we find a new xx. But to do so, we calculate the new x based on the equation, which also references the previous value of x. We call that previous value of x, XR-1 This sequence converges on V2 as Nincreases, which allows us to approximate the actual square root of 2. We can define the absolute error with this equation: e=V2 - xyl Maybe it's been a while since you've seen these verticle bars in an equation. These denote the absolute value of what's inside. A template has been provided below to start with some assumptions, such as the naming of the variables you need to use. Given the tolerance provided (maximum error tolerated), find the number of times the sequence needs to step through to get to this maximum error. As a hint, start your while loop first, with a test that will enter the loop, and stay in the loop, until the error is smaller than our tolerance. Make sure you add "end" at the end of this loop too! Next, write out the code to support calculating what the sequwnce term is for this k. 1 errortol = le-15 % The tolerance used as the convergence criterion. This is set, and should not be changed. 2 %% 3 errorAbsolute = 100; % We are going to start with a predefined error, that we know will enter a while loop. 4 numTerms = 0; % We can initialize the number of terms to zero, and ... 5 lastTerm = 1; % intialize the first term to one. But after this, we need to calculate each term 6 while ( ) % Fill in this blank, what will you use as a test condition? lastTerm - % this is the same as x_k, right? errorAbsolute = % update the absolute error % how can we track how many terms in we are? 7 8 9 10 11 % what comes at the end of a while loop? 12 13 % Finally, output the three variables we will be testing against, that's numTerms, lastTerm, and errorAbsolute

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!