Question: Sequence to SQRT ( 2 ) My Solutions > Consider the sequence 1 , 3 2 , 1 7 1 2 defined by x 1
Sequence to SQRT
My Solutions
Consider the sequence
defined by
for dots,
This sequence converges to as increases. Note that the term in this sequence depends on the term Please do not mistake to simply be
Code has already been provided to define a function named sequenceToSqrt that accepts a single input variable N an integer. Edit the function body to do the following:
Generate a row vector containing the first terms of the sequence. This vector should be the first variable returned by your function. You should do this using a for loop. How do we know a for loop is the correct choice?
Generate a scalar variable that is the relative error, given by the formula below, between the last term in the sequence and This relative error should be the second variable returned by your function. Note that this is a single scalar value that depends on only the last'term of the sequence. You can therefore define the relative error after you've calculated the first terms of the sequence, outside of the looping structure.
Note the value of the variable N is defined as an input to the function. Do not overwrite this value in your code ie do not hardcode a fixed value for into your function Also, notice that the function name, input, and output variables are already defined, so be sure to use these names in your function.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
