Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

10:47 PM Mon Jan 27 83% Assignment Details MATH 105LB LAB 20: NUMERICAL ANLYS LAB (44965) Math 105LB Assignment 4 Fall 2020 Due Tue 2/04,

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

10:47 PM Mon Jan 27 83% Assignment Details MATH 105LB LAB 20: NUMERICAL ANLYS LAB (44965) Math 105LB Assignment 4 Fall 2020 Due Tue 2/04, 11pm Write 1. a MATLAB function to calculate the coefficients of the natural spline interpolating polynomial, S 2. a MATLAB function to evaluate the cubic spline interpolating polynomial. 3. a MATLAB script to 1. for n = 30, construct the natural spline polynomial fits (x, f(x)), for i = 1,2..., n + 1 where x = (i - 1), f(x) = 0 if i + (n - 1)/2 and f(x) = 1 if i = (n - 1)/2 2. plot the absolute value of this natural spline polynomial in log scale. 3. using the code for the previous assignment (divided difference), find a Lagrange polynomial fit the same data. 4. plot the Lagrange polynomial (in log scale). 5. for n = 10, construct the natural spline polynomial and the Lagrange polynomial fits (x, f(x)), for i = 1,2...,n+ 1 where x1 = (i - 1), f(x) = |x - . 6. plot the Lagrange polynomial, the natural spline polynomial and f(x) in the same figure. First function: Input: x, y where x is a vector consisting of x;,a is a vector consisting of /(x). Output: a,b,c,d where a,b,c,d are vectors consisting of the coefficients of the cubic spline polynomial, that is, S(x) = a + b)(x - x) + C,(x - x)2 + d. (x - x)? for x [X1, X:+1) function (a,b,c,d] = natural_spline_coeff_NetiDix,a) %% type your code here end Second function: Input: a, b, c, d, x, X, where a,b,c,d are vectors consisting of the coefficients of the cubic spline polynomial and x is a vector consisting of x Output: SX which is the function value of S at point X function (SX] = natural_spline_polynomial_NetID(a,b,c,d,x,x) Submit Assignment Dashboard Calendar S TO DO Notifications M Inbox 10:47 PM Mon Jan 27 83% Assignment Details MATH 105LB LAB 20: NUMERICAL ANLYS LAB (44965) function (SX] = natural_spline_polynomial_NetID(a,b,c,d,x,x) %% Type your code here end Main script: n = 30; %% Step 1: define the vector x %%% type your code here %% Step 2: calculate the vectory %%% type your code here %% Step 3: calculate the coefficients of the natural spline %%% type your code here %% Step 4: plot the graph %%type your code here figure(1);plot(X,abs(sx)) set(gca, 'YScale', 'log') %% Step 5: calculate the coefficients of the Lagrange polynomial %%% type your code here %% Step 6: plot the graph (Lagrange polynomial) %%type your code here figure(2);plot(X,abs(PX)) set(gca, 'YScale', 'log') Submit Assignment Dashboard Calendar S TO DO Notifications M Inbox 10:47 PM Mon Jan 27 83% Assignment Details MATH 105LB LAB 20: NUMERICAL ANLYS LAB (44965) n = 10; X = 0:1:1; y = abs(x-1/2); %% Step 7: calculate the coefficients of the natural spline %%% type your code here %% Step 8: calculate the coefficients of the Lagrange polynomial %%% type your code here %% Step 9: plot the graph (Lagrange polynomial, natural spline, f=abs(X-1/2)) %%% type your code here We can use the following Matlab comment to check your code: Command Output X = (-1,0,1]'; y = (-1,0,1); [a,b,c,d) = natural_spline_coeff_NetID(x,y) X = 1/2 [SX] = natural_spline_polynomial_NetID(a,b,c,d,x,X) Submit Assignment Dashboard Calendar S TO DO Notifications M Inbox 10:47 PM Mon Jan 27 83% Assignment Details MATH 105LB LAB 20: NUMERICAL ANLYS LAB (44965) %% Step 9: plot the graph (Lagrange polynomial, natural spline, f=abs(X-1/2)) %%% type your code here We can use the following Matlab comment to check your code: Command Output X = (-1,0,1)'; y = (-1,0,11'; [a,b,c,d) = natural_spline_coeff_NetlDixy) X = 1/2; (SX] = natural_spline_polynomial_NetID(a,b,c,d,x,X) SX = 0.5000 Submit three files named by your UCInetiD (e.g. Lagrange_interpolation_wtleung.m) that contains the functions. Your code will be tested on a few problems. Your grade of this assignment is calculated by the number of problems that your code solves correctly. Make sure your function runs without errors and has the same order of input above. Failure to do so will result in a zero grade. Submit Assignment Dashboard Calendar S TO DO Notifications M Inbox 10:47 PM Mon Jan 27 83% Assignment Details MATH 105LB LAB 20: NUMERICAL ANLYS LAB (44965) Math 105LB Assignment 4 Fall 2020 Due Tue 2/04, 11pm Write 1. a MATLAB function to calculate the coefficients of the natural spline interpolating polynomial, S 2. a MATLAB function to evaluate the cubic spline interpolating polynomial. 3. a MATLAB script to 1. for n = 30, construct the natural spline polynomial fits (x, f(x)), for i = 1,2..., n + 1 where x = (i - 1), f(x) = 0 if i + (n - 1)/2 and f(x) = 1 if i = (n - 1)/2 2. plot the absolute value of this natural spline polynomial in log scale. 3. using the code for the previous assignment (divided difference), find a Lagrange polynomial fit the same data. 4. plot the Lagrange polynomial (in log scale). 5. for n = 10, construct the natural spline polynomial and the Lagrange polynomial fits (x, f(x)), for i = 1,2...,n+ 1 where x1 = (i - 1), f(x) = |x - . 6. plot the Lagrange polynomial, the natural spline polynomial and f(x) in the same figure. First function: Input: x, y where x is a vector consisting of x;,a is a vector consisting of /(x). Output: a,b,c,d where a,b,c,d are vectors consisting of the coefficients of the cubic spline polynomial, that is, S(x) = a + b)(x - x) + C,(x - x)2 + d. (x - x)? for x [X1, X:+1) function (a,b,c,d] = natural_spline_coeff_NetiDix,a) %% type your code here end Second function: Input: a, b, c, d, x, X, where a,b,c,d are vectors consisting of the coefficients of the cubic spline polynomial and x is a vector consisting of x Output: SX which is the function value of S at point X function (SX] = natural_spline_polynomial_NetID(a,b,c,d,x,x) Submit Assignment Dashboard Calendar S TO DO Notifications M Inbox 10:47 PM Mon Jan 27 83% Assignment Details MATH 105LB LAB 20: NUMERICAL ANLYS LAB (44965) function (SX] = natural_spline_polynomial_NetID(a,b,c,d,x,x) %% Type your code here end Main script: n = 30; %% Step 1: define the vector x %%% type your code here %% Step 2: calculate the vectory %%% type your code here %% Step 3: calculate the coefficients of the natural spline %%% type your code here %% Step 4: plot the graph %%type your code here figure(1);plot(X,abs(sx)) set(gca, 'YScale', 'log') %% Step 5: calculate the coefficients of the Lagrange polynomial %%% type your code here %% Step 6: plot the graph (Lagrange polynomial) %%type your code here figure(2);plot(X,abs(PX)) set(gca, 'YScale', 'log') Submit Assignment Dashboard Calendar S TO DO Notifications M Inbox 10:47 PM Mon Jan 27 83% Assignment Details MATH 105LB LAB 20: NUMERICAL ANLYS LAB (44965) n = 10; X = 0:1:1; y = abs(x-1/2); %% Step 7: calculate the coefficients of the natural spline %%% type your code here %% Step 8: calculate the coefficients of the Lagrange polynomial %%% type your code here %% Step 9: plot the graph (Lagrange polynomial, natural spline, f=abs(X-1/2)) %%% type your code here We can use the following Matlab comment to check your code: Command Output X = (-1,0,1]'; y = (-1,0,1); [a,b,c,d) = natural_spline_coeff_NetID(x,y) X = 1/2 [SX] = natural_spline_polynomial_NetID(a,b,c,d,x,X) Submit Assignment Dashboard Calendar S TO DO Notifications M Inbox 10:47 PM Mon Jan 27 83% Assignment Details MATH 105LB LAB 20: NUMERICAL ANLYS LAB (44965) %% Step 9: plot the graph (Lagrange polynomial, natural spline, f=abs(X-1/2)) %%% type your code here We can use the following Matlab comment to check your code: Command Output X = (-1,0,1)'; y = (-1,0,11'; [a,b,c,d) = natural_spline_coeff_NetlDixy) X = 1/2; (SX] = natural_spline_polynomial_NetID(a,b,c,d,x,X) SX = 0.5000 Submit three files named by your UCInetiD (e.g. Lagrange_interpolation_wtleung.m) that contains the functions. Your code will be tested on a few problems. Your grade of this assignment is calculated by the number of problems that your code solves correctly. Make sure your function runs without errors and has the same order of input above. Failure to do so will result in a zero grade. Submit Assignment Dashboard Calendar S TO DO Notifications M Inbox

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

a. Did you express your anger verbally? Physically?

Answered: 1 week ago