Use Matlab to run the code shown below, which attempts to numerically compute y-
ID: 2253531 • Letter: U
Question
Use Matlab to run the code shown below, which attempts to numerically compute y--(sin x) using the classical definition f'(x)-lim smaller values of h. 5. f(x+h)-C) for increasingly h=1; x0.5 for i- 1:30 y(i) (sin(x + h) - sin(x))/h; error(i)abs (cos (x) y(i)) end le a) (2 points) As b) (3 points) As h gets smaller, what trend do you observe in the value of y (the h gets smaller, what trend do you observe in the value of err? approximated answer)? c) (4 points) Compute the value of the numerator (sin(x + h) - sin(x)) independently, so that you can interrogate it indepdendently. What do you notice about the computed value of the numerator as the value of h gets small? How do you reconcile this with the fact that it is possible for the machine to accurately represent values of h that are much smaller than 10(-16)? d) (2 points) What is the essential reason for the failure of this algorithm? Please note: you do not need to turn in a printout from running the Matlab code.Explanation / Answer
(a) As h gets smaller, the value of error gradually decreases from 0.0687 to 1.1842e-08 and becomes constant at 1.1842e-08, and finally increases from 1.1842e-08 to 0.8776 and becomes constant at 0.8776.
(b) As h gets smaller, the value of y gradually decreases from 0.8089 to 0.8776 and becomes constant at 0.8776, and finally decreases from 0.8776 to 0 and becomes constant at 0.
(c) As the value of h gets smaller, value of the numerator decreases from 0.2022 to 0 and becomes constant at 0.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.