FORTRAN 90 Lecturer : Rafel Hekmat Hameed University of Babylon Subject : Fortran 90 College of Engineering Year : Second B.Sc. Mechanical Engineering Dep. Double Integral What is a double integral? Recall that a single integral is something of the form න ݂ሺݔሻ݀ݔ A double integral is something of the form ඵ ݂ ሺݔǡ ݕሻ݀ݕ݀ݔ ோ Where R is called the region of integration and is a region in the (x,y) plane. The double integral gives us the volume under the surface z=f(x,y), just as a single integral gives the area under a curve. Evaluation of double integrals The double integral evaluated as an iterated integral ௗ ܫൌ න න ݂ ሺݔǡ ݕሻ݀ݕ݀ݔ ௗ ൌ න න ݂ ሺݔǡ ݕሻ݀ݔ݀ݕ We can do the same, using any integration method. ϭ Example Evaluate ଶǤ ସǤ ܫൌ න න ଶ ͳ ݀ݕ݀ݔ ݕݔ ସ Take dx = 0.2 in x-direction, direction, dy = 0.3 in y-direction. Use Trapezoidal rule in x- direction and Simpson’s 1/3 rule in y-direction. Calculate the value of ݂ሺሺݔǡ ݕሻ ൌ ଵ ௫௬ Applying trapezoidal rule in x-direction x For y=2 : I=0.2/2(0.125+2*0.1191+2*0.1136+0.1087) = 0.0699 For y=2.3 : I=0.2/2(0.1087+2*0.1035+2*0.0988+0.0945)= 0.0608 For y=2.6 : I=0.2/2(0.0962+2*0.0916+2*0.0874+0.0836)= 0.2/2(0.0962+2*0.0916+2*0.0874+0.0836)= 0.0538 We can put in the table y 2 2.3 2.6 f(y) 0.0699 0.0608 0.0538 Applying Simpson’s 1/3 rule in y-direction I=0.3/3(0.0699+4*0.0608+0.0538)= 0.0367 Ϯ program double_integration implicit none real,dimension(50)::sum1 integer:: i ,k real::a , b , n ,dx,dy,f,x,y ,j,sumf,sums f(x,y)=1/(x*y) read(*,*) a,b,n,dy dx=(b-a)/n j=2 do k=k+1 sumf=f(a,j)+f(b,j) do i=1,n-1 x=a+(i*dx) sumf=sumf+2*f(x,j) enddo sumf=sumf*dx/2.0 write(*,40)"for y=",j, "integral=", sumf 40 format(2x,a,f5.2,2x,a,2x,e14.8) sum1(k)=sumf if(j.eq.2.6)exit j=j+dy enddo do i=1,k write(*,10)sum1(i) 10 format(2x,e14.8) enddo sums=sum1(1)+sum1(k) do i=2,k-1 if(i/2*2.eq.i)then sums=sums+4*sum1(i) else ϯ sums=sums+2*sum1(i) endif enddo sums=sums*dy/3.0 write(*,20)"approximated value of double integration=",sums 20 format(2x,a,e16.8) end ϰ