Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please label all plots and tables and include any MATLAB scripts and functions with your solution. 1. Consider the following finite difference quotients (one-sided formula)
Please label all plots and tables and include any MATLAB scripts and functions with your solution. 1. Consider the following finite difference quotients (one-sided formula) (2+h)-f(x) ; (centered formula) mule f(x+h)-f(x - h) 2h each of which approximates the derivative f'(x) of a differentiable functions. Write MATLAB functions, with calling sequences (fp for f prime) fp = onesidediff(f,x,h) and fp = centerdiff(f,x,h), which evaluate these quotients on a vector x, given a scalar h and a general function f passed using the @ notation. Use both MATLAB functions to approximately com- pute the derivative of f(x) = (1+x2)-1 on (-1, 1) using x = linspace(-1,1,100) and h = le-4. Prepare the following plot with two subplots, using the subplot(2,1,1) and subplot(2,1,2) com- mands. The top plot should depict the error (in absolute value) on (-1, 1] between the one-sided approximation and the exact derivative, while the bottom plot should depict the error (in absolute value) on -1, 1 between the centered approximation and the exact derivative
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started