Schematic depiction of the circle of confusion
Theoretically, when a lens is focused on a certain point, exact sharpness will only be obtained in the plane of focus. However, some degree of unsharpness is not possible to decipher for us, and this will still be observed as sharp, while in reality it's already out of focus. When a point source of light is out of focus it will form a circle on the sensor (indicated for the red light source by the curly bracket in the picture on the right), and the size of the circle where we start observing it as out of focus is called the circle of confusion (CoC). So if a point source is out of focus, but its size on the sensor is still smaller than the circle of confusion, we'll observe it as sharp, but if it is bigger than the circle of confusion, we will regard it as unsharp.
The circle of confusion of a print depends on several factors, like the size of the print, the distance from which it is viewed, and last but not least, who is viewing it as some people have better vision than others. As a rule of thumb, the human eye can decipher approximately 5 line pairs per mm (lp/mm) at a viewing distance of 30 cm.
If the size of a print is doubled while the viewing distance is kept the same, then some details which looked sharp before will now look unsharp. Similarly, if you look at a print from a closer distance you see some unsharp details, which looked sharp from a distance.
The circle of confusion for the sensor depends on two things; the circle of confusion which was calculated for the print, and the enlargement of the print. This means that for a smaller sensor the picture will have to be enlarged to a greater extent to obatin a similarly sized print, therefore the circle of confusion for the sensor will decrease. A sharpness obtained with a circle of confusion of 0.03 mm at full frame, will be comparable with a circle of confusion of 0.02 mm when using a camera with a crop factor of 1.5 (0.03/0.02).
In general, 0.03 mm is taken as the standard circle of confusion for 35 mm format. However, modern equipment has better quality than the equipment on which the value of 0.03 was based and many use a smaller circle of confusion nowadays. It's up to ones personal preferences.
Print dimensions* (cm): 
× 
Print resolution (lp/mm): 

Sensor dimensions (mm): 
× 
Horizontal enlargement: 

Vertical enlargement: 

Circle of confusion (mm): 

Calculate!  

* For aspects ratios other than 2:3, this calculator calculates the circle of confusion according to the largest enlargement, and thereby assumes that the image is cropped in the other dimension. If the enlargement is 20 by 30 cm, then the aspect ratio is the same for both the print and the sensor (2:3) and the circle of confusion is the same regardless which dimension you take. However, if you make a print of 20 by 25 cm, then the 20 cm will give the largest enlargement and the circle of confusion is calculated based on that value. It thereby assumes that 5 cm will be cropped from the other dimension (30  25 cm). 
The hyperfocal distance is the point of focus where everything from half that distance to infinity falls within the depth of field. In other words, everything from half the hyperfocal distance to infinity will be sharp. The hyperfocal distance depends on the focal length and the chosen aperture, so either you don't care, or you take a printed chart with the values for the most common focal lengths and aperture values. I do care, but I am too lazy to check the chart every time, so I've memorized the formula below (the "+ f" can in most cases be neglected since the focal length will usually be far smaller than the hyperfocal distance).
$$H = {f^2 \over N×c}+f$$ 

H = hyperfocal distance 

f = focal length 

N = aperture number 

c = circle of confusion 
Some rules of thumb for the hyperfocal distance (the most important being the second one):
• Focus distance = 1/2 × hyperfocal distance • Focus distance = hyperfocal distance • Focus distance = infinity • Focus distance = ~0.4* × hyperfocal distance

→ depth of field will range from 1/3 × hyperfocal distance to hyperfocal distance → depth of field will range from 1/2 × hyperfocal distance to infinity → depth of field will range from hyperfocal distance to infinity → depth of field will be equal to the focus distance (*with some mathematical fun (an oxymoron for most people), the exact number can be calculated to be √2  1) 
Hyperfocal distances for a range of apertures and focal lengths can be calculated below (all hyperfocal distances are given in meters).
Circle of confusion (mm): 


Focal length (mm): 

f/ 

f/ 

f/ 

f/ 

f/ 

f/ 

f/ 

f/ 

f/ 

f/ 

