Starting from:

$25

MA3457- Homework 3 Solved

Your assignment submission should contain a few files. You should submit all of your Matlab code and it should be properly commented to explain what the code is doing. You can submit as separate m-files saved as HW#Q# OR you can submit a single word or text file with all of the code pasted in (specifying or delineating code for each problem). For additional written work and discussion of problems, this should be a single pdf that is well-organized and either typed or neatly written. (If hand-written, use an app to scan and save as a single pdf). This file should be saved as HW#. To receive full credit on a problem, the code must run with no errors and the written work/discussion of the problem must also be complete. Matlab output should be discussed in the write-up.

Cubic Splines
Here, we will assume cubic splines for a set of n ordered data points (x1,y1),...,(xn,yn) are of the

form:
 
 s1(x)

 ...

S(x) =

 sn−1(x)

where the i = 1,...,n − 1 splines are defined as:
x1 ≤ x ≤ x2

...

xn−1 ≤ x ≤ xn
si(x) = ai(x − xi)3 + bi(x − xi)2 + ci(x − xi) + di

It turns out we can use properties of an interpolating function and assumptions of continuity of splines to determine equations for the coefficients in terms of bi = Mi/2 where:

with h = xi − xi−1 for i = 2,...,n. With Boundary Conditions specified for conditions on M1 and

, we can write this system of equations as a linear system AM~ = R~ where we need to solve for

M. Once we have M~ , we then have bi = Mi/2 and di = yi for i = 1,...,n − 1. Then ci and ai can be determined based on bi for i = 1,...,n−1. Refer to slides 16-17 of power point from Tuesday Nov 1st class. It turns out that the matrix A is diagonally dominant. Explain what this property is, why you can see it is true for rows 2,...,n − 2, and how it leads to knowing we can solve for coefficients uniquely.
 We would call A a sparse matrix since it has many entries that are 0’s. As we know from earlier discussions about error, each 0 entry will be represented by its floating point representation in the computer where 0 =. From an error and computational storage standpoint, why does it make sense to use a sparse matrix representation where you only store non-zero entries in the matrix? (Note that Matlab and most programming languages have sparse matrix utilities)
Discrete Least Squares Write a code that takes an input of D for the degree of the least squares polynomial that you want to fit to the data. The data points are x =[1, 1.1, 1.3, 1.5, 1.9, 2.1], y =[1.84, 1.96, 2.21, 2.45, 2.94, 3.18].
1

Determine the discrete least squares polynomials of degrees 1, 2, and 3 for the data.Create a plot for each polynomial fit. Plot both the data points (using a symbol for data in Matlab such as ‘og’ or ‘xg’) and also plot the polynomial at additional points xeval=linspace(0,3,100) with the data.
 Compute the error in each polynomial approximation of degreepn(xi))2 for m data points.

More products