Work is said to be done when energy is transferred from one entity to another via the application of force. For example, when a force F is applied on a box and it moves through a displacement ds, work is done against the force of friction. The increment in the work done during the process is equal to the dot product of the force and displacement vectors. Only the component of force applied parallel to the displacement of the object contributes towards the work done. When an object is moved from position A to B, the total work done by the force is the integral of the force with respect to the displacement along the path of the displacement. For a force that is constant in both magnitude and direction, the integral depends only on the endpoints, and hence the work done is independent of the path taken. When a variable force is acting on an object, like expansion or compression of a spring, the spring force is expressed as a function of distance. The work done by the spring force along the displacement from initial position to final position is given by this equation, where k is the spring constant.