Calculate! 
Depth of field (DOF) is defined as the distance ranges from the camera within which a subject will appear sharp on a print of a certain size viewed from a certain distance. The circle of confusion and the depth of field are directly related since the circle of confusion defines what is sharp and what is not. Other factors influencing the depth of field are the focus distance, focal length and the aperture. For macro photography, the depth of field is a real challenge, as it becomes very shallow at short focus distances. In that case, focus stacking might be an option.
Schematic depiction of how the DOF changes for different apertures =>
[small aperture] [medium aperture] [large aperture]
The scheme to the left shows why the aperture size is of such a big influence on the depth of field. The aperture is depicted by the black bars, and focus is on the blue spot for each case (so no matter which aperture is chosen, the blue spot will be rendered sharp), whereas the red spot is out of focus. The inset in the lower left corner is an approximation of how the two spots will be rendered on the sensor.
From this scheme it can be seen that a large aperture will give rise to a much larger size on the sensor for out of focus objects, compared to a small aperture. In fact, if the aperture is small enough, objects will still be observed as sharp (depending on the chosen circle of confusion), even though the focus is not on them. If the size of the red spot on the sensor is smaller than the circle of confusion, it will be observed as sharp, otherwise it will be observed as unsharp.
The picture below on the left has a very shallow depth of field, only the mushroom is sharp, whereas everything behind it is out of focus. The picture on the right has a large depth of field, as both the plants in the foreground and the plants in the distance are sharp.
A shallow depth of field
A large depth of field
The picture below to the right shows how the aperture is of major importance for the depth of field. In the first example, the aperture is f/4, and the background is obviously unsharp (focus is on the tree on the right). However, the second example is made at f/22 and this results in a sharp background! Note: when viewed at 100%, the background in the f/22 picture is no longer really sharp, which is an example of how the enlargement is important for defining what is sharp and what is not sharp. But in this case, the enlargement is small enough to make the background appear sharp.
Example of how the DOF changes => [large aperture (f/4)] [small aperture (f/22)]
This can also be calculated by using the calculators for circle of confusion and depth of field. If we say that the picture will be viewed from approximately 30 cm (which means the picture resolution will be 5 lp/mm), and the picture is about 14.0 × 9.3 cm (which it is on my screen), then the circle of confusion calculator gives us a value of approximately 0.05 mm. If we use this value in the depth of field calculator, together with an aperture of f/4, a focal length of 20 mm and a focus distance of 0.63 m, then we see that the depth of field ranges from 0.48 m to 0.92 m. So, the tree on the right will be sharp, but everything from 0.92 m and beyond will be observed as unsharp, and this corresponds with the first picture. Calculating the same for f/22 gives a depth of field ranging from 0.23 m to infinity, and this corresponds with the second picture, where everything is observed sharp!
Generally speaking, a lens with a longer focal length has a shallower depth of field, although that depends a bit on how pictures for different focal lengths are compared. It is true that a lens with a long focal length enlarges the background much more than shorter focal lengths, and this makes that they more often have blurry backgrounds. But it also depends on the focus distance.
[long focal length] 
The pictures below show schematically what happens with the picture for different focal lengths and magnifications (focus is on the black tree). The one on the right shows an approximation of what the picture will look like.
• The first picture shows the result for a lens with a long focal length, which is a sharp black tree and a blurry grey tree.
• If we switch to a short focal length, but take the picture at the same spot, then the focus distance is identical and the second picture is obtained. Everything in the picture has become a lot smaller and everything is sharp (although this does depend a bit on the chosen aperture. If the aperture is very large, then chances are that the grey tree will also be blurry).
• If we maintain the short focal length, but approach the black tree in order to obtain the same magnification, then the third picture is obtained. The black tree is the same size as in the first picture, but the grey tree is a lot smaller due to the larger field of view. The grey tree is blurred to the exact same extent as in the first picture (for an explanation on this, see below under meters & micrometers/infinity blur), but since it is much smaller, we will still observe it as sharp (again, this does depend a bit on the chosen aperture. A large aperture can also in this case give a blurry grey tree).
The near and far distances of acceptable sharpness (which is what determines the total depth of field) can be calculated with the formulas below:
$$D_n = {d×(Hf) \over H+d2f}$$ 
D_{n} = near distance of acceptable sharpness 
H = hyperfocal distance 
d = focus distance 
f = focal length 
$$D_f = {d×(Hf) \over Hd}$$ 
D_{f} = far distance of acceptable sharpness 
H = hyperfocal distance 
d = focus distance 
f = focal length 
The depth of field can be calculated with the calculator below (distances greater than 9999 m are considered infinite). The tree icon stands for the subject which the camera is focussed on.
Focal length (mm): 

