lit
    JINRLIB

MERSOD -

D208

: T.Havie :

popa o ppoa cc n pa pa poo opa
dyi/dx = fi(x,y1 ,y2 ,...,yn), i=1,2,...,n
X XEND.

:

: - SUBROUTINE
: - MERSOD
: - DIFF - /

:

CALL MERSOD(X,XEND,Y,N,ACC,H,HMIN,JTEST,OK,DIFF),

X - (REAL*8) - ac p x ( ), - XEND ( );
XEND - (REAL*8) a x;
Y - (REAL*8) oop acc papoc N:
a o Y(I) (I=1,2,...,N) yi(x) ,
a o - yi(x) XEND;
N - (INTEGER) co pa n ( 100);
ACC - (REAL*8) pa ooca ooc;
H - (REAL*8) a aa (ooa opaa);
HMIN - (REAL*8) aa oca a aa (ac a);
JTEST - (INTEGER) aap opo :
JTEST=0: c p aa ABS(H) caoc HMIN, aac coo o o, apap OK .FALSE., poco opa a popa;
JTEST=1: c ABS(H) caoc HMIN, a c pooc p ocoo a H=HMIN;
OK - (LOGICAL) oca , .TRUE. popa MERSOD. c JTEST=0 ABS(H) HMIN, o OK .FALSE;
DIFF - ooa, ocao EXTERNAL a popa.
DIFF oa : SUBROUTINE DIFF(X,Y,F), :
  X - (REAL*8) aca pa,
  Y,F - (REAL*8) oop acc, Y(*), F(*).
c a pa ac p pa:
F(I) = f(X,Y(1),...,Y(N)), I=1,2,...,N.

popaa oa co X - XEND, co Y(I,X) - Y(I,XEND) H a a acao oo aa, oc o po ooc ACC XEND.
n = 100 MERSOD.

:

pp p p p x=0, y1=-1, y2=0:

dy1/dx = sin(x)
dy2/dx = exp(x)
       IMPLICIT REAL*8 (A-H,O-Z)
       DIMENSION Y(2)
       EXTERNAL EXTERN
       LOGICAL OK
       X=0.D0
       XEND=1.D0
       Y(1)=-1.D0
       Y(2)=0.D0
       ACC=0.000001D0
       H=0.1D0
       HMIN=0.000001D0
       JTEST=1
       N=2
       CALL MERSOD(X,XEND,Y,N,ACC,H,HMIN,JTEST,OK,DIFF)
       WRITE(*,1) ACC
       WRITE(*,2) X,Y(1),Y(2)
       Y(1)=-DCOS(X)   !  X=XEND
       Y(2)=DEXP(X)
       WRITE(*,3)
       WRITE(*,2) X,Y(1),Y(2)
    1  FORMAT('  ACCURACY: ',G10.5)
    2  FORMAT('  X=',G10.5,5X,' Y1=',G18.10,5X,' Y2=',G18.10)
    3  FORMAT('  ANALYTIC SOLUTION:')
       END
    C
       SUBROUTINE DIFF (X,Y,F)
       IMPLICIT REAL*8 (A-H,O-Z)
       DIMENSION Y(*),F(*)
       F(1)=DSIN(X)
       F(2)=DEXP(X)
       RETURN
       END
:
       ACCURACY: .10000E-05
       X=1.0000          Y1=  -.5403022899          Y2=   2.718281888
       ANALYTIC SOLUTION:
       X=1.0000          Y1=  -.5403023059          Y2=   2.718281828


home up e-mail