next up previous contents
Next: Solving Poisson's equation Up: Extending ``rk4'' and ``derivs'' Previous: Coding

Debugging

 

As we discussed in class, using fourth-order Runge-Kutta to solve F'(x)=g(x) is equivalent to integrating tex2html_wrap_inline256 with Simpson's rule. Debug your version of ``rk4ind'' by comparing the output of the following code fragment with the output of your ``simpint'' routine for an appropriately designed ``derivs'' routine:

               .
               .
               .
   [Define f, r, dr, and Nu]
               .
               .
               .
      h=2./float(Nu)
      dk=2
      v(1)=0.
      do k=1,Nu-1,2
         x=(k-1)*h
         call dphi(x,v,dv,k,f,r,dr,Nu)
         call rk4ind(v,dv,1,x,h,v,dphi,k,dk,f,r,dr,Nu)
      enddo
      write(6,*) simpint(f,r,dr,Nu),v(1)
               .
               .
               .


Tomas Arias
Tue Feb 8 16:02:01 EST 2000