program hw5number6 c Program using Euler's method to determine an approximate c solution to problem 7.9-3 in Boyce and DiPrima, 8th edition. c c The initial conditions are (x1,x2) = (4,0). c c To compile on a linux machine type c c "g77 7.9-3.c -lm" c c and then to execute it, type "a.out". c c The data file is called "data.d". double precision x(2),derivs(2),t,dt,tf double precision exact(2) dt = 0.001 tf = 50.0 x(1) = 4.0 x(2) = 0.0 open(u,FILE='data.d',STATUS='OLD') do 10 t=0.0,tf,dt exact(1) = 7.0*cos(t) + 4.0*sin(t) + 2.0*t*cos(t)-t*sin(t) c - 3.0*cos(t) + sin(t) exact(2) = 2.0*cos(t) + 3.0*sin(t) + t*cos(t) - 2.0*cos(t) write(u,*) t,x(1),x(2),exact(1),exact(2) derivs(1) = 2.0*x(1) - 5.0*x(2) - cos(t) derivs(2) = x(1)- 2.0*x(2) + sin(t) x(1) = x(1) + derivs(1)*dt x(2) = x(2) + derivs(2)*dt 10 continue stop end