Question: MatLab Help, for loops matlab help. for loop based on convergence. P2. Sequence to SQRT(2) (while loop based on convergence) 0 solutions submitted (max: Unlimited)

MatLab Help, for loops
MatLab Help, for loops matlab help. for loop based on convergence. P2.
matlab help. for loop based on convergence.
Sequence to SQRT(2) (while loop based on convergence) 0 solutions submitted (max:

P2. Sequence to SQRT(2) (while loop based on convergence) 0 solutions submitted (max: Unlimited) Consider the sequence 1. 231217, defined by i1=1,ki=21(xi1+x412)fork=2,3,4,,N The sequance converges on 2 as N increases. The relative error, f, betwoen the Nat term in the sequence and 2 is given by the formua: r=22x Note the vertical bars indicate an absolute value. Code has uready been provided to detine a function named sqrt 2 approx that accepts a single scalar input vailable errorToL. Add commands to use this input value for the error tolerance as the convergence craterion for the sequence. Use a whit te loop to generate sequence terms untit the relatwe ertor, f, is less than or equal to the value in the input tolerance variable er ror Tol. Assign values to the two output variabies as follows. 1. Assign the value of the the last term generated to the variable LastTera 2. Count the mumber of terms needed to meet the tolerance and assign this value with 8 -bit unsigned intoger datatype to the vanablo nenterms Note the value of the variable er ror Tol is defined as an input to the function. Do not ovensite this vatue in your code Be sura to assign a valiae ts aach of the oufput variables. P2. Sequence to SQRT(2) (while loop based on convergence) 0 solutions submitted (max: Unlimited) Consider the sequence 1+23+1217+ definod by x1=1.xk=21(xi1+x412)fork=2,3.4,,N. The sequence comerges on 2 as N inereases. The relative prror, r, between the Nof term in the sequence and 2 is given by fre formula: r=22x Nole the vertical bars indicate an absolute value. Code has abready been proveded to define a function named sqr t2approx that accepts a single seatar irput vaiscie errortol. Add commands to use this input value for the error tolerance as the cocreifpence criterion for the sequence. Use a whil lo bop to generate sequence herma indt the redativo eeror, r, is leas than of equal to the value in the inpol tolerance variable er ror Tol: Assign values to the two outpot vaviables as toliowa i 1. Assign the value of the the iast serm generated to the variable LastTera 2. Count the number of terms needed to meet the tolerance and assign tis value wath 8 -be unsigned integer datatype so the varibbe sumferss Note the value of the variable errortol is defined as an input to the function. Do not overwitle this value in your code. Be sure to assign a valua to each of the output variables

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!