Solution (source code)

= Solution

A <conservative vector field> has path-independent <work>: the integral $\int_A^B\mathbf F\cdot d\mathbf r$ depends only on its endpoints. Equivalently, the <line integral> around every closed path in its domain vanishes. One can then define a single-valued <potential energy> $U$ by
$$
U(B)-U(A)=-\int_A^B\mathbf F\cdot d\mathbf r,
\qquad
\boxed{\mathbf F=-\nabla U,\qquad W_{A\to B}=U(A)-U(B).}
$$
The arbitrary additive constant in $U$ has no effect on the <force>. A useful zero is often chosen at infinity for a localized attractive interaction.

A differentiable <conservative force> has $\nabla\times\mathbf F=0$ because the <curl> of a <gradient> vanishes. Conversely, a smooth curl-free field on a <simply connected> domain admits a global scalar potential. The domain condition matters: on the punctured plane, $\mathbf F=(C/r)\widehat{\boldsymbol\theta}$ has zero <curl> away from the missing origin but closed-loop work $2\pi C$ around it. It is not globally conservative there. The existence of a local potential does not establish a single-valued potential throughout a domain with holes.

The <work-energy theorem> gives $\Delta T=W$ for <kinetic energy> $T$. If all forces are conservative and $U$ has no explicit time dependence, then
$$
\Delta T=-\Delta U,\qquad
\boxed{T+U=\text{constant}.}
$$
This is <conservation of mechanical energy>. In one dimension, an <equilibrium> occurs at $dU/dx=0$; a local minimum with $U''>0$ is stable, while a maximum with $U''<0$ is unstable. Expanding about a minimum gives $U\simeq U_0+U''(x_0)(x-x_0)^2/2$, producing <simple harmonic motion> with $\omega^2=U''(x_0)/m$.

Examples include the <spring> force $F_x=-kx$ with $U=kx^2/2$, the near-surface gravitational <force> $-mg\widehat{\mathbf z}$ with $U=mgz$, and the central <Newtonian gravitational field> with $U=-GMm/r$. An electrostatic <force> on a fixed <electric charge> $q$ has $U=q\Phi$, where $\Phi$ is the <electric potential>.

Sliding <friction> provides a contrasting physical test: traversing a closed path still dissipates <mechanical energy>, since the frictional force opposes the local motion on both outward and return legs. Its work depends on path length and cannot be represented by a position-only $U$. Total <energy> can remain conserved when the resulting internal energy is included. Also, even if $\mathbf F=-\nabla U(\mathbf r,t)$ at each instant, explicit time dependence gives $d(T+U)/dt=\partial U/\partial t$; a static conservative-field argument alone does not guarantee constant mechanical energy in that situation.