Books Sample

Composition

Once I have two functions I can feed the output of one into the other, provided the types match. If 𝑓:𝐴→𝐵𝑓:𝐴\to 𝐵 and 𝑔:𝐵→𝐶𝑔:𝐵\to 𝐶, the composition 𝑔∘𝑓𝑔\circ 𝑓 is the function 𝐴→𝐶𝐴\to 𝐶 given by

(𝑔∘𝑓)(𝑥)=𝑔(𝑓(𝑥)).(𝑔\circ 𝑓)(𝑥)=𝑔(𝑓(𝑥)).
(1.3)
Theorem 1.1
If 𝑓:𝐴→𝐵𝑓:𝐴\to 𝐵 and 𝑔:𝐵→𝐶𝑔:𝐵\to 𝐶 are functions, then 𝑔∘𝑓:𝐴→𝐶𝑔\circ 𝑓:𝐴\to 𝐶 is a function.
Proof
Each 𝑎∈𝐴𝑎\in 𝐴 has exactly one 𝑓(𝑎)∈𝐵𝑓(𝑎)\in 𝐵 by Definition 1.1, and that value has exactly one 𝑔(𝑓(𝑎))∈𝐶𝑔(𝑓(𝑎))\in 𝐶. The composite assigns exactly one output to each input, which is (1.3).

The graph of a composite is not the composite of the graphs; compare (1.1). Pairing (𝑥,𝑓(𝑥))(𝑥,𝑓(𝑥)) with (𝑓(𝑥),𝑔(𝑓(𝑥)))(𝑓(𝑥),𝑔(𝑓(𝑥))) and forgetting the middle coordinate is a different operation from composing two subsets of the plane.

The order is the order of application, read right to left: 𝑓𝑓 first, then 𝑔𝑔. I keep forgetting this and then a computation reminds me.

Algebra of composition

Composition is associative whenever it is defined,

h∘(𝑔∘𝑓)=(h∘𝑔)∘𝑓,h\circ (𝑔\circ 𝑓)=(h\circ 𝑔)\circ 𝑓,
(1.4)

because both sides send 𝑥𝑥 to h(𝑔(𝑓(𝑥)))h(𝑔(𝑓(𝑥))). It is not commutative. Take 𝑓(𝑥)=𝑥+1𝑓(𝑥)=𝑥+1 and 𝑔(𝑥)=2𝑥𝑔(𝑥)=2𝑥. Then

(𝑔∘𝑓)(𝑥)=2𝑥+2,(𝑓∘𝑔)(𝑥)=2𝑥+1.(𝑔\circ 𝑓)(𝑥)=2𝑥+2,\quad (𝑓\circ 𝑔)(𝑥)=2𝑥+1.

Same two functions, two different composites. The identity is the two-sided unit: 𝑓∘𝐼𝐴=𝑓=𝐼𝐵∘𝑓𝑓\circ {𝐼}_{𝐴}=𝑓={𝐼}_{𝐵}\circ 𝑓 when 𝑓:𝐴→𝐵𝑓:𝐴\to 𝐵.

Proposition 1.1
If 𝑓:𝐴→𝐵𝑓:𝐴\to 𝐵, then 𝑓∘𝐼𝐴=𝑓𝑓\circ {𝐼}_{𝐴}=𝑓 and 𝐼𝐵∘𝑓=𝑓{𝐼}_{𝐵}\circ 𝑓=𝑓.
Proof
(𝑓∘𝐼𝐴)(𝑎)=𝑓(𝐼𝐴(𝑎))=𝑓(𝑎)(𝑓\circ {𝐼}_{𝐴})(𝑎)=𝑓({𝐼}_{𝐴}(𝑎))=𝑓(𝑎) and (𝐼𝐵∘𝑓)(𝑎)=𝐼𝐵(𝑓(𝑎))=𝑓(𝑎)({𝐼}_{𝐵}\circ 𝑓)(𝑎)={𝐼}_{𝐵}(𝑓(𝑎))=𝑓(𝑎).

When composition is defined

The rule is strict. 𝑔∘𝑓𝑔\circ 𝑓 exists, with domain 𝐴𝐴, only if every value of 𝑓𝑓 lands in the domain of 𝑔𝑔. If 𝑓:R→R𝑓:\mathbb{R}\to \mathbb{R} is 𝑓(𝑥)=𝑥2𝑓(𝑥)={𝑥}^{2} and 𝑔:(0,∞)→R𝑔:(0,\infty )\to \mathbb{R} is 𝑔(𝑥)=1𝑥𝑔(𝑥)=\frac{1}{𝑥}, then 𝑔∘𝑓𝑔\circ 𝑓 is not defined on all of R\mathbb{R}: 𝑓(0)=0𝑓(0)=0 is not in (0,∞)(0,\infty ). Restrict the domain of 𝑓𝑓 to R∖{0}\mathbb{R}∖\{0\} and the composite exists,

(𝑔∘𝑓)(𝑥)=1𝑥2.(𝑔\circ 𝑓)(𝑥)=\frac{1}{{𝑥}^{2}}.

I would rather notice the missing point than invent a value at zero.

Example 1.2
Let 𝑠(𝑥)=𝑥2𝑠(𝑥)={𝑥}^{2} on R\mathbb{R} and 𝑟(𝑥)=𝑥𝑟(𝑥)=\sqrt{𝑥} on [0,∞)[0,\infty ). Then 𝑟∘𝑠𝑟\circ 𝑠 is not defined on R\mathbb{R}, because 𝑠𝑠 takes negative values. Restrict 𝑠𝑠 to [0,∞)[0,\infty ) and 𝑟∘𝑠𝑟\circ 𝑠 is the identity there. The other way around, 𝑠∘𝑟𝑠\circ 𝑟 is defined on [0,∞)[0,\infty ), and (𝑠∘𝑟)(𝑥)=𝑥(𝑠\circ 𝑟)(𝑥)=𝑥. So one order is a left inverse on a smaller domain, and the other is not even typed until I cut.

Reading a long chain

A long expression like sin⁡(𝑒𝑥2)\sin ({𝑒}^{{𝑥}^{2}}) is a composition written inside out. Unpacking it,

𝑥↦𝑥2↦𝑒𝑥2↦sin⁡(𝑒𝑥2).𝑥\mapsto {𝑥}^{2}\mapsto {𝑒}^{{𝑥}^{2}}\mapsto \sin ({𝑒}^{{𝑥}^{2}}).
(1.5)

When I later differentiate, this is the chain I will walk backwards. Associativity (1.4) says I may parenthesize the chain however I like; the derivative will care about the order of the factors, not about where I put the parentheses.

Exercise 1.2
Let 𝑔(𝑥)=∣𝑥∣𝑔(𝑥)=|𝑥| and 𝑓(𝑥)=𝑥−1𝑓(𝑥)=𝑥-1. Compute (𝑔∘𝑓)(𝑥)(𝑔\circ 𝑓)(𝑥) and (𝑓∘𝑔)(𝑥)(𝑓\circ 𝑔)(𝑥). Where do they differ?
Solution to Exercise 1.2
(𝑔∘𝑓)(𝑥)=∣𝑥−1∣(𝑔\circ 𝑓)(𝑥)=|𝑥-1| and (𝑓∘𝑔)(𝑥)=∣𝑥∣−1(𝑓\circ 𝑔)(𝑥)=|𝑥|-1. They agree for 𝑥≥1𝑥\geq 1; at 𝑥=0𝑥=0 one is 11 and the other is −1-1.