Transcribed TextTranscribed Text

1. Consider f(x) = xe−6x and the interpolating points {xi} 5 i=0 = {0, 0.2, 0.4, 0.6, 0.8, 1}. You may use the built-in MATLAB function spline or myspline on the course webpage in the following calculations. (a) Complete the MATLAB code myspline.m on the course webpage by adding the endpoint conditions for clamped splines. Attach your code to the report. (b) Compute the natural cubic spline S(x) that interpolates f(x) at the given points. Find S0(x) and S4(x), and verify that they satisfy the natural boundary conditions. You need to use myslpine for this problem since the built-in spline does not have the option of natural spline. (c) Compute the clamped cubic spline s(x) that interpolates f(x) at the given points. Find s0(x) and s4(x), and verify the boundary conditions at x0 and x5. (d) Compute the not-a-knot cubic spline Sˆ(x) that interpolates f(x) at the given points. Find Sˆ 0(x) and Sˆ 1(x), and verify that Sˆ (k) 0 (x1) = Sˆ (k) 1 (x1) for k = 0, 1, 2, 3. (e) Compare f(x) and these three cubic splines on the same plot. For each method, compute the maximum error at points x = 0 : 0.001 : 1. (You may use MATLAB function ppval to evaluate a piecewise polynomial at different points.) Discuss the quality of the approximations. Which one is the most accurate and which is the least accurate? Explain the reason in your own words. 2. Consider f(x) = xe−6x , 0 ≤ x ≤ 1. (a) Write a MATLAB script file using spline (with the option of clampled spline) to interpolate this function at equidistant points xi = ih, i = 0, 1, · · · n, where h = 1/n. Generate data to complete the following table. For each grid spacing, obtain the actual (numerical) error enum(h) and compute the numerical order of accuracy α. Is α consistent with your expectation? Find the error bound for each grid spacing. Does the error bound provide a good estimation of the actual error? Attach your script file to the report. k nk hk |enum(hk)| αk |ebound(hk)| 1 4 1/4 — 2 8 1/8 3 16 1/16 4 32 1/32 5 64 1/64 Here, |enum(hk)| is defined as the maximum error evaluated at x = 0 : 0.001 : 1, for the piecewise interpolating polynomial phk (x) with grid spacing hk: |enum(hk)| = max x=0:0.001:1 |f(x) − phk (x)|. The order of accuarcy α is a number such that the error e(h) = O(h α). The numerical order can be obtained from αk = ln(|enum(hk)|/|enum(hk−1)|) ln(hk/hk−1) . 1 (b) Repeat (a) using piecewise linear interpolation. You may use interp1 with method=‘linear’. 2

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

function Question2()

%clamped spline has endtype 2

%f(x)=x e^(-6x)   f'(x)=(1-6x)e^(-6x)

f=@(x)(x.* exp(-6*x));   df=@(x)((1-6*x).*exp(-6*x));
enum=zeros(1,5);%vector of errors
alpha=zeros(1,5);%vector of orders of precision
for k=1:5
[breaks2, coefs2]=unmkpp(pp2);

for k=2:5
$85.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Numerical Analysis Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats