# Finding the value of λ to make an integral path-independent

How can I find λ such that

$$\int_{(1,2)}^{(2,4)} \left( \frac{xy+\lambda}{y}\,dx + \frac{2\lambda y-x}{y^2}\,dy \right)$$

is path independent, and what is the integral's value for that λ?

A line integral is path independent if the integrand can be written in terms of the gradient of a potential function $$U$$. So, let's do exactly that.

Let $$U$$ be defined by $$\nabla U \cdot d\vec{r} = \frac{xy + \lambda}y dx + \frac{2 \lambda y - x}{y^2} dy$$

This is our integrand. Supposing that this is the case, let \begin{align}\frac{\partial U}{\partial x} &= \frac{xy + \lambda}y \\ \frac{\partial U}{\partial y} &= \frac{2 \lambda y - x}{y^2} \end{align} If we integrate the first equation with respect to $$x$$, we obtain $$U = \frac{x^2}2 + \frac{\lambda x}y + f(y)$$ for some function $$f$$. Then if we integrate the second equation with respect to $$y$$, we obtain $$U = 2 \lambda \ln{\lvert y \rvert} + \frac{x}y + g(x)$$ for some function $$g$$.

Setting these two equal, we find $$\frac{x^2}2 + \frac{\lambda x}y + f(y) = 2 \lambda \ln{\lvert y \rvert} + \frac{x}y + g(x)$$ so \left\{ \begin{aligned} \frac{x^2}2 &= g(x) \\ \frac{\lambda x}y &= \frac{x}y \\ f(y) &= 2 \lambda \ln{\lvert y \rvert} \end{aligned} \right.

From the second equation we find that $$\lambda = 1$$, so $$g(x) = \frac{x^2}2$$ and $$f(y) = 2 \ln{\lvert y \rvert}$$.

Thus our potential function is, for some constant $$C$$, $$U = \frac{x^2}2 + \frac{x}y + 2 \ln{\lvert y \rvert} + C$$

Taking the gradient of this returns our original integrand (you can check this). So, $$\lambda = 1$$.

To find the value of the integral, just evaluate the potential function at $$(1, 2)$$ and $$(2, 4)$$ and find their difference, just like evaluating a definite integral using an antiderivative at the bounds. You should get $$\frac{3}2 + 2 \ln 2$$.

You need to check if the Jacobian matrix of the function $$\mathbf{F}(x,y)=\begin{pmatrix}\frac{xy+\lambda}{y} \\ \frac{2\lambda y-x}{y^2}\end{pmatrix}$$ is symmetric. This will tell you how you can choose $$\lambda$$, your first question.

Once you have done that, look for a function $$\varphi(x,y)$$ such that the gradient $$\nabla\varphi(x,y)$$ equals $$\mathbf{F}$$. Such a $$\varphi$$ is called a potential, and can only exist if the Jacobian matrix is symmetric. If you found such a potential, the answer to your second question is $$\varphi(2,4)-\varphi(1,2)$$.