Question
Homework 3(Bonus): To approximate f' (x) numerically by generating a table of approximations D(j,k) for k s j including final answer in terms of D(n,
Homework 3(Bonus): To approximate f' (x) numerically by generating a table of approximations D(j,k) for k s j including final answer in terms of D(n, n). The first column in the matrix could be given as follows:
DCi.07=5 (x+2-9h) -11x-2-91)
2-1+1h
and the elements in the row j could be referred as follows:
DU: 10) = DU: + -1) + DU. k-1) -DU - 1, k-1 for 15k5;
Below program implements basically the Richardson extrapolation. The expression for the elements in row j could be algebraically equivalent to Richardson Extrapolation formula given accordingly:
4*Dk-1 (h) - Dx-1 (2h)
f' (x0) =
+ 0(424+2)
4 -
function [D, err,relerr,n]= diffext(f;,x, delta,toler)
%Input
fis the function input as string f
%
delta is the tolerance for the error
%
toler is the tolerance for the relative error
%Output
D is the matrix of approximate derivatives err is the error bound
%
relerr is the relative error bound
%
n is the coordinate of the best approximation
err=1; relerr=1;
h=1; j=1;
D(1,1)=(feval(f,x+h)-feval(f,x-h))/(2*h);
while relerrtoler & errdelta & i<12
h=h/2;
D(j+1,1)=(feval(f,x+h)-feval(f;,x-h))/(2*h);
for k=1:i
D(j+1,k+1)=D(j+1,k)+(D(j+1,k) - D(j,k))/(4^k)-1);
end
err=abs(D(j+1, j+1) - D(j,j)) ;
relerr=2err/(abs(D(j+1,j+1))+abs(D(j,j))+eps);
]=j+1;
end [n,n]=size(D);
You may use above program to approximate the derivative of function
#(x)=60215-32x3+23385-47x2-77;x=1/V3.
Carry 13 decimal places. You may change the initial values of err, relerr, and h.
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