Trying to make an Adams-Bashforth method with Richardson error estimate

5 vues (au cours des 30 derniers jours)
ce
ce le 10 Déc 2022
Modifié(e) : Mayank Sengar le 12 Jan 2023
%This program solves the initial value problem
% y' = f(x,y), x0 <= x<= b, y(x0)=y0
%Initializing vaiables
%f'(x,y)=
f = @(x,y) cos(y).^2; %derivative in question
g = @(x) atan(x); %this is the actual solution
x0 = 0; %initial value of x
x_end = 10; %end of approximation
h = 0.1; %size of decimal place (0.1,0.001,etc
y0=0; %initial value of y
n = fix((x_end-x0)/h)+1;
x = linspace(x0,x_end,n);
y = zeros(n,1);
y(1) = y0;
f1 = f(x(1),y(1));
y(2) = y(1)+h*f1;
%need to add error
for i = 3:n
f2 = f(x(i-1),y(i-1));
y(i) = y(i-1)+h*(3*f2-f1)/2;
f1 = f2;
fprintf('%5.4f %11.8f\n', x(i), y(i));
plot(x(i),y(i),'b.'); grid on;
fplot(g,[x0,x_end]);
xlabel('x values'); ylabel('y values');
hold on;
end
I'm not sure how I would add the Richardson error to this code. I see the formula in my textbook, but don't understand how I would make it work. . Like I don't really know what that means. I understand the AB method for solving DefEqs, but not ther errors
  1 commentaire
Torsten
Torsten le 10 Déc 2022
Modifié(e) : Torsten le 10 Déc 2022
I'm confident that after reading this article
you will know how Richardson extrapolation works.

Connectez-vous pour commenter.

Réponses (1)

Mayank Sengar
Mayank Sengar le 12 Jan 2023
Modifié(e) : Mayank Sengar le 12 Jan 2023

Catégories

En savoir plus sur Programming 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!

Translated by