In mathematics, an **embedding** (or **imbedding**^{[1]}) is one instance of some mathematical structure contained within another instance, such as a group that is a subgroup.

When some object is said to be embedded in another object , the embedding is given by some injective and structure-preserving map . The precise meaning of "structure-preserving" depends on the kind of mathematical structure of which and are instances. In the terminology of category theory, a structure-preserving map is called a morphism.

The fact that a map is an embedding is often indicated by the use of a "hooked arrow" (U+21AA ↪ RIGHTWARDS ARROW WITH HOOK);^{[2]} thus: (On the other hand, this notation is sometimes reserved for inclusion maps.)

Given and , several different embeddings of in may be possible. In many cases of interest there is a standard (or "canonical") embedding, like those of the natural numbers in the integers, the integers in the rational numbers, the rational numbers in the real numbers, and the real numbers in the complex numbers. In such cases it is common to identify the domain with its image contained in , so that .

In general topology, an embedding is a homeomorphism onto its image.^{[3]} More explicitly, an injective continuous map between topological spaces and is a **topological embedding** if yields a homeomorphism between and (where carries the subspace topology inherited from ). Intuitively then, the embedding lets us treat as a subspace of . Every embedding is injective and continuous. Every map that is injective, continuous and either open or closed is an embedding; however there are also embeddings which are neither open nor closed. The latter happens if the image is neither an open set nor a closed set in .

For a given space , the existence of an embedding is a topological invariant of . This allows two spaces to be distinguished if one is able to be embedded in a space while the other is not.

If the domain of a function is a topological space then the function is said to be *locally injective at a point* if there exists some neighborhood of this point such that the restriction is injective. It is called *locally injective* if it is locally injective around every point of its domain. Similarly, a *local (topological, resp. smooth) embedding* is a function for which every point in its domain has some neighborhood to which its restriction is a (topological, resp. smooth) embedding.

Every injective function is locally injective but not conversely. Local diffeomorphisms, local homeomorphisms, and smooth immersions are all locally injective functions that are not necessarily injective. The inverse function theorem gives a sufficient condition for a continuously differentiable function to be (among other things) locally injective. Every fiber of a locally injective function is necessarily a discrete subspace of its domain

In differential topology:
Let and be smooth manifolds and be a smooth map. Then is called an immersion if its derivative is everywhere injective. An **embedding**, or a **smooth embedding**, is defined to be an immersion which is an embedding in the topological sense mentioned above (i.e. homeomorphism onto its image).^{[4]}

In other words, the domain of an embedding is diffeomorphic to its image, and in particular the image of an embedding must be a submanifold. An immersion is precisely a **local embedding**, i.e. for any point there is a neighborhood such that is an embedding.

When the domain manifold is compact, the notion of a smooth embedding is equivalent to that of an injective immersion.

An important case is . The interest here is in how large must be for an embedding, in terms of the dimension of . The Whitney embedding theorem^{[5]} states that is enough, and is the best possible linear bound. For example, the real projective space of dimension , where is a power of two, requires for an embedding. However, this does not apply to immersions; for instance, can be immersed in as is explicitly shown by Boy's surface—which has self-intersections. The Roman surface fails to be an immersion as it contains cross-caps.

An embedding is **proper** if it behaves well with respect to boundaries: one requires the map to be such that

- , and
- is transverse to in any point of .

The first condition is equivalent to having and . The second condition, roughly speaking, says that is not tangent to the boundary of .

In Riemannian geometry and pseudo-Riemannian geometry:
Let and be Riemannian manifolds or more generally pseudo-Riemannian manifolds.
An **isometric embedding** is a smooth embedding which preserves the (pseudo-)metric in the sense that is equal to the pullback of by , i.e. . Explicitly, for any two tangent vectors we have

Analogously, **isometric immersion** is an immersion between (pseudo)-Riemannian manifolds which preserves the (pseudo)-Riemannian metrics.

Equivalently, in Riemannian geometry, an isometric embedding (immersion) is a smooth embedding (immersion) which preserves length of curves (cf. Nash embedding theorem).^{[6]}

In general, for an algebraic category , an embedding between two -algebraic structures and is a -morphism that is injective.

In field theory, an **embedding** of a field in a field is a ring homomorphism .

The kernel of is an ideal of which cannot be the whole field , because of the condition . Furthermore, it is a well-known property of fields that their only ideals are the zero ideal and the whole field itself. Therefore, the kernel is , so any embedding of fields is a monomorphism. Hence, is isomorphic to the subfield of . This justifies the name *embedding* for an arbitrary homomorphism of fields.

Further information: Substructure (mathematics) and Elementary equivalence |

If is a signature and are -structures (also called -algebras in universal algebra or models in model theory), then a map is a -embedding exactly if all of the following hold:

- is injective,
- for every -ary function symbol and we have ,
- for every -ary relation symbol and we have iff

Here is a model theoretical notation equivalent to . In model theory there is also a stronger notion of elementary embedding.

In order theory, an embedding of partially ordered sets is a function between partially ordered sets and such that

Injectivity of follows quickly from this definition. In domain theory, an additional requirement is that

- is directed.

A mapping of metric spaces is called an *embedding*
(with distortion ) if

for every and some constant .

An important special case is that of normed spaces; in this case it is natural to consider linear embeddings.

One of the basic questions that can be asked about a finite-dimensional normed space is, *what is the maximal dimension such that the Hilbert space can be linearly embedded into with constant distortion?*

The answer is given by Dvoretzky's theorem.

In category theory, there is no satisfactory and generally accepted definition of embeddings that is applicable in all categories. One would expect that all isomorphisms and all compositions of embeddings are embeddings, and that all embeddings are monomorphisms. Other typical requirements are: any extremal monomorphism is an embedding and embeddings are stable under pullbacks.

Ideally the class of all embedded subobjects of a given object, up to isomorphism, should also be small, and thus an ordered set. In this case, the category is said to be well powered with respect to the class of embeddings. This allows defining new local structures in the category (such as a closure operator).

In a concrete category, an **embedding** is a morphism which is an injective function from the underlying set of to the underlying set of and is also an **initial morphism** in the following sense:
If is a function from the underlying set of an object to the underlying set of , and if its composition with is a morphism , then itself is a morphism.

A factorization system for a category also gives rise to a notion of embedding. If is a factorization system, then the morphisms in may be regarded as the embeddings, especially when the category is well powered with respect to . Concrete theories often have a factorization system in which consists of the embeddings in the previous sense. This is the case of the majority of the examples given in this article.

As usual in category theory, there is a dual concept, known as quotient. All the preceding properties can be dualized.

An embedding can also refer to an embedding functor.