Calculator
Example data table
These examples are standard benchmarks for checking orientation and step stability.
| Example | Function | Contour | Expected result |
|---|---|---|---|
| Unit circle test | f(z)=1/z | Circle, center 0, R=1 | 0 + 2πi |
| Outside pole | f(z)=1/(z-2) | Circle, center 0, R=1 | 0 |
| Analytic Cauchy | g(z)=exp(z), z0=0 | Any contour enclosing z0 | 2πi · exp(0) = 2πi |
Formula used
For a parameterized contour z(t), the integral is
∮ f(z) dz = ∫ f(z(t)) z′(t) dt
This tool samples the path and applies trapezoidal or Simpson quadrature in the parameter t, using complex arithmetic throughout.
If z0 lies inside the contour and g(z) is analytic on and within it, then
∮ g(z)/(z - z0) dz = 2πi · g(z0)
The Cauchy mode evaluates g at z0 and checks whether z0 is inside the chosen contour.
How to use this calculator
- Pick Numerical for general f(z), or Cauchy for ∮ g(z)/(z - z0) dz.
- Choose a contour (circle, ellipse, rectangle) and set its center and size parameters.
- Enter your expression using z, constants i, pi, and supported functions.
- Increase steps N if the integrand changes rapidly near the path.
- After solving, use the export buttons to save CSV or PDF reports.
Professional article: contour integral solver
1) Scope of the calculator
This solver numerically evaluates closed-path complex integrals used in electromagnetics, quantum response calculations, and contour-based inverse transforms. It supports circles, ellipses, and rectangles. Each run records sampled points, complex differentials, and the accumulated integral so you can verify stability and reproduce results.
2) Path parameterization and sampling data
The computation follows a parameterized curve z(t) over one full loop. Circles and ellipses use t from 0 to 2π, while rectangles traverse four edges. The step count N sets the spacing and the granularity of the exported table.
3) Quadrature choices and expected accuracy
Trapezoidal quadrature works for all contours and handles piecewise paths well. Simpson's rule is offered for smooth circle/ellipse contours and often converges faster for smooth integrands. For smooth periodic cases, Simpson's rule may stabilize with fewer samples, reducing runtime at a fixed tolerance. A practical workflow is N=256, then compare against N=512 and N=1024 to confirm convergence.
4) Orientation and sign conventions
The positive convention is counterclockwise traversal; reversing the direction flips the sign. A quick check is ∮ (1/z) dz around the unit circle, which should return 2πi (about 6.283185i). Use this benchmark when changing method or contour type.
5) Singularities, poles, and validation checks
Poles inside the contour contribute nonzero values; poles outside typically give near-zero results for analytic integrands. Numerical error grows when the contour passes very near a singularity. If the sample table shows spikes in f(z) or segment contributions, increase N or move the contour away from the pole.
6) Cauchy mode for simple-pole structures
For integrands shaped like g(z)/(z - z0), Cauchy’s integral formula gives ∮ g(z)/(z - z0) dz = 2πi · g(z0) when z0 is enclosed and g is analytic. The solver checks enclosure and reports a clear inside/outside status.
7) Function syntax and complex arithmetic support
Expressions are parsed safely (no arbitrary code execution) and evaluated in complex arithmetic. Use operators + - * / ^, constants pi, e, i, and functions such as exp, sin, cos, tan, log, abs, arg, and conj.
8) Exports, reporting, and reproducibility
CSV export captures point-by-point path data for plotting and regression tests. The PDF report summarizes parameters, method, and the final complex value for sharing. For professional reporting, include the contour definition, orientation, method, and N, and document a convergence check at higher N.
FAQs
1) Which mode should I use?
Use Numerical for general f(z). Use Cauchy when your integrand matches g(z)/(z - z0) with a simple pole and analytic g on and inside the contour.
2) What step counts N are recommended?
Start with N=256. If the integrand varies quickly or approaches a pole, increase to 512 or 1024. Stop when two successive results agree within your required tolerance.
3) Does the solver compute residues automatically?
No. It performs numerical quadrature on the chosen contour. Cauchy mode uses the analytic Cauchy formula for a single simple-pole structure, but it does not symbolically find all poles or residues of a general function.
4) Why do I get a small nonzero value for an analytic function?
Finite sampling causes discretization error. Increase N, choose Simpson for smooth circle/ellipse cases, and avoid contours too close to singularities. For well-behaved analytic integrands, the magnitude should shrink as N increases.
5) Why is Simpson’s rule sometimes unavailable?
Simpson’s rule assumes a smooth periodic parameterization and an even number of subintervals. It is therefore offered only for circle and ellipse contours and requires suitable step counts. For rectangles, use trapezoidal quadrature.
6) What does the inside/outside check mean in Cauchy mode?
It tests whether the point z0 lies inside the selected contour region. If it is outside, the Cauchy formula does not apply, and the tool reports that the pole is not enclosed by your chosen path.
7) What should I include in a report?
Record the function, contour geometry, center/size values, orientation, method, and N. Attach the PDF output for a summary and keep the CSV when you need point-by-point reproducibility or plots.