Question: Matlab SOLVE PART B PART A FINDS APPROXIMATION PART B PLOTS ACTUAL - APPROXIMATION The aim of this lab is to test the accuracy of

Matlab

SOLVE PART B

Matlab SOLVE PART B PART A FINDS APPROXIMATION PART B PLOTS ACTUAL

PART A FINDS APPROXIMATION

PART B PLOTS ACTUAL - APPROXIMATION

- APPROXIMATION The aim of this lab is to test the accuracy

The aim of this lab is to test the accuracy of several finite difference formulas for numerical differentiation. Consider the function f()5 We choose uniformly spaced grid points on the interval -3,3], namely Xi =-3 + ih, where i = 0, , n and h = 6 Create a single script named main.m that does the following: x2 +0.25 ) Numerically approximate f(for i -1, ,n - 1 using the forward difference, backward difference, and central difference scheme. Plot these schemes as well as the actual f'(xi) on the same figure. For example, the figure with n 50 is shown below. Produce a figure for n 50,100 and 200 (3 figures in total, each figure has 4 curves) 4 Forward Backward Central Actual 2 -4 -2 2 4 b) Let e be the absolute error of the numerical derivative at x.In other words, ef(x) -F) where f'(x) is the numerical approximation. Plot the maximum error max e, as a function of n 50,100,200 and 500. In the plot command, include the -o' option to show markers at data points For example, the plot with the central difference scheme is shown below (left panel) 1SSn-1 0.5 100 200 300 400 500 -) , or O(n2). To show this, we can plot log E Note that the theoretical error is - against log n (refer to the loglog command), which is a straight line (right panel). Then, we perform a linear fit, and the slope is the power of n in the big-O notation: >> polyfit (log (N), log (E), 1) % N=[ 50, 100, 200, 500], E contains the maximum errors ans- 1.9775 6.2248 % the linear fit is y = -1.9775 + 6.2248 For each of the three numerical schemes, produce the figures above and perform the linear fit. Make sure that the slope matches the theoretical results

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!