Question: Consider the function: f ( x ) = 1 / 2 ( x - 2 ) ^ ( 2 ) * [ 2 pi (
Consider the function: fxxpi
Consider the interval: x
Carry out the following tasks
Task :
Compute nx equidistantly distributed discretized points along xand the values in an array named x
Task :
Compute the function values fxfor each value of x and store the results in an array named f
Task :
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 xint
Task :
Interpolate the function values at all xint locations using the following methods:
linear interpolation, store the results in fintlinear hint: interp function
cubic spline interpolation: store the results in fintspline hint: interp function
lagrangian interpolation: store the results in fintlagrange hint: use the provided intlagrangefunction
Task :
Compute the exact values at the interpolation locations xint and store the results in fintexact
Task :
Compute the maximum error between the numerically interpolated values and the exact values for each of the methods and store the results in
elinear
espline
elagrangian
Task :
Plot the results in subplots arranged in lines and column
subplot :
plot fvis vs xvis as solid black line with line width
plot fintlinear vsxint as a solid red line with circles marking the points, use also line width
subplot :
plot fvis vs xvis as solid black line with line width
plot fintspline vsxint as a solid blue line with circles marking the points, use also line width
subplot :
plot fvis vs xvis as solid black line with line width
plot fintlagrange vsxint as a solid green line with circles marking the points, use also line width
MATLAB Code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
