Reference no: EM132641028
Write a computer program for each problem.
Question 1. Use the lagrange interpolation polynomial that pisses through the following data points:
|
xi
|
-4
|
-3
|
-2
|
-1
|
0
|
|
yi
|
5
|
0
|
3
|
2
|
9
|
to estimate the ue of y at x = -2.5.
2. For the following data set
(a) construct two types of cubic spline approximation (with the efficient implementation) using the following boundary conditions:
i. f"(xo) = f"(xn) = 0
ii = f"(xo) = f"(x1) and f"(xn) = f"(xn-1)
(b) plot the two cubic splines in the same figure over the interval x ∈ (0,31 for comparison.
(c) use the above cubic splines to evaluate the y value at x = 2.5.
3. Using the data in the following table to fit a quadratic polynomial to the data:
|
x,
|
0.0
|
0.2
|
0.4
|
0.6
|
0.8
|
1.0
|
|
yi
|
0.00
|
1.05
|
0.85
|
0.35
|
0.10
|
1.00
|
namely, find a quadratic polynomial
y = ao + a1x + a2x2
where a0, a1 and a2 are the three coefficients to be determined using the least square approach.
(a) Approach I: form an overdetermined system Ax = b
yt = ao + a1x1 + a2xt2 for 0 ≤ i ≤ 5
then form a square system by multiplying the overdetermined system by AT, the transpose of A, i.e.
ATAx = ATb
which can be solved using LAPACK's LU decomposition routines.
(b) Approach 2: use the following LAPACK routine
void dgels_(char *TRANS ,int *M, int *N, int *NRHS, double *A, int *LDA, double *b, int *LDB, double *WORK, int *LWORK, int *INFO):
to directly solve the overdetermined system.
(c) Approach 3: follow the standard least square procedure to minimize the sum of error square
minimize ε = ∑5t=0(a0 + a1x1 + a2xi2 - yt)2
which can be achieved by setting the partial derivative of ε with respect to a0, a1 and a2 equal to zero:
∂ε/∂a0 = 0
∂ε/∂a1 = 0
∂ε/∂a2 = 0
which forms a 3 x 3 linear system to be solved.