arunjotshi
04-08-2006, 05:43 PM
Hello friends,
I am new to Numerical Recipies Forum.
I am using it to evaluate a double integral of function f(x,y)=x(x+3y) where the limits of x,y are given [0,4]. I am modifying the method specified on page 164 of the book (FUNCTION quad3d ) for triple integration. It is working fine.
But I was wondering whether there is a way to evaluate the integral with the following limits:
1) x lies between 0 and 4.
2) y lies between 0 and x.
I am not able to figure out how to do this :(
Please help!
Thanks and Regards,
Arun Jotshi,
SUNY Buffalo,
USA.
msph2778
04-21-2006, 07:20 AM
Hello
I am a new member of Numerical Recipes Forum
I am using numerical recipes subroutines for calculation
my integral.
My integrand has strongly oscillatory behavior and singularity too. So, I have calculated it, but have obtained different results for any integration method. Now, I don’t really know which subroutine is correct for my integrand. Are there other methods for these types functions?
Thanks for your helps
Best regards,
Ghadir Mohammadkhani.
ashesh
04-27-2006, 07:47 AM
Facing the exact same problem as Arun Jotshi.
My function is similar to:
f(x,y)=x(x+3y)
Int x_0^4 Int y_0^x f(x,y) dy dx
(Would like to perform double integration numerically between the limits:
1) x lies between 0 and 4.
2) y lies between 0 and x.
Hope some one can direct me to the appropriate procedure for solving this.
Thanks in advance.
arunjotshi
11-01-2006, 10:25 PM
Friends,
Best is to call Maple 9 or higher using your C/C++ program to calculate the integrals. Hope this helps. It worked out for me.
Good Luck!
Arun.
noomane
05-03-2007, 04:01 AM
i have resolve your probleme for double integral, you have a code file in this response, when i performe the double intergral.
! programme principale
!-------------------------------------------------------------------
external quad2d,qtrapx,qtrapy,qtrapz,y1,y2,z1,z2,func
x1=0.0
x2=4.0
call quad3d(x1,x2,ss)
pk=ss
write(6,*)pk
end
! subroutine qui calcul une integrale triple
!-------------------------------------------------------------------
subroutine quad2d(x1,x2,ss)
real ss,x1,x2,h
external h
call qgausx(h,x1,x2,ss)
return
end
function f(yy)
real f,yy,func,x,y
common /xy/ x,y
y=yy
f=func(x,y)
return
end
function h(xx)
real h,xx,f,y1,y2,x,y
external f
common /xy/ x,y
real ss
x=xx
call qgausy(f,y1(x),y2(x),ss)
h=ss
return
end
! LA fonction Ã* integrer
!---------------------------------------------------------------------
FUNCTION func(x,y)
func= x*(x+3*y)
RETURN
END
! LA fonction y1(x)
!---------------------------------------------------------------------
FUNCTION y1(x)
y1= 0*x
RETURN
END
! LA fonction y2(x)
!---------------------------------------------------------------------
FUNCTION y2(x)
y2= 1*x
RETURN
END
! INTEGRATION PAR LA METHODE DE GAUSS
!-----------------------------------------------------------------
SUBROUTINE qgausx(func,a,b,ss)
REAL a,b,ss,func
EXTERNAL func
INTEGER j
REAL dx,xm,xr,w(5),x(5)
SAVE W,x
DATA w/.2955242247,.2692667193,.2190863625,.149451349,.06 66713449/
DATA x/.1488743389,.4333953941,.6794095682,.8650633666,.9 739065285/
xm=0.5*(b+a)
xr=0.5*(b-a)
ss=0
do 11 j=1,5
dx=xr*x(j)
ss=ss+w(j)*(func(xm+dx)+func(xm-dx))
11 continue
ss=xr*ss
return
END
! INTEGRATION PAR LA METHODE DE GAUSS
SUBROUTINE qgausy(func,a,b,ss)
REAL a,b,ss,func
EXTERNAL func
INTEGER j
REAL dx,xm,xr,w(5),x(5)
SAVE W,x
DATA w/.2955242247,.2692667193,.2190863625,.149451349,.06 66713449/
DATA x/.1488743389,.4333953941,.6794095682,.8650633666,.9 739065285/
xm=0.5*(b+a)
xr=0.5*(b-a)
ss=0
do 11 j=1,5
dx=xr*x(j)
ss=ss+w(j)*(func(xm+dx)+func(xm-dx))
11 continue
ss=xr*ss
return
END
! INTEGRATION PAR LA METHODE DE GAUSS
SUBROUTINE qgausz(func,a,b,ss)
REAL a,b,ss,func
EXTERNAL func
INTEGER j
REAL dx,xm,xr,w(5),x(5)
SAVE W,x
DATA w/.2955242247,.2692667193,.2190863625,.149451349,.06 66713449/
DATA x/.1488743389,.4333953941,.6794095682,.8650633666,.9 739065285/
xm=0.5*(b+a)
xr=0.5*(b-a)
ss=0
do 11 j=1,5
dx=xr*x(j)
ss=ss+w(j)*(func(xm+dx)+func(xm-dx))
11 continue
ss=xr*ss
return
END
have fine.