Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem with integration.

Newbie
 
Join Date: Jul 2008
Posts: 1
#1: Jul 21 '08
Hi, already tried few routines from GSL and it seems it doesn't work.

Function: 1/(x^2 - alpha^2)

Can anyone tell how to calculate that numerically.
Tried to do it by "hand" as well but no good results.

Cheers.

gpraghuram's Avatar
Expert
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,258
#2: Jul 22 '08

re: Problem with integration.


Have you use pow function which is available in math.h
See an example below.
Expand|Select|Wrap|Line Numbers
  1.  
  2. int main()
  3. {
  4.      printf ("10 ^ 6 = %lf\n", pow (10,6));
  5. }
  6.  
  7.  

Raghu
Needs Regular Fix
 
Join Date: Sep 2007
Location: The Netherlands
Posts: 427
#3: Jul 22 '08

re: Problem with integration.


Quote:

Originally Posted by marcoos

Hi, already tried few routines from GSL and it seems it doesn't work.

Are you having problems integrating this function, as the title of your post suggests? in that case, which GSL routine are you using and what are your limits of integration? Remember, this function is singular when x = +/- alpha .
Quote:

Originally Posted by gpraghuram

Have you use pow function which is available in math.h

The pow function is a good choice for non-integer powers or when you don't know the power in advance. Otherwise, it would be much faster to evaluate x*x instead of pow(x,2). This is especially important if your function is an integrand as then it will need to be evaluated many times.

By the way, the analytic answer is -(1/alpha)*arctanh(x/alpha) where arctanh is the inverse hyperbolic tangent.
Reply