Solution (source code)

= Solution

A position-dependent <force> is a <conservative force> when its <work> depends only on endpoints. Equivalently, its <work> around any closed allowed path vanishes, and one can define a <potential energy> $U$ satisfying
$$
\boxed{\mathbf F=-\boldsymbol\nabla U,\qquad W_{A\to B}=U(A)-U(B).}
$$
The potential is defined up to an additive constant. A vanishing <curl>, $\boldsymbol\nabla\times\mathbf F=0$, is a local test; it guarantees a global single-valued potential on a <simply connected> region with suitable regularity. Holes or excluded singularities require checking the global path condition.

The <work-energy theorem> gives $dK/dt=\mathbf F\cdot\mathbf v$. For a static potential this implies $d(K+U)/dt=0$. If $U$ depends explicitly on time, then instead $d(K+U)/dt=\partial U/\partial t$ under that <force> alone. Friction and other nonconservative forces add their own power and can convert <mechanical energy> into heat.

Examples include the <gravitational potential energy> $-GMm/r$ outside a spherical <mass> and the electrostatic <energy> $U=qV$, where $\mathbf E=-\boldsymbol\nabla V$. For a point source charge $Q$, $U=qQ/(4\pi\epsilon_0r)$, giving attraction or repulsion through the sign of $qQ$. A spring has $U=kx^2/2$ and <force> $-kx$. An equilibrium has $\boldsymbol\nabla U=0$; a strict local minimum is stable against small displacements when the quadratic curvature is positive. Expanding about that minimum explains the harmonic restoring <force> used in many small-oscillation models.

Magnetic <force> on a moving point charge does no <work>, but it is <velocity>-dependent and is not generally a position-only <force> $-\boldsymbol\nabla U$. Likewise a time-varying <magnetic flux> induces a circulating <electric field> with $\oint\mathbf E\cdot d\mathbf l=-d\Phi_B/dt$, so that <electric field> cannot globally be represented solely by an electrostatic scalar potential. These distinctions prevent treating every field <force> as conservative simply because an <energy> description exists for the complete system.