In mathematics, an **n-sphere** or **hypersphere** is an -dimensional generalization of the -dimensional circle and -dimensional sphere to any non-negative integer . The -sphere is the setting for -dimensional spherical geometry.

Considered extrinsically, as a hypersurface embedded in -dimensional Euclidean space, an -sphere is the locus of points at equal distance (the *radius*) from a given *center* point. Its interior, consisting of all points closer to the center than the radius, is an -dimensional ball. In particular:

- The -sphere is the pair of points at the ends of a line segment (-ball).
- The -sphere is a circle, the circumference of a disk (-ball) in the two-dimensional plane.
- The -sphere, often simply called a sphere, is the boundary of a -ball in three-dimensional space.
- The 3-sphere is the boundary of a -ball in four-dimensional space.
- The -sphere is the boundary of an -ball.

Given a Cartesian coordinate system, the *unit -sphere* of radius can be defined as:

Considered intrinsically, when , the -sphere is a Riemannian manifold of positive constant curvature, and is orientable. The geodesics of the -sphere are called great circles.

The stereographic projection maps the -sphere onto -space with a single adjoined point at infinity; under the metric thereby defined, is a model for the -sphere.

In the more general setting of topology, any topological space that is homeomorphic to the unit -sphere is called an -*sphere*. Under inverse stereographic projection, the -sphere is the one-point compactification of -space. The -spheres admit several other topological descriptions: for example, they can be constructed by gluing two -dimensional spaces together, by identifying the boundary of an -cube with a point, or (inductively) by forming the suspension of an -sphere. When it is simply connected; the -sphere (circle) is not simply connected; the -sphere is not even connected, consisting of two discrete points.

For any natural number , an -sphere of radius is defined as the set of points in -dimensional Euclidean space that are at distance from some fixed point , where may be any positive real number and where may be any point in -dimensional space. In particular:

- a 0-sphere is a pair of points , and is the boundary of a line segment (-ball).
- a 1-sphere is a circle of radius centered at , and is the boundary of a disk (-ball).
- a 2-sphere is an ordinary -dimensional sphere in -dimensional Euclidean space, and is the boundary of an ordinary ball (-ball).
- a 3-sphere is a -dimensional sphere in -dimensional Euclidean space.

The set of points in -space, , that define an -sphere, , is represented by the equation:

where is a center point, and is the radius.

The above -sphere exists in -dimensional Euclidean space and is an example of an -manifold. The volume form of an -sphere of radius is given by

where is the Hodge star operator; see Flanders (1989, §6.1) for a discussion and proof of this formula in the case . As a result,

Main article: Ball (mathematics) |

The space enclosed by an -sphere is called an -ball. An -ball is closed if it includes the -sphere, and it is open if it does not include the -sphere.

Specifically:

- A -
*ball*, a line segment, is the interior of a 0-sphere. - A -
*ball*, a disk, is the interior of a circle (-sphere). - A -
*ball*, an ordinary ball, is the interior of a sphere (-sphere). - A -
*ball*is the interior of a 3-sphere, etc.

Topologically, an -sphere can be constructed as a one-point compactification of -dimensional Euclidean space. Briefly, the -sphere can be described as , which is -dimensional Euclidean space plus a single point representing infinity in all directions.
In particular, if a single point is removed from an -sphere, it becomes homeomorphic to . This forms the basis for stereographic projection.^{[1]}

See also: Volume of an n-ball and Unit sphere § Volume and area |

Let be the surface area of the unit -sphere of radius embedded in -dimensional Euclidean space, and let be the volume of its interior, the unit -ball. The surface area of an arbitrary -sphere is proportional to the st power of the radius, and the volume of an arbitrary -ball is proportional to the th power of the radius.

The -ball is sometimes defined as a single point. The -dimensional Hausdorff measure is the number of points in a set. So

A unit -ball is a line segment whose points have a single coordinate in the interval of length , and the -sphere consists of its two end-points, with coordinate .

A unit -sphere is the unit circle in the Euclidean plane, and its interior is the unit disk (-ball).

The interior of a 2-sphere in three-dimensional space is the unit -ball.

In general, and are given in closed form by the expressions

where is the gamma function.

As tends to infinity, the volume of the unit -ball (ratio between the volume of an -ball of radius and an -cube of side length ) tends to zero.^{[2]}

The *surface area*, or properly the -dimensional volume, of the -sphere at the boundary of the -ball of radius is related to the volume of the ball by the differential equation

Equivalently, representing the unit -ball as a union of concentric -sphere *shells*,

We can also represent the unit -sphere as a union of products of a circle (-sphere) with an -sphere. Then . Since , the equation

