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

3 ビュー (過去 30 日間)
ce
ce 2022 年 12 月 10 日
編集済み: Mayank Sengar 2023 年 1 月 12 日
%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 件のコメント
Torsten
Torsten 2022 年 12 月 10 日
編集済み: Torsten 2022 年 12 月 10 日
I'm confident that after reading this article
you will know how Richardson extrapolation works.

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

回答 (1 件)

Mayank Sengar
Mayank Sengar 2023 年 1 月 12 日
編集済み: Mayank Sengar 2023 年 1 月 12 日

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by