sábado, 25 de mayo de 2019

Adam Moulton method

https://souravrohan.wordpress.com/2011/06/05/adam-moulton-method/

Adam Moulton method


FORTRAN CODE FOR SOLVING An IVP USING Adam Moulton  4-STEP IMPLICIT METHOD:
PARAMETER(M=10)
OPEN(33,FILE=’INP14.DAT’)
OPEN(34,FILE=’OUP14.DAT’)
READ(33,*)A,B,H,W0
CALL AM(A,B,H,W0,M)
END PROGRAM
SUBROUTINE AM(A,B,H,W0,M)
REAL K1,K2,K3,K4,W(M),T(M),N
WRITE(34,10)
10 FORMAT(2X,’X’,9X,’EXACT’,12X,’AMW(I)’,10X,’ERR’)
N=(B-A)/H
W(0)=W0
T(0)=A
WRITE(34,11)T(0),G(T(0)),W(0), ABS(G(T(0))-W(0))
11 FORMAT(2X,F4.2,3(4X,F12.8))
DO I=1,4
K1=H*F(T(I-1),W(I-1))
K2=H*F(T(I-1)+H/2,W(I-1)+K1/2)
K3=H*F(T(I-1)+H/2,W(I-1)+K2/2)
K4=H*F(T(I-1)+H,W(I-1)+K3)
W(I)=W(I-1)+(K1+2*K2+2*K3+K4)/6.0
T(I)=A+I*H
WRITE(34,11)T(I),G(T(I)),W(I), ABS(G(T(I))-W(I))
END DO
DO I=3,N-1
T(I+1)=A+(I+1)*H
W(I+1)=W(I)+(H/720)*(251*F(T(I+1),W(I+1))+646*F(T(I),W(I))-264*F(T(I-1),W(I-1))+106*F(T(I-2),W(I-2))-19*F(T(I-3),W(I-3)))
WRITE(34,11)T(I+1),G(T(I+1)),W(I+1), ABS(G(T(I+1))-W(I+1))
END DO
END SUBROUTINE
FUNCTION F(T,Y)
F=COS(2*T)+SIN(3*T)
RETURN
END
FUNCTION G(T)
G=SIN(2*T)/2.0-(COS(3*T)-4)/3.0
RETURN
END
inputs:
0
2
0.2
0.5
program name:
outputs:
X EXACT AMW(I) ERR
0.00 1.00000000 1.00000000 0.00000003
0.20 1.25293064 1.15557957 0.09735110
0.40 1.57122552 1.39189768 0.17932783
0.60 1.87508702 1.64209783 0.23298915
0.80 2.07891798 1.82905316 0.24986494
0.80 2.07891798 1.82908905 0.24982905
1.00 2.11797953 1.89059699 0.22738262
SEE NUMERICAL ANALYSIS (7TH EDITION) BY BURDEN
PAGE 295 TO KNOW MORE………………………………

No hay comentarios:

Publicar un comentario