Question: This is the 4th HW assignment. This time our subject is integration (numerical) and the subroutine is coming from Ch 4, namely Gauss-Legendre Integration code:

SUBROUTINE gauleg(Func, x1,x2,x,w,n) INTEGER :: n REAL :: Func, x1,x2,x(n),w(n) DOUBLE PRECISION EPS PARAMETER (EPS =3,d14) INTEGER : i,j,m DOUBLE PRECISION p1,p2,p3,pp,xl,xm,z,z1 External Func; m=(n+1)/2xm=0.5d0(x2+x1)xl=0.5d0(x2x1)do12i=1,mz=cos(3.141592654d0(i.25d0)/(n+.5d0)) 1 continue p1 =1,d0 p2 =0.d0 do 11j=1,n p3=p2 p2=p1 11 continue pp=n(zp1p2)/(zz1.d0) zl=z z=z1p1/pp if(abs(z-zl).gt.EPS)goto 1 x(i)=xmxlz x(n+1i)=xm+xlz w(i)=2.d0xl/((1.d0zz)ppppp) w(n+1i)=w(i) 12 continue return END SUBROUTINE gauleg float FUNC(float x ) \{ //return xx; //the integral for x2; It is analogly equal to : (1/3)(5^313)=(1/3)124=41.3333 return pow (x,2) \}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
