two-step Adams Moulton method
    11 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Hello, 
I want to use two-step Adams Moulton method to solve ODE. The code is given below.
Running this I have problems with dimensions. 
Any help is greatly aprecciated. 
Thank you 
% initialize
f = inline('y/x-y^2/x^2','x','y');
xrange=[1,2];
h=0.1;
x=1:h:2;
n = (xrange(2)-xrange(1))/h;
y(1) = 1;
% generate starting estimates using Runge-Kutta
for i = 1
	k1 = f(x(i), y(i));
	k2 = f(x(i) + h/2, y(i) + h/2*k1);
	k3 = f(x(i) + h/2, y(i) + h/2*k2);
	k4 = f(x(i) + h, y(i) + h*k3);
	y(i+1) = y(i) + h/6*(k1 + 2*k2 + 2*k3 + k4);
	x(i+1) = x(i) + h;
end
% iterate
for i = 3:n+1
	% Adams-Moulton -- *correct*
	y(i) = y(i-1) + h/12*(5*f(x(i),y(i)) + 8*f(x(i-1),y(i-1))- f(x(i-2),y(i-2)));
end
0 Commenti
Risposte (2)
  Torsten
      
      
 il 5 Feb 2019
        In the Adams-Moulton formula, y(i) appears on both sides of the equation. This means that the Adams-Moulton method is implicit.  You will have to solve the equation	
y(i) - (y(i-1) + h/12*(5*f(x(i),y(i)) + 8*f(x(i-1),y(i-1))- f(x(i-2),y(i-2)))) = 0
in the unknown y(i) in order to get the correct value (e.g. using MATLAB's "fzero").
Best wishes
Torsten. 
0 Commenti
  Muhammad Sinan
 il 22 Mar 2021
        The only things need to correct is the discretization in iteration, here is the code
% iterate
for i = 3:length(n)-1
	% Adams-Moulton -- *correct*
	y(i) = y(i-1) + h/12*(5*f(x(i),y(i)) + 8*f(x(i-1),y(i-1))- f(x(i-2),y(i-2)));
end
Check it, if any thing goes wrong comment here.
Thank you!
0 Commenti
Vedere anche
Categorie
				Scopri di più su Particle & Nuclear Physics in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!