# Line Integral of a Vector Field Defined in Spherical Coordinates Along the Given Path

I am trying to calculate the line integral of a vector field along a given path.

$$\vec{v} = (r \cos^2θ) \hat{{r}} − (r\cosθ\sinθ) \hat{{θ}} + 3r \hat{{φ}}$$

Here, $$r$$ is the magnitude of the position vector, $$\theta$$ is the angle of the position vector with respect to the $$z$$-axis, and $$\varphi$$ is the angle of the projection in the $$xy$$ plane with respect to the $$x$$-axis.

The path is given in the link below:

https://i.stack.imgur.com/AYstr.png

To compute the integral, I assume we're supposed to first compute it from $$(1,0,0)$$ to $$(0,1,0)$$, then from $$(0,1,0)$$ to $$(0,1,2)$$ and so on.

I was able to calculate the integral from the point $$(1,0,0)$$ to $$(0,1,0)$$, but after that, the vector $$\vec{r}$$ is no longer of constant magnitude, so I do not know how to proceed. Do I have to convert into Cartesian coordinates, or is it possible to still solve this using spherical polar coordinates?

This is what I did to calculate the line integral from $$(1,0,0)$$ to $$(0,1,0)$$:

First, I wrote the unit vectors $$\hat{{r}}$$, $$\hat{{θ}}$$ and $$\hat{{φ}}$$ in terms of $$\hat{{i}}$$, $$\hat{{j}}$$, $$\hat{{k}}$$

$$\hat{{r}} = \cos\varphi \hat{{i}} + \sin \varphi \hat{{j}}$$

$$\hat{{\theta}} = - \hat{{k}}$$

$$\hat{{\varphi}} = - \sin\varphi \hat{{i}} + \cos\varphi \hat{{j}}$$

Now, substituting these in $$\vec{v}$$, I got

$$\vec{v} = (r cos^2\theta \cos\varphi - 3r \sin\varphi) \hat{{i}} + (r \cos^2\theta \sin\varphi + 3r \cos\varphi) \hat{{j}} + (r \cos\theta \sin\theta) \hat{{k}}$$

Also, $$dr = -\sin\varphi d\varphi \hat{{i}} + \cos\varphi d\varphi \hat{{j}}$$

Taking the dot product, I got $$\vec{v}\cdot dr = 3r \cos^2\varphi d\varphi$$

On integrating this from $$\varphi=0$$ to $$\varphi=\pi/2$$, I ended up with $$0$$.

But now, to go from $$(0,1,0)$$ to $$(0,1,2)$$, I am stuck, as this is no longer a circular/spherical path, and the magnitude of $$r$$ keeps changing. I suppose I could write $$\vec{r} = \hat{{j}} + z \hat{{k}}$$, but I do not know how to write the expressions of the unit vectors $$\hat{{\theta}}$$ and $$\hat{{\varphi}}$$ in terms of $$\hat{{i}}$$, $$\hat{{j}}$$, $$\hat{{k}}$$.

Any help would be greatly appreciated!