Focus distance* (m): 


Aperture (f/): 

Circle of confusion (mm): 

Hyperfocal distance (m): 

Near distance of acceptable sharpness (m): 

Far distance of acceptable sharpness (m): 

Total depth of field (m): 

In front of subject (m): 

In front of subject (%): 

Behind subject (m): 

Behind subject (%): 

Calculate!  

*Focus distance is the distance between sensor and subject, should at least be 4 × focal length. 
Depth of field  depth of field and focal length
Calculated for magnification = 0.026, circle of confusion = 0.03 mm and f/8
It is often said that the depth of field is constant regardless of the focal length as long as the magnification is constant, this is however not entirely true. This is a plot of the depth of field vs focal length at the same magnification, which shows that the depth of field is constant regardless of the focal length (at the same magnification) only from a certain focal length. But the only exceptions are wide angles (a focal length of 20 mm or less starts to give a significant difference), so in practice, it can be used as a rule of thumb.
Depth of field  depth of field and focus distance
Calculated for focal length = 50 mm, circle of confusion = 0.03 mm and f/8
Another misconception about the depth of field is that it is distributed as 1/3 in front and 2/3 behind the point of focus. This is a plot of the depth of field vs focus distance (focus distance is the distance between subject and sensor), which shows that depth of field distribution is nowhere near the assumed 1/3 in front and 2/3 behind. The rule of 1/3 in front and 2/3 behind the point of focus is only valid at a focus distance of 1/3 of the hyperfocal distance, all other focus distances have a different ratio.
At larger focus distances more and more of the depth of field will be behind the plane of focus. On the other hand, at very small focus distances (like with macro photography), the depth of field will be distributed equally much in front as behind the plane focus.
In the example on the left, the hyperfocal distance can be calculated to be 10.5 meter, and in the graph we can see that at 3.5 meter (10.5/3) the distribution is indeed 1/3 and 2/3.
Depth of field  depth of field and sensor size
It is often said that cameras with smaller sensors have a larger depth of field, but this depends a bit on how you define this. Let's consider two cameras, a full frame camera (FF), and a camera with a sensor size which is 2/3 the size of full frame, so with a crop factor of 1.5 (CF). If we take a picture with the full frame camera equipped with a 21 mm lens, then we need a 14 mm lens on the crop camera to have the same field of view (14 = 21/1.5). Furthermore, the circle of confusion becomes 2/3 the size for the crop camera, to compensate for the bigger enlargement that is needed to obtain similar prints of the same size. When the aperture number is kept identical, then indeed the depth of field is larger for the crop camera (0.96 versus 0.57 m):
camera 
crop factor 
lens (mm) 
aperture number 
aperture (mm) 
COC (mm) 
DOF 

FF 
1 
21 
f/4 
5.25 
0.03 
0.57 
CF 
1.5 
14 
f/4 
3.5 
0.02 
0.96 
All calculated for focus distance = 1 m. 

Example of how the DOF changes => [FF, 21 mm, f/4] [CF, 14 mm, f/4] [CF, 14 mm, f/2.8]
However, if we keep the aperture size constant, then the depth of field is more or less identical. This new aperture can be easily determined by dividing the aperture number for the full frame camera by the crop factor for the second camera. This will give the aperture number which will give the same depth of field on the camera with a smaller sensor.
So, in this case, an aperture number of f/4 for the full frame camera, divided by a crop factor of 1.5, gives an aperture number of f/2.67 for the crop camera. But, given that there is no such aperture, f/2.8 was taken as the closest approximate. For this reason, there is some minor difference in the aperture size, and thus in the depth of field as well:
camera 
crop factor 
lens (mm) 
aperture number 
aperture (mm) 
COC (mm) 
DOF 

FF 
1 
21 
f/4 
5.25 
0.03 
0.57 
CF 
1.5 
14 
f/2.8 
5.0 
0.02 
0.61 
All calculated for focus distance = 1 m. 

The examples to the left show the above calculations in real life. The first photo was taken with a full frame camera and a 21 mm lens at f/4. The second photo was taken with a crop sensor, a 14 mm lens and again at f/4. Here you can see that the trees behind the foreground tree look a bit less blurry than on the first photo, which is because the depth of field is larger for this situation, which also causes the out of focus objects behind the sharp region to look less blurry. But the third photo shows how the blurriness is more or less the same when the aperture is changed to f/2.8.
So if the aperture number is kept identical, then indeed the depth of field is larger for a camera with a smaller sensor. But if not the aperture number, but the aperture size is kept constant, then the depth of field is more or less identical for both cameras.
Depth of field  taking diffraction into account
As explained under lenses/magnification, diffraction has a signicant impact on image sharpness, and this isn't taken into account in the calculations for e.g. depth of field. Those calculations are based purely on the effect of defocus, but in real life both defocus and diffraction take place simultaneously. When knowing both the blur caused by defocus and the blur caused by diffraction, the total blur can be approximated by this formula:
$$b_{total} = \sqrt{{b_{defocus}}^2+{b_{diffraction}}^2}$$ 
b_{total} = total blurring 
b_{defocus} = blurring due to defocus 
b_{diffraction} = blurring due to diffraction 
But fortunately, rather than adapting the depth of field calculators, there is an alternative and relatively easy way to determine the optimal camera settings, which I read about here, here and here. If you have a foreground subject at distance D_{n} and a background subject at distance D_{f}, then the optimal focus distance can be calculated with the formula below:
$$D_o = \frac{2×D_n×D_f}{D_n+D_f}$$ 
D_{o} = optimal focus distance 
D_{n} = distance to foreground subject 
D_{f} = distance to background subject 
In case the distance to the background subject approaches infinity, the optimal focus distance is two times the distance to the foreground subject, which is the hyperfocal distance. So when the subject in the background approaches infinity, finding the optimal focus distance is easy; two times the distance to the foreground subject:
$$D_o = \frac{2×D_n×D_f}{D_n+D_f} = \frac{2×D_n×\infty}{D_n+\infty} \approx 2×D_n$$ 
D_{o} = optimal focus distance 
D_{n} = distance to foreground subject 
D_{f} = distance to background subject 
So now that the optimal focus distance is known, we only need to find the optimal aperture. A small aperture gives less defocus at the foreground and the background_{}, but gives more diffraction in stead. On the other hand, a large aperture gives more defocus at the foreground and the background, but less diffraction. Somewhere the combination of these two effects has an optimum, and that optimal aperture can be found by using this formula:
$$A_o = \sqrt{375×\left(\frac{D_n×f}{D_nf}\frac{D_f×f}{D_ff}\right)}$$ 
A_{o} = optimal aperture 
D_{n} = distance to foreground subject 
D_{f} = distance to background subject 
f = focal length 
This calculator calculates the optimal conditions according to the previous two formulas, as well as the blur on the sensor for both the point of focus (caused by diffraction) and the foreground/background (caused by both defocus and diffraction).
Distance to foreground subject (m): 

Distance to background subject (m): 

Focal length (mm): 

Optimal focus distance (m): 

Optimal aperture (f/): 

Blur at point of focus (µm): 

Blur at background and foreground (µm): 

Calculate! 

Infinity blur is the size of a projection on the sensor of a point at infinity at a certain focus distance. It can be calculated by multiplying the aperture size with the magnification.
$$b_{infinity} = {\frac{d}{2}{\sqrt{\frac{d^2}{4}f×d}} \over \frac{d}{2}+{\sqrt{\frac{d^2}{4}f×d}}}×\frac{f}{N}= \frac{m×f}{N}$$ 
b_{infinity} = infinity blur 
d = focus distance 
f = focal length 
N = aperture number 
m = magnification 
Some rules of thumb:
• The infinity blur will have the same size as the aperture when magnification is 1:1 (which is when the focus distance is four times the focal length).
• When focussing on the hyperfocal distance, the infinity blur will be equal to the circle of confusion.
• At focus distances greater than the hyperfocal distance, the infinity blur will be smaller than the circle of confusion and objects at infinity will be observed as sharp.
• And of course, when focused on infinity, the infinity blur will be close to zero.
However, like described for depth of field further up on this page, the above formula ignores the effect caused by diffraction. Combining the infinity blur with the blurring caused by diffraction can be done with this approximation:
$$b_{infinity(total)} = \sqrt{{b_{infinity}}^2+{b_{diffraction}}^2}= \sqrt{\left({\frac{m×f}{N}}\right)^2+\left({\frac{N×(1+m)}{750}}\right)^2}$$ 
b_{infinity(total)} = total infinity blur 
b_{infinity} = infinity blur 
b_{diffraction} = blurring due to diffraction 
m = magnification 
f = focal length 
N = aperture number 
This calculator calculates both the infinity blur, and the combined effect of infinity blur with diffraction.
Focal length (mm): 

