I am trying to numerically verify that, over a closed circular path, the line integral of a physics-inspired complex quantity $z_Q = P \cdot \frac{\partial}{\partial Q} S$ is the same regardless of whether the derivative is taken with respect to $Q=t$ (time) or $Q=k_x + i k_y$ (linear combination of momenta). $P,S$ are complex algebraic quantities, thereby making $z_Q$ a complex number.

The possible $Q$ are related each other via Equations 1 below: $$ k_x (t) = k_{x0} + r \cos(t) \\ k_y (t) = k_{y0} + r \sin(t)$$ That is, $t \in (0, 2 \pi)$ parametrizes a circle $(k_x,k_y)$ of radius $r$ centered at $(k_{x0}, k_{y0})$.


  1. Using NIntegrate[] over a Region[]:

    (* Define z_Q. A is some other constant input. *)
    zk[A_,kx_?NumberQ,ky_?NumberQ] := A kx + I ky Sin[kx]^2 
        (*zk is a lot more complicated in general, but this is just a functional example. *)
    zt[A_,t_?NumberQ] := A + Cos[t] + I Tan[t^2]^2 
        (* zt is arrived at by directly substituting Equations 1 above BEFORE derivatives are taken,
            and then taking the derivative with respect to t instead of kx + iky. *)
    (* Define ParametricRegion/ImplicitRegion *)
    kx0 = 1; ky0 = 1; r = 0.5; AA= 1; (* Sample data. *)
    R1 = DiscretizeRegion[ParametricRegion[{kx0 + r Cos[t], 
        ky0 + r Sin[t]}, {{t, 0, 2 \[Pi]}}], {{-2, 2}, {-2, 2}}, 
        PrecisionGoal -> 7.`, AccuracyGoal -> \[Infinity]];
            (* I specify edges (-2, 2) *)
    NIntegrate[zt[AA,t],  t \[Element] R1] 
    NIntegrate[zk[AA,kx,ky], {kx, ky} \[Element] R1]
  2. However, this does not yield the same answer when the single-parameter form is integrated directly: NIntegrate[zt[AA, t], {t, 0, 2 Pi}]

I am guessing the issue here is that t \[Element] R1 is not a valid way of supplying t numerical values for evaluation in NIntegrate. However, NIntegrate using {t, 0, 2 Pi} for $z_t$ does not match the answer from $z_k$. Compared to a difference method I used to calculate the same quantities in MATLAB, both $z_k$ and $z_t$ from all my Mathematica attempts are wrong in my Mathematica implementation. I know for a fact that my MATLAB results are reliable and physically sensible.

  1. So I used the following resources to try a different way of doing the integration:

How to do a line integral visually in version 10 or later How to calculate contour integrals with Mathematica? How to do numerical line integral? Complex line integral

The issue with (How to do a line integral visually in version 10 or later) is that it requires a vector field vec[t], while $z_Q$ is just a complex number. Despite its questionable justification, I tried the method there by defining the vector field as a pair {Re[zQ], Im[zQ]}. This led to gibberish results, and I wasn't sure how to do the $z_t$ integral using this approach.

The issue with (Complex line integral) is that I don't understand the Module[] notation there and so am not sure how to rightfully implement it. My attempts led to un-integrable expressions, or inconsistencies in defining dimensions.

Given all this, do you have any suggestions for the right way to tackle my issue using Mathematica?

  • $\begingroup$ For more insight, the integral of $z_Q$ is supposed to be a complex winding number. $\endgroup$ – TribalChief Jan 11 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.