If , applying the function gives . Since , this implies , proving injectivity. Also every is the image of , because , proving surjectivity.
Thus is a bijection and its inverse function is itself:
Such a function is an involution.
Seek an affine function . Its function composition with itself is
Equating coefficients requires and . Because and , either choice or has . Thus two valid functions are
Substitution into verifies each answer. These provide the requested maps; no assumption that every possible solution is affine function is needed.
There are ordered selections without replacement. Each unordered -element subset occurs in exactly orders, so the binomial coefficient is
One precise specification of its domain, codomain, and map is
Here , and includes the single empty selection. The actual values on are positive, so is also a valid codomain. For fixed , one can instead use the function with .
For , the adjacent binomial coefficients obey
Since and , the sign is determined by the numerator:
The printed codomain is inconsistent with the displayed map: , and when is odd, . With the usual extension for , is a function , and for ; the positive range above remains unchanged. Without that extension, the natural domain is .[ref]
For functions , big O notation means
Using the natural logarithm and exponential function, . Since , for every we have . The witnesses therefore prove
For a nonzero separable solution , separation of variables gives
These Dirichlet boundary conditions follow because is not identically zero. If , the affine function obeys both conditions only when . If , also has only the zero solution under both conditions.
For , . The first boundary condition forces , and the second forces for a nonzero solution. Hence all nonzero spatial modes are
The identically zero function is also a solution. Allowing includes it in the displayed family. Here is the interval length and labels the eigenvalues of the operator with these boundary conditions.
The image of a function is
The function is surjective, or onto, exactly when every equals for at least one , equivalently . It is injective, or one-to-one, exactly when
Thus surjectivity concerns whether the entire codomain is reached; injectivity concerns whether distinct inputs have distinct outputs.
If , then and , so . Thus the function is strictly increasing on its domain and is injective. Its values are nonnegative, so it is not surjective onto :
If means its image of a function is ; if it includes zero its image of a function is . Indeed, for any , set and ; then . This convention does not change the classification.
Put . Because , is a nonnegative integer, and
The function is strictly increasing for , so . Both powers are integers. Taking the floor function therefore gives
Taking nonnegative th roots now gives . Consequently
The argument also covers , when both outer floors are zero.
Apply the multivariable chain rule to a differentiable function on the chosen local branch of the parabolic coordinates:
Substituting part (ii) gives
A function is periodic with period when
The period need not be the smallest positive one; for example, every positive integer multiple of a period is also a period.
We need . Indeed, if , the function is negative on ; if , the improper integral diverges at zero; and if , its support interval is empty. For ,
Setting this equal to one gives the unique admissible value
On this interval , so both requirements for a probability density function are met.
Since , the function is strictly increasing on its support. For ,
and for . Differentiating the cumulative distribution function gives
The density value at the single point is immaterial. Hence has an exponential distribution with rate . Direct integration by parts, or its standard expected value, yields
For the product of finite probability distributions, enumerate the Cartesian product of the two supports and multiply the two probability masses.
def product[T,U](d: FiniteDist[T], d2: FiniteDist[U]): FiniteDist[(T,U)] =
  new FiniteDist[(T,U)] {
    private val dom = for (x <- d.getDom; y <- d2.getDom) yield (x,y)
    def getDom: List[(T,U)] = dom
    def getProb(p: (T,U)): Double = d.getProb(p._1) * d2.getProb(p._2)
  }
Each pair appears once because both original supports have no duplicates. Exact probabilities are positive on that support, and normalization follows by finite distributivity:
For the pushforward of a finite probability distribution, sum all masses in each fiber of a function; simply overwriting repeated image values would lose probability.
def image[T,U](d: FiniteDist[T], f: T => U): FiniteDist[U] =
  new FiniteDist[U] {
    private val weighted = d.getDom.map(x => (f(x), d.getProb(x)))
    private val dom = weighted.map(_._1).distinct
    def getDom: List[U] = dom
    def getProb(y: U): Double =
      weighted.foldLeft(0.0) { case (total, (z,p)) =>
        if (z == y) total+p else total
      }
  }
Assume the given finite probability distributions are fixed and f is a pure total function on the source support. Distinct image values form exactly the positive-mass support. The fibers partition the original support, proving
For example, sending a discrete uniform distribution on to parity produces masses and , not four distinct outcomes. Exact algebra establishes the finite probability distribution laws; Double computes approximations, with the usual possibility of rounding and floating-point underflow for very small products.
Represent a multiset by a pure multiplicity function. Every operation returns a new function describing updated counts:
class ContraMSet[-T](f: T => Int) {
  def count(x: T): Int = f(x)

  def insert(x: T): ContraMSet[T] =
    new ContraMSet[T]((y: T) => f(y) + (if (y == x) 1 else 0))

  def delete(x: T): ContraMSet[T] =
    new ContraMSet[T]((y: T) => {
      val old = f(y)
      if (y == x && old > 0) old - 1 else old
    })

  def union[U <: T](that: ContraMSet[U]): ContraMSet[U] =
    new ContraMSet[U]((y: U) => this.count(y) + that.count(y))
}
An empty instance is new ContraMSet[T]((_: T) => 0). The constructor's precondition is that f is pure and gives a nonnegative integer count, with finite support of a multiset if only finite multisets are intended. Nonnegativity and the support condition are preserved by each operation. Integer overflow must be excluded for this fixed-width count interface.
A contravariant type parameter makes ContraMSet[T] a consumer of values of type T. Thus a counter able to answer queries for every animal can also answer queries restricted to cats. It does not expose or enumerate stored T values. The return type ContraMSet[T] is legal: its outer covariant result position and the class's contravariant argument position together place negatively.
For union, the argument itself is in a negative position, while its ContraMSet argument would reverse that sign. Using ContraMSet[T] directly as the parameter type would therefore put positively and fail the variance-position rule. Introduce : both operands can count every U, and their sum is a ContraMSet[U]. This is a restriction to a common query domain; operations do not promise to preserve counts outside the narrowed domain.[ref]
Pointwise evaluation gives
No old function is modified, so updates preserve immutable object. Constructing each wrapper takes constant work, but a later count may traverse a chain of previously created programming closures; its running time need not be constant in the history length. This functional representation trades enumeration and direct storage of occurrences for composable counting behavior.
A function is onto, or a surjective function, when every has a preimage: . It is one-to-one, or an injective function, when implies for all . It is bijective, a bijection, when both properties hold.
An inverse function is a function satisfying
For a bijection, is the unique with : existence follows from surjectivity and uniqueness from injectivity. This is a two-sided inverse function, rather than just a left or right inverse.