Focus distance* (m): 

Aperture number (f/): 

Infinity blur (µm): 

Infinity blur + diffraction (µm): 

Calculate!  

*Focus distance is the distance between sensor and subject, should at least be 4 × focal length. 
Infinity blur  infinity blur and focal length
Calculated for magnification = 0.01 and f/8
On the right is a plot of the focal length vs the relative infinity blur, which is probably the lamest graph ever produced as it is just a straight line. The relative infinity blur is the infinity blur as it is observed with the blurred objects at infinity at the same size (as opposed to the "normal" infinity blur, where the object of focus is kept at the same size). This relative infinity blur can be obtained by dividing the infinity blur by the focal length.
This shows that the relative infinity blur is constant, even at small focal lengths. This is in contrast to the depth of field which is not constant at smaller focal lengths.
The fact that the relative infinity blur is only dependent on the aperture can also be deduced from the formulas. As described above, the infinity blur is defined as the aperture size multiplied by the magnification:
$$b_{infinity} = {\frac{m×f}{N}}$$ 
b_{infinity} = infinity blur 
m = magnification 
f = focal length 
N = aperture number 
And since the relative infinity blur can be obtained by dividing the absolute infinity blur by the focal length:
$$b_{infinity(rel)} = {\frac{b_{infinity}}{f}} = {\frac{m×f}{N×f}} = {\frac{m}{N}}$$ 
b_{infinity(rel)} = relative infinity blur 
b_{infinity} = infinity blur 
As can be seen above, the relative infinity blur can be determined by dividing the magnification with the aperture number, and since we are keeping the magnification constant, the relative infinity blur only depends on the aperture number.
Of course, the effect of diffraction is ignored here. If we do take the effect of diffraction into account, then the formula will look like this:
$$b_{infinity(rel, total)} = {\frac{b_{infinity(total)}}{f}} = \frac{\sqrt{{b_{infinity}}^2+{b_{diffraction}}^2}}{f}= \sqrt{\left({\frac{m×f}{N×f}}\right)^2+\left({\frac{N×(1+m)}{750×f}}\right)^2}= \sqrt{\left({\frac{m}{N}}\right)^2+\left({\frac{N×(1+m)}{750×f}}\right)^2}$$ 
b_{infinity(rel,total)} = total relative blur 
b_{infinity(total)} = total blur 
b_{infinity} = infinity blur 
b_{diffraction} = blurring due to diffraction 
m = magnification 
f = focal length 
N = aperture number 
So when taking diffraction into account, the total relative infinity blur is no longer independent of the focal length, but this will only start to play a roll at small apertures, and especially for short focal lengths.
To the right are photos of the same tree, photographed at different focal lengths and different apertures. The tree (which was the point of focus for each photo) was kept at the same size in all photos, in order to keep the magnification constant. Then I took the area with the patch of snow in the distance and enlarged it so it has the same size, regardless of the focal length. If the relative blur is the same, then the blur should be the same as well in these enlargements.
Although the 50 mm lens seems to have a bit less blur for all four apertures for some reason, the results correspond pretty well with the theory:
• At f/4, the influence of diffraction is negligible, and the total relative infinity blur should be constant regardless of the focal length. And indeed, the blur is reasonably constant in the first row.
• At f/7.1, diffraction is still negligible, and the total relative infinity blur is still pretty much identical.
• At f/13, diffraction starts to influence the shorter focal lengths, and indeed the 24 mm shows a bit more relative blurring than the other three focal lengths.
• At f/22, diffraction is getting strong for short focal lengths, and the 50 mm shows a bit more blurring, whereas the 24 mm shows a lot more blurring.

24 mm 
50 mm 
100 mm 
200 mm 

f/4 

f/7.1 

f/13 

f/22 