Solution (source code)

= Solution

A time-independent <conservative force> defines a <conservative vector field> on a domain when the <work> between two points is independent of path, equivalently when every closed-path <work> <integral> vanishes. Define a <potential energy> $U$ by $\boxed{\mathbf F=-\nabla U}$ and $U(B)-U(A)=-\int_A^B\mathbf F\cdot d\mathbf r$. The additive constant is arbitrary; only differences affect <work>. A vanishing <curl> is necessary, and is sufficient on a <simply connected domain> under the usual smoothness assumptions. Local zero <curl> by itself need not guarantee a single-valued global potential on a domain with holes.

For a test <mass> outside a point or spherical <mass>, $U=-GMm/r$ with zero at infinity reproduces the inward gravitational <force>. Near a surface with approximately uniform downward <gravity>, $U=mgz$ when $z$ increases upward. A linear <spring> has $U=kx^2/2$. In <electrostatics> the <electric potential> is <energy> per unit charge, so $U=qV$ and $\mathbf E=-\nabla V$; potential and <potential energy> have different units and roles.

For motion under a time-independent <conservative force>, $d(K+U)/dt=0$. <nonconservative forces> change the <mechanical energy> by their <work>, and an explicitly time-dependent potential can exchange <energy> with the external agency changing it. A time-varying <magnetic field> can give a circulating <electric field>, so not every <electric field> is electrostatic or conservative. Conversely, zero magnetic <work> on a charge does not turn a velocity-dependent magnetic <force> into an ordinary position-potential <force>.