P. 733, line 19

From Bill Goodwine's Wiki
Revision as of 22:48, 3 November 2011 by Goodwine (talk | contribs) (Created page with "The program should be: <nowiki> program systemeuler c This is a sample FORTRAN program that solves the differential c equation c c x' = y, y' = (1 - x^2)y - x...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The program should be:

      program systemeuler

c     This is a sample FORTRAN program that solves the differential
c     equation
c
c     x' = y, y' = (1 - x^2)y - x
c     x(0) = 0.02, y(0) = 0.0
c     
c     using Euler's method.

      double precision x(2),t,dt
      double precision copy(2)

      open(unit=13,file="systemfortran.d")

      dt = 0.001
      x(1) = 0.02
      x(2) = 0.0

      do 10 t = 0, 20, dt
         write(13,*) t,x(1),x(2)
         copy(1) = x(1)
         copy(2) = x(2)
         x(1) = x(1) + (copy(2))*dt
         x(2) = x(2) + ((1.0 - copy(1)**2)*copy(2) - copy(1))*dt
 10   continue
      stop
      end