1) Write a function divdiff in matlab. The function should read in two vectors x and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1) Write a function divdiff in matlab. The function should read in two vectors x and y, and returns a table (a matrix) of the divided difference values. The prototype of the function is: function a = divdiff(x, y) tinput: x, y: the data set to be interpolated Soutput: a: a table for Newton's divided differences 2) Write a function called polyvalue, that reads in the table of divided difference values generated by the function divdiff, the x-vector, and a vector t. The output of the function should be the values of Newton't polynomial computed at points gives in the vector t. The prototype of the polyvalue function is function v = polyvalue (a, x, t) $ input: a = Newton's divided differences x = the ponts for the dataset, same as in divdiff t = the points where the polynomial should be evaluated 3) Test your Matlab functions in a and b using 11 equally spaced nodes on the interval [-5, 5] (>> x = -5:5 ), find the interpolating polynomial p of degree 10 for the function f (x) = (x2 + 1)-1. Plot the function f(x) using the matlab ezplot function. Then on the same plot (use hold on) plot p(x) at the 11 point. Does it work well or poor? explain why? 4) Now, use the cubic spline interpolation provided by the matlab functions spline and ppval to generate the interpolation assuming natural cubic spline. Plot the result on the same plot as in three. 5) Repeat (4), but now use clamped cubic spline instead. You can do that by differentiating the function and finding f'(-.5) and f'(.5). Plot the result on the same plot as in 3 and 4. Your final result should look something like the following figure. 1/(x2 + 1) actual 1 nodes interpolated 0.9 natural cubic ....clamped 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.10 -3 -2 -1 1 3. 2. m.m.m m.m.m mimo (x), What to turn in: Submit a zip file that contains the required matlab files that would generate a figure similar to the above figure. Explain which method is the best for this problem, natural cubic spline or clamped cubic spline or Newton's divided difference. 1) Write a function divdiff in matlab. The function should read in two vectors x and y, and returns a table (a matrix) of the divided difference values. The prototype of the function is: function a = divdiff(x, y) tinput: x, y: the data set to be interpolated Soutput: a: a table for Newton's divided differences 2) Write a function called polyvalue, that reads in the table of divided difference values generated by the function divdiff, the x-vector, and a vector t. The output of the function should be the values of Newton't polynomial computed at points gives in the vector t. The prototype of the polyvalue function is function v = polyvalue (a, x, t) $ input: a = Newton's divided differences x = the ponts for the dataset, same as in divdiff t = the points where the polynomial should be evaluated 3) Test your Matlab functions in a and b using 11 equally spaced nodes on the interval [-5, 5] (>> x = -5:5 ), find the interpolating polynomial p of degree 10 for the function f (x) = (x2 + 1)-1. Plot the function f(x) using the matlab ezplot function. Then on the same plot (use hold on) plot p(x) at the 11 point. Does it work well or poor? explain why? 4) Now, use the cubic spline interpolation provided by the matlab functions spline and ppval to generate the interpolation assuming natural cubic spline. Plot the result on the same plot as in three. 5) Repeat (4), but now use clamped cubic spline instead. You can do that by differentiating the function and finding f'(-.5) and f'(.5). Plot the result on the same plot as in 3 and 4. Your final result should look something like the following figure. 1/(x2 + 1) actual 1 nodes interpolated 0.9 natural cubic ....clamped 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.10 -3 -2 -1 1 3. 2. m.m.m m.m.m mimo (x), What to turn in: Submit a zip file that contains the required matlab files that would generate a figure similar to the above figure. Explain which method is the best for this problem, natural cubic spline or clamped cubic spline or Newton's divided difference. 1) Write a function divdiff in matlab. The function should read in two vectors x and y, and returns a table (a matrix) of the divided difference values. The prototype of the function is: function a = divdiff(x, y) tinput: x, y: the data set to be interpolated Soutput: a: a table for Newton's divided differences 2) Write a function called polyvalue, that reads in the table of divided difference values generated by the function divdiff, the x-vector, and a vector t. The output of the function should be the values of Newton't polynomial computed at points gives in the vector t. The prototype of the polyvalue function is function v = polyvalue (a, x, t) $ input: a = Newton's divided differences x = the ponts for the dataset, same as in divdiff t = the points where the polynomial should be evaluated 3) Test your Matlab functions in a and b using 11 equally spaced nodes on the interval [-5, 5] (>> x = -5:5 ), find the interpolating polynomial p of degree 10 for the function f (x) = (x2 + 1)-1. Plot the function f(x) using the matlab ezplot function. Then on the same plot (use hold on) plot p(x) at the 11 point. Does it work well or poor? explain why? 4) Now, use the cubic spline interpolation provided by the matlab functions spline and ppval to generate the interpolation assuming natural cubic spline. Plot the result on the same plot as in three. 5) Repeat (4), but now use clamped cubic spline instead. You can do that by differentiating the function and finding f'(-.5) and f'(.5). Plot the result on the same plot as in 3 and 4. Your final result should look something like the following figure. 1/(x2 + 1) actual 1 nodes interpolated 0.9 natural cubic ....clamped 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.10 -3 -2 -1 1 3. 2. m.m.m m.m.m mimo (x), What to turn in: Submit a zip file that contains the required matlab files that would generate a figure similar to the above figure. Explain which method is the best for this problem, natural cubic spline or clamped cubic spline or Newton's divided difference. 1) Write a function divdiff in matlab. The function should read in two vectors x and y, and returns a table (a matrix) of the divided difference values. The prototype of the function is: function a = divdiff(x, y) tinput: x, y: the data set to be interpolated Soutput: a: a table for Newton's divided differences 2) Write a function called polyvalue, that reads in the table of divided difference values generated by the function divdiff, the x-vector, and a vector t. The output of the function should be the values of Newton't polynomial computed at points gives in the vector t. The prototype of the polyvalue function is function v = polyvalue (a, x, t) $ input: a = Newton's divided differences x = the ponts for the dataset, same as in divdiff t = the points where the polynomial should be evaluated 3) Test your Matlab functions in a and b using 11 equally spaced nodes on the interval [-5, 5] (>> x = -5:5 ), find the interpolating polynomial p of degree 10 for the function f (x) = (x2 + 1)-1. Plot the function f(x) using the matlab ezplot function. Then on the same plot (use hold on) plot p(x) at the 11 point. Does it work well or poor? explain why? 4) Now, use the cubic spline interpolation provided by the matlab functions spline and ppval to generate the interpolation assuming natural cubic spline. Plot the result on the same plot as in three. 5) Repeat (4), but now use clamped cubic spline instead. You can do that by differentiating the function and finding f'(-.5) and f'(.5). Plot the result on the same plot as in 3 and 4. Your final result should look something like the following figure. 1/(x2 + 1) actual 1 nodes interpolated 0.9 natural cubic ....clamped 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.10 -3 -2 -1 1 3. 2. m.m.m m.m.m mimo (x), What to turn in: Submit a zip file that contains the required matlab files that would generate a figure similar to the above figure. Explain which method is the best for this problem, natural cubic spline or clamped cubic spline or Newton's divided difference. 1) Write a function divdiff in matlab. The function should read in two vectors x and y, and returns a table (a matrix) of the divided difference values. The prototype of the function is: function a = divdiff(x, y) tinput: x, y: the data set to be interpolated Soutput: a: a table for Newton's divided differences 2) Write a function called polyvalue, that reads in the table of divided difference values generated by the function divdiff, the x-vector, and a vector t. The output of the function should be the values of Newton't polynomial computed at points gives in the vector t. The prototype of the polyvalue function is function v = polyvalue (a, x, t) $ input: a = Newton's divided differences x = the ponts for the dataset, same as in divdiff t = the points where the polynomial should be evaluated 3) Test your Matlab functions in a and b using 11 equally spaced nodes on the interval [-5, 5] (>> x = -5:5 ), find the interpolating polynomial p of degree 10 for the function f (x) = (x2 + 1)-1. Plot the function f(x) using the matlab ezplot function. Then on the same plot (use hold on) plot p(x) at the 11 point. Does it work well or poor? explain why? 4) Now, use the cubic spline interpolation provided by the matlab functions spline and ppval to generate the interpolation assuming natural cubic spline. Plot the result on the same plot as in three. 5) Repeat (4), but now use clamped cubic spline instead. You can do that by differentiating the function and finding f'(-.5) and f'(.5). Plot the result on the same plot as in 3 and 4. Your final result should look something like the following figure. 1/(x2 + 1) actual 1 nodes interpolated 0.9 natural cubic ....clamped 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.10 -3 -2 -1 1 3. 2. m.m.m m.m.m mimo (x), What to turn in: Submit a zip file that contains the required matlab files that would generate a figure similar to the above figure. Explain which method is the best for this problem, natural cubic spline or clamped cubic spline or Newton's divided difference. 1) Write a function divdiff in matlab. The function should read in two vectors x and y, and returns a table (a matrix) of the divided difference values. The prototype of the function is: function a = divdiff(x, y) tinput: x, y: the data set to be interpolated Soutput: a: a table for Newton's divided differences 2) Write a function called polyvalue, that reads in the table of divided difference values generated by the function divdiff, the x-vector, and a vector t. The output of the function should be the values of Newton't polynomial computed at points gives in the vector t. The prototype of the polyvalue function is function v = polyvalue (a, x, t) $ input: a = Newton's divided differences x = the ponts for the dataset, same as in divdiff t = the points where the polynomial should be evaluated 3) Test your Matlab functions in a and b using 11 equally spaced nodes on the interval [-5, 5] (>> x = -5:5 ), find the interpolating polynomial p of degree 10 for the function f (x) = (x2 + 1)-1. Plot the function f(x) using the matlab ezplot function. Then on the same plot (use hold on) plot p(x) at the 11 point. Does it work well or poor? explain why? 4) Now, use the cubic spline interpolation provided by the matlab functions spline and ppval to generate the interpolation assuming natural cubic spline. Plot the result on the same plot as in three. 5) Repeat (4), but now use clamped cubic spline instead. You can do that by differentiating the function and finding f'(-.5) and f'(.5). Plot the result on the same plot as in 3 and 4. Your final result should look something like the following figure. 1/(x2 + 1) actual 1 nodes interpolated 0.9 natural cubic ....clamped 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.10 -3 -2 -1 1 3. 2. m.m.m m.m.m mimo (x), What to turn in: Submit a zip file that contains the required matlab files that would generate a figure similar to the above figure. Explain which method is the best for this problem, natural cubic spline or clamped cubic spline or Newton's divided difference.
Expert Answer:
Answer rating: 100% (QA)
Mtlb de fr Newtn divide differene frmultin ler ll lse ll funtin fr whih interltin hve t d fx x211 ll ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
(a) Show that, for all vectors x and y in an inner product space, ||x + y||2 + ||x - y||2 = 2 (||x||2 + ||y||2). (b) Interpret this result pictorially for vectors in R2 under the Euclidean norm.
-
Find vectors x and y in R2 that are orthonormal with respect to the inner product (u, v) = 3u1v1 + 2u2v2 but are not orthonormal with respect to the Euclidean inner product.
-
Find vectors x and y with ||x|| s = 1 and ||y|| m = 1 such that ||A|| 1 = ||Ax|| s and ||A|| = ||Ay|| m , where A is the matrix in the given exercise. Exercise 23 Data From Exercise 23 A = 3
-
WiCom Servicing completed these transactions during November 2020, its first month of operations: Required 1. Prepare journal entries to record the transactions. Use general journal page 1. 2. Set up...
-
Is injecting medical cement effective in reducing pain for people who have suffered fractured vertebrae? The paper A Randomized Trial of Vertebroplasty for Osteoporotic Spinal Fractures (New England...
-
In the water pump of Problem 10.8, the pump casing acts as a diffuser, which converts 60 percent of the absolute velocity head at the impeller outlet to static pressure rise. The head loss through...
-
What is a motion for judgment on the pleadings?
-
You are the human resources manager for a famous retailer, and you are trying to convince the president of the company to change the structure of employee compensation. Currently, the companys retail...
-
Vaughn Corporation's December 31, 2021 balance sheet showed the following: 8% preferred stock, $20 par value, cumulative, 14300 shares authorized; 9300 shares issued $186000 Common stock, $10 par...
-
The results below are based on data collected as part of a student project for an introductory statistics class at UF. If there is more than one group/treatment, the first group mentioned is group 1....
-
Why are economists unable to come up with a systemic policy response to capital flows? Explain
-
The TXJ Companies, Inc., which operates the T.J. Marx, Mitchells, and Good Home chains, is the leading off-price apparel and home fashions retailer in the U.S. and worldwide. Presented here are...
-
Explain why the state of the economy is such an important consideration to your brand suncor energy and oil. Why would your brand/your brands company suncor energy and oil consistently consider both...
-
What mechanisms can be implemented within an organization to promote transparency and ethical consistency, thus reinforcing a strong moral compass in business practices ?
-
You invest $1000 in 2 ETF. Assume that normal ETF return = Rm. Suppose this year's Rm = 8%, risk free rate = 1%, buying on leverage rate = 1%. Your rate of return (of $1000) this year is?
-
Compute each: current ratio, quick ratio, return on investment, return on equity, debt to equity ratio. Following is the balance sheet of Finch Company for Year 3: FINCH COMPANY Balance sheet Assets...
-
You are advising Loch Lochy Liquors Limited (LLL), manufacturer of a premium Scotch whisky selling under the brand name "Highland Princess". You have been summoned to a meeting of LLL's management...
-
When a company has a contract involving multiple performance obligations, how must the company recognize revenue?
-
In the ice cream cone shown, L = 4 in. and e = 35°. The cone is filled with ice cream such that the portion above the cone is a hemisphere. Determine the volume of the ice cream. L
-
Two vectors are given: u = 5i - 6j + 9k and v = 11i + 7j - 4k Use MATLAB to calculate the dot product u v of the vectors in three ways: (a) Write an expression using element-by-element calculation...
-
Given: x sin axdx = sin ax/a2 x cos ax/a. Use MATLAB to calculate the following definite integral: /33x/2 x sin(0.6x)dx.
-
Covenant Trucking Company uses the units-of-production (UOP) depreciation method because UOP best measures wear and tear on the trucks. Consider these facts about one Mack truck in the company's...
-
PepsiCo, Inc., has acquired several other companies. Assume that PepsiCo purchased Kettle Chips Co. for \(\$ 8\) million cash. The book value of Kettle Chips' assets is \(\$ 12\) million (market...
-
The board of directors of Park Place Porsche is having a quarterly meeting. Accounting policies are on the agenda, and depreciation is being discussed. A new board member, an attorney, has some...
Study smarter with the SolutionInn App