Obtaining a fourth order of accuracy approximation formula for y''(0) and findind rhe unknown coefficients
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
John D'Errico
le 6 Mai 2019
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 commentaires
Voir également
Catégories
En savoir plus sur Classical Mechanics dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!