Question: Consider the function: f ( x ) = 1 / 2 ( x - 2 ) ^ ( 2 ) * [ 2 pi (

Consider the function: f(x)=1/2(x-2)^(2)*[2pi(0.55)^(2)]
Consider the interval: 0<= x <=4
Carry out the following tasks
Task 1:
Compute nx =41 equidistantly distributed discretized points along xand the values in an array named x
Task 2:
Compute the function values f(x)for each value of x and store the results in an array named f
Task 3:
Compute the points at which the function values should be interpolated as the midpoints between the values stored in x, store the values in the array x_int
Task 4:
Interpolate the function values at all x_int locations using the following methods:
linear interpolation, store the results in f_int_linear (hint: interp1 function)
cubic spline interpolation: store the results in f_int_spline (hint: interp1 function)
lagrangian interpolation: store the results in f_int_lagrange (hint: use the provided int_lagrangefunction)
Task 5:
Compute the exact values at the interpolation locations x_int and store the results in f_int_exact
Task 6:
Compute the maximum error between the numerically interpolated values and the exact values for each of the methods and store the results in
e_linear
e_spline
e_lagrangian
Task 7:
Plot the results in 3 subplots arranged in 3 lines and 1 column
subplot 1:
plot f_vis vs x_vis as solid black line with line width 3
plot f_int_linear vs_x_int as a solid red line with circles marking the points, use also line width 3
subplot 2:
plot f_vis vs x_vis as solid black line with line width 3
plot f_int_spline vs_x_int as a solid blue line with circles marking the points, use also line width 3
subplot 3:
plot f_vis vs x_vis as solid black line with line width 3
plot f_int_lagrange vs_x_int as a solid green line with circles marking the points, use also line width 3
MATLAB Code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!