holds for all . Along with the base cases , from above, these recurrences can be used to compute the surface area of any sphere or volume of any ball.

We may define a coordinate system in an -dimensional Euclidean space which is analogous to the spherical coordinate system defined for -dimensional Euclidean space, in which the coordinates consist of a radial coordinate , and angular coordinates , where the angles range over radians (or degrees) and ranges over radians (or degrees). If are the Cartesian coordinates, then we may compute from with:^{[3]}^{[a]}

Except in the special cases described below, the inverse transformation is unique:

where atan2 is the two-argument arctangent function.

There are some special cases where the inverse transform is not unique; for any will be ambiguous whenever all of are zero; in this case may be chosen to be zero. (For example, for the -sphere, when the polar angle is or then the point is one of the poles, zenith or nadir, and the choice of azimuthal angle is arbitrary.)

To express the volume element of -dimensional Euclidean space in terms of spherical coordinates, let and for concision, then observe that the Jacobian matrix of the transformation is:

The determinant of this matrix can be calculated by induction. When , a straightforward computation shows that the determinant is . For larger , observe that can be constructed from as follows. Except in column , rows and of are the same as row of , but multiplied by an extra factor of in row and an extra factor of in row . In column , rows and of are the same as column of row of , but multiplied by extra factors of in row and in row , respectively. The determinant of can be calculated by Laplace expansion in the final column. By the recursive description of , the submatrix formed by deleting the entry at and its row and column almost equals , except that its last row is multiplied by . Similarly, the submatrix formed by deleting the entry at and its row and column almost equals , except that its last row is multiplied by . Therefore the determinant of is

Induction then gives a closed-form expression for the volume element in spherical coordinates

The formula for the volume of the -ball can be derived from this by integration.

Similarly the surface area element of the -sphere of radius , which generalizes the area element of the -sphere, is given by

The natural choice of an orthogonal basis over the angular coordinates is a product of ultraspherical polynomials,

for , and the for the angle in concordance with the spherical harmonics.

The standard spherical coordinate system arises from writing as the product . These two factors may be related using polar coordinates. For each point of , the standard Cartesian coordinates

can be transformed into a mixed polar–Cartesian coordinate system:

This says that points in may be expressed by taking the ray starting at the origin and passing through , rotating it towards by , and traveling a distance along the ray. Repeating this decomposition eventually leads to the standard spherical coordinate system.

Polyspherical coordinate systems arise from a generalization of this construction.^{[4]} The space is split as the product of two Euclidean spaces of smaller dimension, but neither space is required to be a line. Specifically, suppose that and are positive integers such that . Then . Using this decomposition, a point may be written as

This can be transformed into a mixed polar–Cartesian coordinate system by writing:

Here and are the unit vectors associated to and . This expresses in terms of , , , and an angle . It can be shown that the domain of is if , if exactly one of and is , and if neither nor are . The inverse transformation is

These splittings may be repeated as long as one of the factors involved has dimension two or greater. A **polyspherical coordinate system** is the result of repeating these splittings until there are no Cartesian coordinates left. Splittings after the first do not require a radial coordinate because the domains of and are spheres, so the coordinates of a polyspherical coordinate system are a non-negative radius and angles. The possible polyspherical coordinate systems correspond to binary trees with leaves. Each non-leaf node in the tree corresponds to a splitting and determines an angular coordinate. For instance, the root of the tree represents , and its immediate children represent the first splitting into and . Leaf nodes correspond to Cartesian coordinates for . The formulas for converting from polyspherical coordinates to Cartesian coordinates may be determined by finding the paths from the root to the leaf nodes. These formulas are products with one factor for each branch taken by the path. For a node whose corresponding angular coordinate is , taking the left branch introduces a factor of and taking the right branch introduces a factor of . The inverse transformation, from polyspherical coordinates to Cartesian coordinates, is determined by grouping nodes. Every pair of nodes having a common parent can be converted from a mixed polar–Cartesian coordinate system to a Cartesian coordinate system using the above formulas for a splitting.

Polyspherical coordinates also have an interpretation in terms of the special orthogonal group. A splitting determines a subgroup

This is the subgroup that leaves each of the two factors fixed. Choosing a set of coset representatives for the quotient is the same as choosing representative angles for this step of the polyspherical coordinate decomposition.

In polyspherical coordinates, the volume measure on and the area measure on are products. There is one factor for each angle, and the volume measure on also has a factor for the radial coordinate. The area measure has the form:

where the factors are determined by the tree. Similarly, the volume measure is

Suppose we have a node of the tree that corresponds to the decomposition and that has angular coordinate . The corresponding factor depends on the values of and . When the area measure is normalized so that the area of the sphere is , these factors are as follows. If , then

If and , and if denotes the beta function, then

If and , then

Finally, if both and are greater than one, then

Main article: Stereographic projection |

Just as a two-dimensional sphere embedded in three dimensions can be mapped onto a two-dimensional plane by a stereographic projection, an -sphere can be mapped onto an -dimensional hyperplane by the -dimensional version of the stereographic projection. For example, the point on a two-dimensional sphere of radius maps to the point on the -plane. In other words,

Likewise, the stereographic projection of an -sphere of radius will map to the -dimensional hyperplane perpendicular to the -axis as

To generate uniformly distributed random points on the unit -sphere (that is, the surface of the unit -ball), Marsaglia (1972) gives the following algorithm.

Generate an -dimensional vector of normal deviates (it suffices to use , although in fact the choice of the variance is arbitrary), . Now calculate the "radius" of this point:

The vector is uniformly distributed over the surface of the unit -ball.

An alternative given by Marsaglia is to uniformly randomly select a point in the unit n-cube by sampling each independently from the uniform distribution over , computing as above, and rejecting the point and resampling if (i.e., if the point is not in the -ball), and when a point in the ball is obtained scaling it up to the spherical surface by the factor ; then again is uniformly distributed over the surface of the unit -ball. This method becomes very inefficient for higher dimensions, as a vanishingly small fraction of the unit cube is contained in the sphere. In ten dimensions, less than 2% of the cube is filled by the sphere, so that typically more than 50 attempts will be needed. In seventy dimensions, less than of the cube is filled, meaning typically a trillion quadrillion trials will be needed, far more than a computer could ever carry out.

With a point selected uniformly at random from the surface of the unit -sphere (e.g., by using Marsaglia's algorithm), one needs only a radius to obtain a point uniformly at random from within the unit -ball. If is a number generated uniformly at random from the interval and is a point selected uniformly at random from the unit -sphere, then is uniformly distributed within the unit -ball.

Alternatively, points may be sampled uniformly from within the unit -ball by a reduction from the unit -sphere. In particular, if is a point selected uniformly from the unit -sphere, then is uniformly distributed within the unit -ball (i.e., by simply discarding two coordinates).^{[5]}

If is sufficiently large, most of the volume of the -ball will be contained in the region very close to its surface, so a point selected from that volume will also probably be close to the surface. This is one of the phenomena leading to the so-called curse of dimensionality that arises in some numerical and other applications.

Let be the square of the first coordinate of a point sampled uniformly at random from the -sphere, then its probability density function, for , is

Let be the appropriately scaled version, then at the limit, the probability density function of converges to . This is sometimes called the Porter–Thomas distribution.^{[6]}

- 0-sphere
- The pair of points with the discrete topology for some . The only sphere that is not path-connected. Parallelizable.
- 1-sphere
- Commonly called a circle. Has a nontrivial fundamental group. Abelian Lie group structure U(1); the circle group. Homeomorphic to the real projective line.
- 2-sphere
- Commonly simply called a sphere. For its complex structure, see
*Riemann sphere*. Homeomorphic to the complex projective line - 3-sphere
- Parallelizable, principal U(1)-bundle over the -sphere, Lie group structure Sp(1).
- 4-sphere
- Homeomorphic to the quaternionic projective line, . .
- 5-sphere
- Principal
*U*(1)-bundle over the complex projective space . . It is undecidable whether a given -dimensional manifold is homeomorphic to for .^{[7]} - 6-sphere
- Possesses an almost complex structure coming from the set of pure unit octonions. . The question of whether it has a complex structure is known as the
*Hopf problem,*after Heinz Hopf.^{[8]} - 7-sphere
- Topological quasigroup structure as the set of unit octonions. Principal -bundle over S^4. Parallelizable. . The -sphere is of particular interest since it was in this dimension that the first exotic spheres were discovered.
- 8-sphere
- Homeomorphic to the octonionic projective line .
- 23-sphere
- A highly dense sphere-packing is possible in -dimensional space, which is related to the unique qualities of the Leech lattice.

The **octahedral -sphere** is defined similarly to the -sphere but using the 1-norm

In general, it takes the shape of a cross-polytope.

The octahedral -sphere is a square (without its interior). The octahedral -sphere is a regular octahedron; hence the name. The octahedral -sphere is the topological join of pairs of isolated points.^{[9]} Intuitively, the topological join of two pairs is generated by drawing a segment between each point in one pair and each point in the other pair; this yields a square. To join this with a third pair, draw a segment between each point on the square and each point in the third pair; this gives a octahedron.