Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

PART A FINDS APPROXIMATION

PART B PLOTS ACTUAL - APPROXIMATION

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions

Question

can someone help? \f

Answered: 1 week ago