Using Simpson's method to integrate a complex function

In summary, there is no problem with using Simpson's method to evaluate integrals with complex functions. However, when dealing with singularities, quadpack routines can be used to avoid them. These routines have been implemented in Scipy's integrate.quad function. It is also possible to specify the position of the singularity when using this function.
  • #1
amjad-sh
246
13
Homework Statement
The question includes programming, but the basic problem is related to mathematics, that's why I posted it here.

In fact, I'm working on a condensed matter physics paper,where I need to draw integral

##g(\nu,2k_fz)## in units of ##(2k_f)^{-1}## and interms of z.

##g(\nu,2k_fz)=\int_{1}^{-1}\dfrac{\nu^2(1-u^2)usin(2k_fzu)}{u^2-\nu^2/2+u\sqrt{u^2-\nu^2}}\, du##, where ##\nu=0.5##



I'm using Simpson's method to evaluate this integral. The problem is that the sign inside the the radical in the denominator will be negative while evaluating this method, that's why we need to treat the integrand as a complex function. The program(python) will plot for me just the real part of the result.

But my main question is: Is it Ok to use Simpson's method in order to evaluate integrals that their integrand is a complex function?

because the graph I'm getting is not even close to the graph depicted in the paper.



Is contour integration a better choice?
Relevant Equations
Simpson's method :
simpson.PNG
 
Physics news on Phys.org
  • #2
amjad-sh said:
But my main question is: Is it Ok to use Simpson's method in order to evaluate integrals that their integrand is a complex function?
Yes, that shouldn't be a problem.
 
  • Informative
Likes amjad-sh
  • #3
DrClaude said:
Yes, that shouldn't be a problem.
Yes, it was a tiny mistake in my code that was stopping the graph to appear as it should.
But if we consider the problem in case ##\nu=0##,a singularity will arise while applying Simpson's method for u=0.
Do you know a trick or a way to go around this singularity?
 
  • #4
quadpack has routines to deal with integration of functions with singularities. It has been ported to C in GSL, but I don't think it is available in python.
 
  • Like
Likes amjad-sh
  • #5
DrClaude said:
quadpack has routines to deal with integration of functions with singularities. It has been ported to C in GSL, but I don't think it is available in python.

Scipy provides an interface to quadpack via the integrate.quad function
 
  • #6
cpt_carrot said:
Scipy provides an interface to quadpack via the integrate.quad function
I don't use python, but from the information I could find, only a basic quadrature method from quadpack is implemented in scipy, not the routines for dealing with singularities.
 
  • #7
DrClaude said:
I don't use python, but from the information I could find, only a basic quadrature method from quadpack is implemented in scipy, not the routines for dealing with singularities.

By default I think quad calls qagse which does support singularities, you can also specify a series of domains to avoid them. With the right set of options you can get to most of the quadpack routines.
 
  • Like
Likes amjad-sh and DrClaude
  • #8
  • Like
Likes cpt_carrot, jim mcnamara and amjad-sh

1. What is Simpson's method and how does it work?

Simpson's method is a numerical integration technique used to approximate the area under a curve. It works by dividing the area into smaller sections and using quadratic polynomials to approximate the curve within each section.

2. When should I use Simpson's method instead of other integration methods?

Simpson's method is most useful when integrating complex functions that cannot be easily solved using other methods, such as the trapezoidal rule or the midpoint rule. It is also more accurate than these other methods for certain types of functions, such as oscillatory or highly curved functions.

3. What are the limitations of Simpson's method?

Simpson's method may not work well for functions with sharp corners or discontinuities, as the quadratic polynomials used to approximate the curve may not accurately represent these features. It also requires more computational steps compared to other integration methods, which may make it less efficient for larger or more complex functions.

4. How do I know if my Simpson's method approximation is accurate enough?

The accuracy of Simpson's method can be improved by using a smaller step size and increasing the number of subintervals. To determine if the approximation is accurate enough, you can compare the results to the exact solution, if known, or use a convergence test to see if the approximation is approaching the true value as the step size decreases.

5. Can Simpson's method be used for multidimensional integration?

Yes, Simpson's method can be extended to multidimensional integration by using a similar approach of dividing the area into smaller sections and approximating the function within each section. However, the computational complexity increases significantly for higher dimensions, and other methods may be more efficient for multidimensional integration.

Similar threads

  • Calculus and Beyond Homework Help
Replies
3
Views
364
  • Calculus and Beyond Homework Help
Replies
11
Views
549
  • Calculus and Beyond Homework Help
Replies
27
Views
736
  • Calculus and Beyond Homework Help
Replies
17
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
852
  • Calculus and Beyond Homework Help
Replies
8
Views
174
  • Calculus and Beyond Homework Help
Replies
3
Views
868
  • Calculus and Beyond Homework Help
Replies
5
Views
980
  • Calculus and Beyond Homework Help
Replies
4
Views
700
  • Calculus and Beyond Homework Help
Replies
5
Views
571
Back
Top