Consider the real line with its ordinary topology. This space is not compact; in a sense, points can go off to infinity to the left or to the right. It is possible to turn the real line into a compact space by adding a single "point at infinity" which we will denote by ∞. The resulting compactification can be thought of as a circle (which is compact as a closed and bounded subset of the Euclidean plane). Every sequence that ran off to infinity in the real line will then converge to ∞ in this compactification.
Intuitively, the process can be pictured as follows: first shrink the real line to the open interval (-π,π) on the x-axis; then bend the ends of this interval upwards (in positive y-direction) and move them towards each other, until you get a circle with one point (the topmost one) missing. This point is our new point ∞ "at infinity"; adding it in completes the compact circle.
A bit more formally: we represent a point on the unit circle by its angle, in radians, going from -π to π for simplicity. Identify each such point θ on the circle with the corresponding point on the real line tan(θ/2). This function is undefined at the point π/2, since tan(π/2) is undefined there; we will identify this point with our point ∞.
Since tangents and inverse tangents are both continuous, our identification function is a homeomorphism between the real line and the unit circle without ∞. What we have constructed is called the Alexandroff one-point compactification of the real line, discussed in more generality below. It is also possible to compactify the real line by adding two points, +∞ and -∞; this results in the extended real line.
It is often useful to embed topological spaces in compact spaces, because of the strong properties compact spaces have. An embedding of a topological space X as a dense subset of a compact space is called a compactification of X.
Embeddings into compact Hausdorff spaces may be of particular interest. Since every compact Hausdorff space is a Tychonoff space, and every subspace of a Tychonoff space is Tychonoff, we conclude that any space possessing a Hausdorff compactification must be a Tychonoff space. In fact, the converse is also true; being a Tychonoff space is both necessary and sufficient for possessing a Hausdorff compactification.
The Stone-Čech compactification can be constructed explicitly as follows: let C be the set of continuous functions from X to the closed interval [0,1]. Then each point in X can be identified with an evaluation function on C. Thus X can be identified with a subset of [0,1]C, the space of all functions from C to [0,1]. Since the latter is compact by Tychonoff's theorem, the closure of X as a subset of that space will also be compact. This is the Stone-Čech compactification.
Complex projective space CPn is also a compactification of Cn; the Alexandroff one-point compactification of the plane C is (homeomorphic to) the complex projective line CP1, which in turn can be identified with a sphere, the Riemann sphere.
Passing to projective space is a common tool in algebraic geometry because the added points at infinity lead to simpler formulations of many theorems. For example, any two different lines in RP2 intersect in precisely one point, a statement that is not true in R2.
For example modular curves are compactified by the addition of single points for each cusp, making them Riemann surfaces (and so, since they are compact, algebraic curves). Here the cusps are there for a good reason: the curves parametrize a space of lattices, and those lattices can degenerate ('go off to infinity'), often in a number of ways (taking into account some auxiliary structure of level). The cusps stand in for those different 'directions to infinity'.
That is all for lattices in the plane. In n-dimensional Euclidean space the same questions can be posed, for example about GLn(R)/GLn(Z). This is harder to compactify. There is a general theory, the Borel-Serre compactification, that is now applied.