Computer Science, asked by swetaaa2906, 11 months ago

Develop a MATLAB program to determine the numerical error of algebraic approximation of a 1 derivative to an exact function - here approximate df/dx of f(x) = e'. Use double precision.

Definitions:

Taylor series: f(x) = f(x0) + (x-x0) f'(x0) + (x-x) f'(X)/2! + (x-xo) f"(xo)/3! + ...

Backward-difference approx. of df/dx: f'(x) = [ f(x0) – f(xo-h)]/h with h = Ax = small increment Notice this is the approximate derivative only at point xo, not other es of x

Theoretical truncation error by substitution of the Taylor series: f'(X) = [ f(xo) – f(xo-h)]/h

So f(x) = [ f(xo) -{f(xo) + (So-h -x) f'(xo) + (xo-h -Xo)2 f'(Xo)/2! + ... }l/h

*[0-{ (-h) f'(xh)? f"(x/2! +. }}/h

= f'(xo) - (h) f'(x)/2! - term of O(h?) +. the boxed term is the truncation error

Task: Quantify the numerical error of approximating df/dx for the exponential function

Consider f(x) = exp(x) for a range of x values and tabulate numerical errors as point spacing "h changes. For our purposes the Matlab value of exp(x) can be considered "exact. The approximate calculations will yield nearly the same values for df/dx in most cases so we focus on the value of the numerical error in df/dx.

Obtain results at x =- 100500051 1.5, 2.0 with h = 1/2, 1/4, 1/8, 1/16, 1/32

> Specifically find: True Absolute Error in df/dx with given h= f(x) exact -f(x) approx. | F(x) approx. with current-f'(x)

Estimated Abs. Error in sfdx with given h

=

approx. with previous h

Theoretical Truncation Error in df/dx with given h = | leading term in the "box" above Create 3 tables (1 for each error type) with each row in the table for each x and columns for X, exact df/dx, numerical error with h = 1/2, 1/4, 1/8, 1/16 and 1/32

Plot Graph of True Abs. Error of df/dx vs x with curves for h=1/2, h=1/4, h=1/8 - Plot Graph of True Abs. Error of df dx vs h with curves for x=0, x=1, x=2 Comment of the error trends. Are the trends the same pattern for each error definition or significantly different? Do the actual errors follow the theory? How does error vary with

respect to x? How does error vary with respect to h? Specifically is error proportional to (h) where the exponent N is approximately equal to___ ?​

Answers

Answered by lillianmadden
0

Answer:

Develop a MATLAB program to determine the numerical error of algebraic approximation of a 1st derivative to an exact function - here approximate df/dx of f(x) = ex. Use double precision. Definitions: Taylor series: f(x) = f(x0) + (x-xo) f'(x0) + (x-Xo)2 f”(xo)/2! + (x-xo)3 f”(xo)/3! + ... Backward-difference approx. of df/dx: f'(x0) = [ f(xo) – f(xo-h)]/h with h = ax = small increment Notice this is the approximate derivative only at the point xo, not at other values of x. Theoretical truncation error by substitution of the Taylor series: f'(xo) –[ f(xo) – f(xo-h)]/h So f'(xo) — [ f(xo) – {f(x0) + (xo-h -xo) f'(x0) + (xo-h - x0)2 f'(xo)/2! + ... }]/h =[0-{ (-h) f'(x0) + (-h)2 f”(xo)/2! + ... }] /h f'(xo) - (h) f'(xo)/2! – term of O(H2) + ... the boxed term is the truncation error + Task: Quantify the numerical error of approximating df/dx for the exponential function Consider f(x) = exp(x) for a range of x values and tabulate numerical errors as point spacing “h” changes.

Explanation:

Similar questions