Line integration given tangent vector

I have the following problem: I know a unit vector in spherical polar coordinates, let's call it $$\vec{e}_{s}$$, in the form $$\vec{e}_{s} = f(r,\theta)\vec{e}_{r} + g(r,\theta)\vec{e}_{\theta} + c\vec{e}_{\phi}$$, where $$f,g$$ are known functions and $$c$$ is a constant. Furthermore I know that this vector is the tangent of some curve $$C$$ at every point $$(r,\theta,\phi)$$. My question is how can I compute the line integral of its divergence along $$C$$. I know that:$$$$\int_{C}\nabla\vec{e}_{s}ds=\int_{c}\nabla\vec{e}_{s}\vec{e}_{s}d\vec{r}$$$$

where $$d\vec{r}$$ is the infinitesimal length element (in this case in spherical coordinates), but I can't get any further. I know that, in principle, given a parametric curve $$C(t)$$ one can easily compute (numerically) the line integral of a by expressing $$(r,\theta) = (r(t),\theta(t))$$ but I don't know how can I do this in my case.

I've seen the examples for NIntegrate here for Line integrals, but it seems to me I would need the curve to be parametrized by a single variable and the same to hold for my vector.

I know that this is not specifically a question for Mathematica, but the integral is to be evaluated numerically and I intend to do this in Mathematica.

Any help on this would be greatly appreciated!

• Are you sure about: $$\int_{C} \nabla \cdot\vec{e}_{s} d s=\int_{C} \nabla \cdot\vec{e}_{s} \vec{e}_{s} d \vec{r}$$ ? Are the tangents $\mathbf{\alpha}^\prime(t)$ of your curve always unit vectors? If your curve has nonzero 'acceleration' $\mathbf{\alpha}^{\prime\prime}(t)$ i.e not a line or circle, then I don't think this is correct. – flinty May 18 at 16:59
• The divergence in spherical polar is: $$\nabla \cdot \mathbf{A}=\frac{1}{r^{2}} \frac{\partial}{\partial r}\left(r^{2} A_{r}\right)+\frac{1}{r \sin \theta} \frac{\partial}{\partial \theta}\left(\sin \theta A_{\theta}\right)+\frac{1}{r \sin \theta} \frac{\partial A_{\varphi}}{\partial \varphi}$$ In your case $A_r=f(r,\theta), A_\theta=g(r,\theta), A_\phi=c$ – flinty May 18 at 17:15
• Hello! You might be right. Anyway, I do not know the curve parametrization. I integrate along some path that I require to be tangent to $\vec{e}_s$ at every point. I know how to write the divergence in polar coordinates. My problem is that I can't wrap my mind around how to parametrize the curve using a single parameter. The only information that I have is the expressions of the functions $f,g$ in terms of $r,\theta$. – Kvothe May 18 at 18:30
• Just to be a little more explicit: i do not know the curve $C$. In principle I'm defining it to be the curve to which the vector $\vec{e}_s$ is always tangent. Maybe there is an error in this logic – Kvothe May 18 at 18:37

Update: technically it's ill-defined because you cannot take the divergence of $$\vec{e}_s$$ which is restricted to the curve. See here https://math.stackexchange.com/questions/3682769/line-integral-of-the-divergence-of-a-curves-unit-tangent-vector . So I've edited this to not confuse anyone passing by.

However 'ill-defined' is unsatisfying, so based on physical intuition I'm going to carry on saying it's zero. The reasoning is entirely based on the real-world meaning of divergence as average flux over a boundary and is not very mathematical.

Hand waving: Imagine the curve is actually a thin wire. The average amount of unit vector field flowing into a small box along the wire equals the amount flowing out - you have net zero flux. Also note if you had a closed curve in 2D, there's zero flux flowing in or out of the bounded region. In higher dimensions, there's zero flux going across the curve - it only flows along with it.

An example of such a curve could be a line, circle, or a helix like below:

a[t_] := {Cos[t]/2, Sin[t]/2, Sqrt[3/4] t}
f[x_, y_, z_] := {-y, x, Sqrt[3/4]}
a'[1] == f @@ a[1] (*test f[x(t),y(t),z(t)] gives unit vector a'[t]*)
Div[f[x, y, z], {x, y, z} ](* is zero *)


Here's how you can get the divergence (in spherical) of your $$\vec{e}_s$$ using Mathematica

FullSimplify[
Div[{f[r, \[Theta]], g[r, \[Theta]], c}, {r, \[Theta], \[Phi]},
"Spherical"]]


$$\nabla\cdot\vec{e}_s=\left[\frac{2 f(r,\theta)}{r}+\frac{\partial f}{\partial r}\right]+\left[\frac{1}{r}\cot(\theta)g(r,\theta)+\frac{1}{r}\frac{\partial g}{\partial \theta}\right]+\left[0\right]$$

• I think you are right, but I followed a slightly different path. Consider a vectro $\vec{\alpha}(t) = \alpha_x(t)\vec{e}_{x} + \alpha_{y}(t)\vec{e}_y + \alpha_z(t)\vec{e}_z$. Now, the integral in the original post can be written as: $$\int_{C}\nabla\vec{\alpha}\vec{\alpha}d\vec{r} = \int_{C}dt\left[\left(\frac{\partial \alpha_x}{\partial x}\alpha_x\frac{dx}{dt}\right) + (...)_y + (...)_z\right]$$ where $(...)_{y,z}$ contain the same expressions as the first brackets but with the indices $y,z$ instead of $x$. Comment continues bellow due to space limitations – Kvothe May 20 at 7:18
• Then, using the chain rule, the integral gives the square of $\vec{\alpha}$: $$\int_{C}\nabla\vec{\alpha}\vec{\alpha}d\vec{r} = \frac{1}{2}\vec{\alpha}^2(b)-\frac{1}{2}\vec{\alpha}^2(a)$$ In my case, in which $\vec{\alpha}$ is a unit vector, the two values at the ends of the curve ($a,b$) are equal both to $1$. So, indeed the line integral is 0. I'm not very confident in this reasoning because it gives a very general result which I did not find in any textbook. This might be because I'm actually wrong and have omitted something or because it is not very useful. – Kvothe May 20 at 7:22