Note that the vector field is irrotational, since

which means

is conservative. This means there is some scalar potential function

such that

. If we can find such a function, then we only need to evaluate the difference of

and

(because the gradient theorem holds in this case).
We're looking for a function

that satisfies



Integrate the first equation with respect to

to get

Differentiate with respect to

, then we must have




Differentiate with respect to

, and we have to have




Now, by the gradient theorem, we have

where

is the line segment.