Obtaining a fourth order of accuracy approximation formula for y''(0) and findind rhe unknown coefficients
2 ビュー (過去 30 日間)
古いコメントを表示
I want to obtain a fourth order of accuracy approximation formula for y''(0). I want to create MATLAB application to find the unknown coefficients. I wrote a code but I could not declare function so I could not display function and find the unknown coefficiets. The code I wrote it as follows:
How can I declare and display the function ? Thanks for everything.
function accuracyapprox()
syms h;
A = [1 1 1 1 1 1; ...
0 h 2*h 3*h 4*h 5*h; ...
0 h^2/2 2*h^2 9*h^2/2 8*h^2 25*h^2/2; ...
0 h^3/6 8*h^3/6 27*h^3/6 64*h^3/6 125*h^3/6; ...
0 h^4/24 16*h^2/24 81*h^4/24 256*h^4/24 625*h^4/24; ...
0 h^5/120 32*h^5/120 243*h^5/120 1024*h^5/120 3125*h^5/120];
B = [0 0 1; 0 0 0];
R = inv(A) * B;
end
3 件のコメント
回答 (1 件)
John D'Errico
2019 年 5 月 6 日
Save this function as an m-file, NOT in the MATLAB directories, but on your search path.
function ypp = accuracyapprox
syms h
A = ((0:5)*h).^((0:5).')./factorial(0:5).';
ypp = pinv(A)*[0;0;1;0;0;0];
Now, use the function.
ypp = accuracyapprox
ypp =
15/(4*h^2)
-77/(6*h^2)
107/(6*h^2)
-13/h^2
61/(12*h^2)
-5/(6*h^2)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Classical Mechanics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!