Question: Read Problem 1 . 4 . 2 in the Heister and Rebholz text. Write a MATLAB function that will take the values of h and

Read Problem 1.4.2 in the Heister and Rebholz text. Write a MATLAB function that will take the values of h and the sequence of errors and output the corresponding convergence rate. That is, suppose h=[1,1/2,1/4,1/8],e=[1,1/2,1/4,1/8] where e contains the errors. A value of k can be computed using the following script. % store the values of h and e from the texth =[1; 1/2; 1/4; 1/8; 1/16];e =[1; 1/2; 1/4; 1/8; 1/16];% determine the length of the arrays% initialize the array to store the convergence raten = length(h);k = zeros(n-1,1);% loop through the values in the arrays and compute% the convergence ratefor i =1:n-1 k(i)= log(e(i+1)/e(i))/log(h(i+1)/h(i));endTranslate this into a function, letting the array k be the output. Determine whether the value of k is converging to a single number, which would be the convergence rate as discussed in the text.The array of convergence values k can also be computed using vector operations, as long as you grab the appropriate entries in each of the arrays. The array storing k does not have to be initialized in this case.

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!