Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

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: gauleg.f90. You would need an external Func(x) in your code where your integration function is written. This is f(x)=x^2, exactly just like the examples we did in the class. I also share them with you here.
So now, please write a main function (just on FORTRAN) to call this gauled.f90 which also calls Func.f90 and calculate our simple reference integral of x^2 between 0 to 5 which will definetly be : 41.66666 !
image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2021 Workshops Biokdd Iwcfs Mlkgraphs Al Cares Protime Alsys 2021 Virtual Event September 27 30 2021 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Anna Fensel ,Jorge Martinez-Gil ,Lukas Fischer

1st Edition

3030871002, 978-3030871000

More Books

Students also viewed these Databases questions