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 件のコメント
John D'Errico
John D'Errico 2019 年 5 月 6 日
編集済み: John D'Errico 2019 年 5 月 6 日
#removed, tags repaired.
Kerem Candangil
Kerem Candangil 2019 年 5 月 6 日
I understood. I wanted to ask how we can give matrix realization. Also I wanted to ask how we can construct second order of accuracy difference scheme for numerical solution.

サインインしてコメントする。

回答 (1 件)

John D'Errico
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)

カテゴリ

Help Center および File ExchangeClassical Mechanics についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by