Using Simpson's method to integrate a complex function

Click For Summary

Homework Help Overview

The discussion revolves around the application of Simpson's method for integrating complex functions, particularly in the context of singularities that may arise during the process.

Discussion Character

  • Exploratory, Assumption checking, Problem interpretation

Approaches and Questions Raised

  • Participants explore whether Simpson's method is appropriate for complex integrands and discuss potential issues with singularities when applying the method. There are inquiries about alternative approaches to handle these singularities.

Discussion Status

Some participants have provided insights into existing tools, such as quadpack and its integration with SciPy, which may assist in handling singularities. However, there remains a lack of consensus on the best approach to take, with various interpretations being explored.

Contextual Notes

Participants mention specific constraints related to the implementation of integration routines in Python and the limitations of available methods for dealing with singularities.

amjad-sh
Messages
240
Reaction score
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
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   Reactions: amjad-sh
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?
 
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   Reactions: amjad-sh
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
 
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.
 
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   Reactions: amjad-sh and DrClaude
  • Like
Likes   Reactions: cpt_carrot, jim mcnamara and amjad-sh

Similar threads

Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 27 ·
Replies
27
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 8 ·
Replies
8
Views
1K