CMPSC/Mathematics 455Final Exam—Part IIDue Friday 2 December 2022Fall 2022You are to write a MATLAB function to implement a table lookup approx-imation of the function sin−1 x = arcsin x for...

Refer to file


CMPSC/Mathematics 455 Final Exam—Part II Due Friday 2 December 2022 Fall 2022 You are to write a MATLAB function to implement a table lookup approx- imation of the function sin−1 x = arcsin x for x ∈ [0, π/4]. You will be using inverse interpolation with cubic splines followed by Newton’s method for correction. A similar approach is discussed in Section 4.9 of the Cleve Moler text- book that is linked to on the class Canvas page. The link for the textbook is //https:www.mathworks.com/moler/chapters.html. The appropriate chapter is called “Zeros and Roots”. There are four steps to this process. 1. Set up Inverse Interpolation. Note that over the domain [0, π/4], sin x has the range [0, √ 2/2]. Let a = 0, b = √ 2/2, h = (b− a)/10. Compute the y values yvals = a:h: b and then compute xvals = sin(yvals) 2. Perform Inverse Iterpolation. After specifying the correct endpoint conditions for a complete spline in the 1 × 2 array endconds, set up the spline with the command pp=csape(xvals,yvals,’complete’,endconds). Then save pp in a .mat file using the command save pparcsin pp thus creating the file ppexp.mat. [Hint: The dervative of f(x) = sin−1 x = arcsin x is f ′(x) = (1− x2)−1/2. ] In Octave, this is slightly different. There is no csape function. Instead you should make the call 1 yspline=[endconds(1) yvals endconds(2)]; pp=spline(xvals,yspline); The rest is the same. 3. Inverse Sine Function. Create the function arcsin with form function [y,y0]=arcsin(x) where y is the computed value of arcsinx = sin−1 x and y0 = ppval(pp, x) is initial guess for our Newton iteration. Its first line of the function should be load pparcsin thereby loading the object pp created in the previous step. That avoids the problem of making pp an extra input parameter. After that, for a given x, you will use Newton’s method to solve the nonlinear equation g(y) = x− sin(y) = 0 with initial guess y0 = ppval(pp, x) to compute y ≈ sin−1 x = arcsinx. Stop your iteration when |g(y)/g′(y)| ≤ tol ∗max([|y| tol]), tol = 10−14 = 1e− 14 or after five iterations whichever comes first. 4. Test your inverse sine function. Do the computation c=xvals(11); hh=c/99; xx=0:hh:c; The MATLAB/Octave functon for sin−1 x = arcsinx is asin. For each value in xx, compute y and y0 using arcsin putting all of these values in two vectors called yy and yy0. In three separate plots, plot yy against xx, plot err = yy − asin(xx) against xx, and err0 = yy0 − asin(xx) against xx. The first plot should look like the inverse sine function, and the other two plots should have small values. Please upload into Canvas all MATLAB functions and scripts new to the final, and all three plots. 2
Dec 01, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here