# Sympy: Deﬁnite Integration via Integration in the Complex Plane Proposal

Rizgar Mella March 26, 2008
Abstract Symbolic packages become far more powerful when able to solve deﬁnite intergrals. A majority of these problems can be solved in the complex plane. A straightforward and eﬀective method done by hand is very powerful, but translation to code may be problematic. Deﬁnite integrals are very important in many scientiﬁc ﬁelds such as quantum mechanics, combined with the importance of open source software in academic circles. Expansion of the Sympy package to include complex variable analysis, through the inclusion of Laplace Transforms and calculation of residues of contours from analysis of its poles (residue calculus). The residues allow almost all deﬁnite integrals to be resolved after reformatting into an appropriate contour, where the sum of residues is the solution. Continuing the expansion to include Inverse Laplacians to aid the solution of partial diﬀerential equations will make it a more aﬀective tool.

1

1

Detailed Description

The proposed addition I would like to implement for ﬁnding the solution for deﬁnite integration and integration on complex plane using residues, is to begin with an implementation of ﬁnding the residues appendix Figure 1 of an arbitrary contour. The diﬃculty in ﬁnding the residue is to ﬁnd code that detects the poles (easy for humans, must be cautious when dealing with computers). Pole detection can be found by decomposing the function into a tree structure, poles can be found from a set of rules for traversing the tree e.g.( [/s(s + a)], is two single poles one when s=0 and one when s = −a). For more complicated examples the computer program must be more robust. Finding of the residues with reformatting of a deﬁnite integral to an appropriate contour, will allow almost every deﬁnite integral to become solvable. A straight forward example in the appendix Figure 2. With the use of the Bromwich Contour, the Inverse Laplacian function could be created. The Bromwich Contour/Integral, easily produces a contour where the sum of the residues is the Inverse Laplacian, a very useful mathematical operation. BromwichContour = F (t) = 1 2πi
γ+i∞

est f (s)ds
γ−i∞

(1)

The ﬁnding of residues, Laplacian transform and inverse Laplacian Tranform have many other applications such as solving partial diﬀerential equations, this is done by running a Laplace Transform on the partial diﬀerential equation to produce an ordinary diﬀerential equation, when solved just apply the inverse Laplacian transform to arrive at the correct solution. I hope to write a Residue ﬁnding, Laplacian Transform and Inverse Laplacian Transform in python for sympy project.

2

Testing

Testing is an important step in the development of any computational implementation of a mathematical method. Evaluation of most (e.g some number to some number) deﬁnite integrals can be validated, by ﬁrst numerically evaluating the result of the algorithm to be tested, then separately evaluating the integral with numerical methods (well tested and trusted). Both results can be tested to an arbitrary number of decimal places. The sympy nitegrate function can serve as the comparison; obviously the test integrals will then have to be wellbehaved integrals. There are ways of testing non well behaved integrals, which is to symbolically evaluate the integral over many ﬁnite domains where if the domains are small enough, a majority will seem well behaved to the numerical integrate method and the conﬁdence in the symbolic method for that integral can then be evaluated in terms of the number of successful domains evaluated over the unsuccessful domains. The test ﬁles in sympy contain ’test xxx’ functions ﬁlled with asserts, which is a simple enough framework to include my proposed testing method. A random integral generator would be an excellent extreme test, but such a piece of code would require substantial testing on its own, only would be attempted if time permitted. 2

3

Appendix

Figure 1: Finding Residue Example

Figure 2: Deﬁnite Integration, with the use of residues. First Example

4

References

Example of Integration taken from: www.exampleproblems.com/wiki/index.php/CVRC1 3