Use Mat Lab to write a function called forwarddiff.m that takes data sample loca
ID: 3812435 • Letter: U
Question
Use Mat Lab to write a function called forwarddiff.m that takes data sample locations and function samplings at those locations as inputs and returns an approximation of the derivative at the sample points based on forward finite difference method with order of accuracy O(h^3). The function should display nothing to the screen unless an error or warning occurs. The detailed specification is as follows: The approximation of derivative by forward difference method (for O(h^3) is given as: f' (x_1) = -f(x_i + 2) + 6f(x_i + 1) - 3f(x_i) - 2f(x_i - 1)/6h Valid call: I = forwarddiff(x, fx) Inputs: x: (N-element vector) numerical data for sample locations. fx: (N-element vector) function data taken at locations defined in input x. Output: I: Approximation for the first derivative of fx at data points 2 to N-2. Assumptions: The ith element of x corresponds to the ith element of fx. Validation: Your code should throw an error if any of the following are true: x and fx are not the same length either of the inputs are not vectors (e.g., a matrix) either of the inputs contains something other than numerical dataExplanation / Answer
Hi
I didn't find any question here. It is suggested to post a valid question more specifc and detailed.
Check the content before you post.
Thanks
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.