# write three separate mtalab programs to approximate the sine curve using curving fitting by a polynomial curve a cubic spine and lagrange s interpolating polynomial investigating the quality and error of the fitting produce a report with diagrams

Write three separate MATLAB programs to approximate the sine curve between 0 and 2Ï€ using curve fitting by a polynomial curve of power 4; a cubic spline; Lagrangeâ€™s interpolating polynomial or Newtonâ€™s interpolating polynomial.

For each of the three cases, you should generate points on the curve at regular intervals and use these points as your data points for the curve fitting. Use the same set for each of the three approximations.

1. For each case, investigate the quality of the fitting with varying number of data points. You can study that qualitatively by plotting the original curve on top of the fitted curves, together with the curve of the difference between the two. Compare the three results and comment on your observations. Use at least three different numbers of data points. You can choose your own numbers. But be sensible, use numbers that are not too low and not too high. (Anything up to the power of the curve is too low; anything beyond 100 is too high.)

For the case of the cubic spline, you may consider the use of â€œnatural splinesâ€ which has zero curvature at the free ends of the curve (curvature is a function of the second derivative of the curve). You can use this as a part of the boundary conditions of the curve.

2. For each case, for one specific number of data points only (you decide that number) investigate the behaviour of the fitted curves when there are some errors in the input data. You can manufacture the errors artificially by changing some (or all) of the original values slightly for the given angles. This error should be random, and therefore different for different points. Your investigation should be systematic, by studying different error magnitudes progressively; this means varying the bound of the error magnitude in each study. Comment on the results. (This can be an endless investigation if you are to vary the data many times. So letâ€™s keep it to three.)

You should produce a report showing your results and commenting on the above investigations, supported by graphical outputs. Of course, your report should show the data you use for every case.