Work is a measure of what a force achieves, so when we calculate the work done by a force on an object we consider only it's displacement in the direction of the force.
Mathematically, as we consider both force $\vec{F}$ and displacement $\vec{d}$ to be vectors, and the work done on an object to be a scalar $W$, we say that the work is the scalar product, or dot product of force and displacement. We should note that this is not the displacement from an arbitrary origin, but rather the change in an objects position during a motion.
For a constant force
$W= \vec{F} \cdot \vec{d} $
If the two vectors are at an angle $\theta$ to each other then we can say
$W = Fd\cos\theta$
Consider a hiker that walks first on the flat and then up a hill carrying a backpack, with a constant velocity on each section.
A hiker carries a 10kg backpack a distance of 500 m on the flat at a constant velocity. How much work do they do on the backpack?
The hiker now climbs up a mountain that has a 5 degree incline. When he has walked a distance of 500m and is still moving at the same speed how much work has he done on the backpack?
The scalar product is commutative (order is not important)
$\vec{A}\cdot\vec{B}=\vec{B}\cdot\vec{A}$
and distributive
$\vec{A}\cdot(\vec{B}+\vec{C})=\vec{A}\cdot\vec{B}+\vec{A}\cdot\vec{C}$
The scalar product of two vectors written in unit vector notation is straightforward to calculate because the different unit vectors are perpendicular to each other.
$\hat{i}\cdot\hat{i}=\hat{j}\cdot\hat{j}=\hat{k}\cdot\hat{k}=1$
$\hat{i}\cdot\hat{j}=\hat{i}\cdot\hat{k}=\hat{j}\cdot\hat{k}=0$
So for two vectors
$\vec{A}=A_{x}\hat{i}+A_{y}\hat{j}+A_{z}\hat{k}$
$\vec{B}=B_{x}\hat{i}+B_{y}\hat{j}+B_{z}\hat{k}$
$\vec{A}\cdot\vec{B}=A_{x}B_{x}+A_{y}B_{y}+A_{z}B_{z}$
Our previous definition of work was rather limited, in that it considered only a constant force. To be able to consider the work done by a force which can vary over a given path between two points in space we should better write
$W=\int_{a}^{b}\vec{F}\cdot d\vec{l}$
Here we broke our path up into infintessimcal elements $d\vec{l}$ over which we can then integrate
as
$\vec{F}=F_{x}\hat{i}+F_{y}\hat{j}+F_{z}\hat{k}$
$d\vec{l}=dx\,\hat{i}+dy\,\hat{j}+dz\,\hat{k}$
This vector integral can be easily split in to separate integrals for the different components
$W=\int_{x_{a}}^{x_{b}}F_{x}\,dx+\int_{y_{a}}^{y_{b}}F_{y}\,dy+\int_{z_{a}}^{z_{b}}F_{z}\,dz$
Hooke's Law states that for a spring to be either compressed or stretched from it's equilibrium length the force exerted on it must be
$F_{A}=kx$
the spring exerts an equal and opposite force back on itself
$F_{S}=-kx$
Suppose a spring is extended from $x=0$ to an arbitrary distance $x$. Then the work done on the spring by the applied force is
$W=\int_{0}^{x}F_{A}(x)\,dx=\int_{0}^{x}kx\,dx=\frac{1}{2}kx^2$
and, equally, if we compress the spring
$W=\int_{0}^{-x}F_{A}(x)\,dx=\int_{0}^{-x}kx\,dx=\frac{1}{2}kx^2$
In either case the work done by the spring on itself will be negative and of equal magnitude to the work we do on it ($W=-\frac{1}{2}kx^2$). The net work done on the spring by us and the spring is zero. We'll know see why this must be the case.
If we consider the net work on an object we can use Newton's second law to define a new and very useful quantity, the kinetic energy of an object.
$W_{net}=\int\vec{F_{net}}\cdot d\vec{l}=\int F_{\parallel}\,dl$
Newton's second laws tells us that
$F_{\parallel}=ma_{\parallel}=m\frac{dv}{dt}$
so that
$W_{net}=\int F_{\parallel}\,dl=\int m \frac{dv}{dt}dl$
We don't really want to involve time in our integral directly, so here's the chain rule trick again
$\frac{dv}{dt}=\frac{dv}{dl}\frac{dl}{dt}=\frac{dv}{dl}v$
which lets us write
$W_{net}=\int m v \frac{dv}{dl}dl=\int mv\,dv$
Evaluating this integral from $v_{1}$ to $v_{2}$ gives us that the net work is
$W_{net}=\frac{1}{2}mv_{2}^2-\frac{1}{2}mv_{1}^2$
We can now define the kinetic energy of an object as $\frac{1}{2}mv^2$ and note that any change in this quantity is equal to the net work done on the object. We should note that forces directed perpendicular to the motion, which can change the direction, but not the magnitude of the velocity, as in uniform circular motion, do no work.
Let's look at problem 7.61 from the textbook.
A 5.0 $\mathrm{kg}$ object moving in two dimensions initially has a velocity $\vec{v_{1}} = (11.5\hat{i} + 21.5\hat{j})\mathrm{m/s}$. A net force $\vec{F}$ then acts on the object for $2.0 \mathrm{s}$, after which the object's velocity is $\vec{v_{2}} = (15.0\hat{i}+28.0\hat{j})\mathrm{m/s}$. Determine the work done by $\vec{F}$ on the object.
Hard Way
We need the acceleration.
$\vec{a}=\frac{\vec{v_{2}}-\vec{v_{1}}}{t}=\frac{(15.0-11.5)\hat{i}+(28.0-21.5)\hat{j}}{2}\mathrm{\frac{m/s}{s}}=1.75\hat{i}+3.25\hat{j}\, \mathrm{m/s^2}$
$\vec{F}=m\vec{a}=5(1.75\hat{i}+3.25\hat{j})=8.75\hat{i}+16.25\hat{j}\,\mathrm{N}$
$\vec{d}=\vec{v}_{1}t+\frac{1}{2}\vec{a}t^2=2(11.5\hat{i} + 21.5\hat{j})+2(1.75\hat{i}+3.25\hat{j})=26.5\hat{i}+49.5\hat{j}\,\mathrm{m}$
$W=\vec{F}\cdot\vec{d}=8.75\times26.5+16.25\times49.5=1036.25 \mathrm{J}$
Easy Way
$W=\frac{1}{2}m(v_{2}^2-v_{1}^2)=2.5\times((15^2+28^2)-(11.5^2+21.5^2))$
$=2.5\times((225+784)-(132.25+462.25))=1036.25 \mathrm{J}$
You should make sure you can do this problem both ways!
$W_{net}=\int\vec{F_{net}}\cdot d\vec{l}=\int F_{\parallel}\,dl=\frac{1}{2}mv_{2}^2-\frac{1}{2}mv_{1}^2$
Plus
Minus
Important point
The law of conservation of energy states that within a closed system the total amount of energy is always conserved.
Another way of this is saying this is that energy can be neither created of destroyed, it can only be converted from one form to another.
There are, however, many different forms of energy.
For mechanics problems it is useful to think about a more restricted law, which considers mechanical energy to be conserved.
Conservation of mechanical energy can be assumed whenever the forces which apply to a system are entirely conservative.
A force can be considered to be conservative, if the work done on the object by the force depends only on the beginning and end point of the motion and is independent of the path taken.
A force can only be conservative if the net work done by the force on an object moving around any closed path is zero.
This means that for an object moving from point 1 to point 2 under force the work must be equal and opposite for when it moves from point 2 to point 1.
As we know, the friction force is always in the opposite direction to motion, if we push an object a distance against a frictional force $\vec{F_{Fr}}$ then the work done by the friction on the object is $-F_{Fr}d$. (Note that the work done is negative, the frictional force reduces the kinetic energy.) If we push it back to it's original position the force is now in the opposite direction so the work done by the frictional force is again $-F_{Fr}d$. As the total work done is $-2F_{Fr}d$ we can see that friction is not a conservative force.
Forces that depend on position can be conservative.
For example for a spring
$\int_{x_{1}}^{x_{2}}F_{s}\,dx=-\int_{x_{1}}^{x_{2}}kx\,dx=\frac{1}{2}k(x_{2}^2-x_{1}^2)$
Hooke's Law states that for a spring to be either compressed or stretched from it's equilibrium length the force exerted on it must be
$F_{A}=kx$
the spring exerts an equal and opposite force back on itself
$F_{S}=-kx$
Suppose a spring is extended from $x=0$ to an arbitrary distance $x$. Then the work done on the spring by the applied force is
$W=\int_{0}^{x}F_{A}(x)\,dx=\int_{0}^{x}kx\,dx=\frac{1}{2}kx^2$
and, equally, if we compress the spring
$W=\int_{0}^{-x}F_{A}(x)\,dx=\int_{0}^{-x}kx\,dx=\frac{1}{2}kx^2$
In either case the work done by the spring on itself will be negative and of equal magnitude to the work we do on it ($W=-\frac{1}{2}kx^2$). The net work done on the spring by us and the spring is zero. We should note however that the work that the spring does to cancel out our work does not vanish, it is stored as potential energy.
Work done against a conservative force is not lost. It is converted in to potential energy that can be converted back in to work.
We use the symbol $U$ for potential energy.
The change in potential energy $\Delta U$ is the same as the work done against the force, which is equal and opposite to the work done by the force.
$\Delta U = -\int_{1}^{2}\vec{F}_{G}\cdot\,d\vec{l}$
Although, the change in potential energy is well defined we have absolute freedom in determining the absolute value of potential energy,
$U=\Delta U +U_{0}$
though usually some choices are more sensible than others.
We arrived at the potential energy by integrating the force over displacement.
$\Delta U = -\int_{1}^{2}\vec{F}\cdot\,d\vec{l}$
We can go the other way and obtain the force from the potential. If we have a given potential that varies in space $U(x,y,z)$ then the force is the related to the spatial derivative of the potential.
$\vec{F}(x,y,z)=-\hat{i}\frac{\partial U}{\partial x}-\hat{j}\frac{\partial U}{\partial y}-\hat{k}\frac{\partial U}{\partial z}$
The work-energy theorem which says that the net work done on an object $W_{Net}$ is equal to it's change in kinetic energy $\Delta K$
$W_{Net}=\Delta K$
We also saw that the change in potential energy if only conservative forces are active is
$\Delta U = -\int_{1}^{2}\vec{F}\cdot\,d\vec{l} = - W_{Net} $
So we can see that when only conservative forces act that
$\Delta K + \Delta U = 0 $
We call the sum of the Kinetic Energy and Potential Energy the Total Mechanical Energy E
$E=K+U$
and we can see that under the condition of only conservative forces acting this is a conserved quantity.
We can use the conservation of mechanical energy to know that if the change in height and therefore potential energy is the same in both cases, the kinetic energy gained should be the same in both cases, and thus the velocity at the end of both tracks should be the same.
We can't, however, use this to tell the time taken, this depends on the path taken. We can understand the counter-intuitive result that the longer path takes less time based on the fact that throughout the middle section of the path the ball is always moving faster than it is on the straight path.
In reality there is a limit to how far we can bend the path and still have the ball take less time. The curve of fastest descent is the one closest to a Cycloid.