second order of accuracy approximation formula

4 次查看(过去 30 天)
Assuming y (x) is a smooth function defined on the interval [0; 1] ; obtain a second order of accuracy approximation formula for y''' (1): You can make use of MATLAB software to find the unknown coeficients. Write down the formula as a result.
clear
clc
syms x y a b c d e A B C D h
y=@(x,h) a+b*h+c*h^2/2+d*h^3/6; % general form of Taylor series where a=y(0),b=y'(0)..etc are non-zero constants
t=A*y(x,0)+B*y(x,h)+C*y(x,2*h)+D*y(x,3*h); % Find the linear sum of Ay(x)+By(x+h)..etc
eqn1=simplify(subs(t,h,0)/a); % dividing by constant to get the equation
eqn2=simplify((subs(diff(t,h,1),h,0))/b);
eqn3=simplify((subs(diff(t,h,2),h,0))/c);
eqn4=simplify((subs(diff(t,h,3),h,0))/d);
s=solve([eqn1==0,eqn2==0,eqn3==1/h^2,eqn4==1],[A,B,C,D]); % solve the system of equations for A,B,C,D
%solve the system so that the coefficients of y,y',y'' are all 0
%except y''' whose coeff is 1
sol=[s.A;s.B;s.C;s.D]
I made a solution like this, is it correct?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by