Transcribed TextTranscribed Text

1. Numerical Differentiation. In Lecture 5b we saw that the forward and backward difference approximations of a function f(x) incur error that scales linearly with the increment h, while the error of the 2-point central difference approximation scales quadratically with h. i.c. it is O(h2) Here you will experiment a bit with these formulas. (a) Follow the guidance in the lecture slides to implement your own MATLAB functions to numeri- cally differentiate the function (1) by (i) the forward difference approximation, and (ii) the central difference approximation The differentiation functions should call a separate function that evaluates equation (1). As with any function, these must clearly describe what they do, what inputs they take, and what outputs they provide. (b) Using your functions from (a), write a script that computes the finite difference approximation at 100 points evenly spaced over the range 10. Choose several differencing increments h over the range 10-16 515 10-1 (where h is varied on a log scale; see logspace), and compute the average error of these finite difference approximations when compared to the exact derivative, - are (2) Construct a log-log plot of the average error vs. h over the range of h.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

function NumDiff()
%We solve part A
'Part A'
%Setting the arbitrary values of step and original point
%Calculating derivatives using the diff function that contains to values of
%input function and step as an input and outputs the approximate value of
'Forward differentiation'
'Backward differentiation'
'Center differentiation'
'Part B'
%We create array of values%
startValue = 1;
endValue = 10;
nElements = 100;
stepSize = (endValue-startValue)/(nElements-1);
A = startValue:stepSize:endValue;...

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available MATLAB for Computer Science Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats