|Mathematical analysis → Complex analysis|
|Geometric function theory|
In complex analysis, the Schwarz triangle function or Schwarz s-function is a function that conformally maps the upper half plane to a triangle in the upper half plane having lines or circular arcs for edges. The target triangle is not necessarily a Schwarz triangle, although that is the most mathematically interesting case. When that triangle is a non-overlapping Schwarz triangle, i.e. a Möbius triangle, the inverse of the Schwarz triangle function is a single-valued automorphic function for that triangle's triangle group. More specifically, it is a modular function.
Let πα, πβ, and πγ be the interior angles at the vertices of the triangle in radians. Each of α, β, and γ may take values between 0 and 1 inclusive. Following Nehari,  these angles are in clockwise order, with the vertex having angle πα at the origin and the vertex having angle πγ lying on the real line. The Schwarz triangle function can be given in terms of hypergeometric functions as:
This function maps the upper half-plane to a spherical triangle if α + β + γ > 1, or a hyperbolic triangle if α + β + γ < 1. When α + β + γ = 1, then the triangle is a Euclidean triangle with straight edges: a = 0, , and the formula reduces to that given by the Schwarz–Christoffel transformation.
Through the theory of complex ordinary differential equations with regular singular points and the Schwarzian derivative, the triangle function can be expressed as the quotient of two solutions of a hypergeometric differential equation with real coefficients and singular points at 0, 1 and ∞. By the Schwarz reflection principle, the reflection group induces an action on the two dimensional space of solutions. On the orientation-preserving normal subgroup, this two-dimensional representation corresponds to the monodromy of the ordinary differential equation and induces a group of Möbius transformations on quotients of hypergeometric functions. 
where is the gamma function.
Near each singular point, the function may be approximated as
where is big O notation.
When α, β, and γ are rational, the triangle is a Schwarz triangle. When each of α, β, and γ are either the reciprocal of an integer or zero, the triangle is a Möbius triangle, i.e. a non-overlapping Schwarz triangle. For a Möbius triangle, the inverse is a modular function.
When α = 0 the triangle is degenerate, lying entirely on the real line. If either of β or γ are non-zero, the angles can be permuted so that the positive value is α, but that is not an option for an ideal triangle having all angles zero.
Instead, a mapping to an ideal triangle with vertices at 0, 1, and ∞ is given by in terms of the complete elliptic integral of the first kind:
The Schwarz–Christoffel transformation gives the mapping from the upper half-plane to any Euclidean polygon.
The methodology used to derive the Schwarz triangle function earlier can be applied more generally to arc-edged polygons. However, for an n-sided polygon, the solution has n-3 additional parameters, which are difficult to determine in practice.  See Schwarzian derivative § Conformal mapping of circular arc polygons for more details.