{"cells": [{"cell_type": "markdown", "metadata": {"tags": ["module-mfg"]}, "source": ["# Composition and Inverse Functions\n", "[Mathematics for Geoscientists](module-mfg) \n", "\n", "(compninv_isb)=\n", "## Injection, Surjection, Bijection\n", "\n", "```{index} Injection\n", "```\n", "\n", "```{index} Surjection\n", "```\n", "\n", "```{index} Bijection\n", "```\n", "\n", "Before we start talking about inverse functions, let us define some very important terms.\n", "\n", "A function $f: A \\to B$ is:\n", "\n", "1. an **injection** (or *injective* or *one-to-one*) if different elements of the domain are assigned different elements of the codomain, i.e.:\n", "\n", "$$ \\forall a, a' \\in A, (a \\neq a') \\Rightarrow (f(a) \\neq f(a')). $$\n", "\n", "We can determine easily whether a function is an injection from its graph. For a function to be injective, any horizontal line must cross its graph in at most one point. This is why the introduced notion of strictly monotonic function is important: if a function is **strictly monotonic** (on some interval or on its entire domain), then it is an injection.\n", "\n", "2. a **surjection** (or *surjective* or *onto*) if *every* element of its codomain $B$ is a possible value of $f(a)$ for some $a \\in A$. That is, the image of $f$ must be equal to its codomain. That is,\n", "\n", "$$ \\forall b \\in B, \\exists a \\in A : f(a) = b. $$\n", "\n", "3. a **bijection** (or *bijective* or one-to-one and onto or one-to-one correspondence) if it is both an injection and a surjection. That is,\n", "\n", "$$ \\forall b \\in B, \\exists ! a \\in A: f(a) = b. $$\n", "\n", "Let us summarise this in a table (source: [Wikipedia](https://en.wikipedia.org/wiki/Bijection,_injection_and_surjection)):\n", "\n", "```{list-table}\n", ":header-rows: 1\n", ":widths: 10 20 20\n", ":align: center\n", "\n", "* - \n", " -
surjective\n", " -
non-surjective\n", "* - **injective**\n", " -
**bijective**\n", " -
**injective-only**\n", "* - **non-injective**\n", " -
**surjective-only**\n", " -
**general**\n", "```"]}, {"cell_type": "markdown", "metadata": {}, "source": ["(compninv_composition)=\n", "## Function composition\n", "\n", "```{index} Composition (functions)\n", "```\n", "\n", "Let $f: A \\to B$ and $g: C \\to D$ be two functions. If $f[A] \\subseteq C$, we can define a function $h: A \\to D$ such that $h(x) = g[f(x)], \\forall x \\in A$. We denote the function $h$ defined this way by $g \\circ f$ and call it the **composition** of $g$ and $f$.\n", "\n", "This is generally *not* a commutative operation. For $f: \\mathbb{R} \\to \\mathbb{R}, f(x) = x + 1$ and $g: \\mathbb{R} \\to \\mathbb{R}, g(x) = x^2$:\n", "\n", "$$ (g \\circ f)(x) = (x+1)^2 \\\\\n", "(f \\circ g)(x) = x^2 + 1 $$\n", "\n", "But it is associative. For $f: \\mathbb{R} \\to \\mathbb{R}, f(x) = x + 1, g: \\mathbb{R} \\to \\mathbb{R}, g(x) = \\sin(x)$ and $h: \\mathbb{R} \\to \\mathbb{R}, h(x) = \\sqrt{x^2}$:\n", "\n", "$$ [h \\circ (g \\circ f)](x) = h[\\sin(x + 1)] = \\sqrt{\\sin^2(x+1)} \\\\\n", "[(h \\circ g) \\circ f](x) = \\sqrt{ \\sin^2[f(x)] } = \\sqrt{\\sin^2(x+1)} $$\n", "\n", "As an example of a function composition that is *not* defined, consider $f: \\mathbb{R} \\to \\mathbb{R}$ where $f(x) = \\cos x$ and $g: \\mathbb{R} \\to \\mathbb{R}$ where $g(x) = \\sqrt{x}$. The range of $f$ is $[-1, 1]$ but the natural domain of $g$ is $[0, + \\infty)$."]}, {"cell_type": "markdown", "metadata": {}, "source": ["(compninv_inverse)=\n", "## Inverse function\n", "\n", "```{index} Inverse (functions)\n", "```\n", "\n", "Let $f: A \\to B$ be a function and assume there exists another function $g: B \\to A$ such that for all $x \\in A$ and for all $y \\in B$:\n", "\n", "$$ g[f(x)] = x \\iff f[g(y)] = y. $$\n", "\n", "We then call $g$ the **inverse function** of $f$ and we denote it $g = f^{-1}$.\n", "\n", "```{admonition} Properties\n", "\n", "- A function $f$ is invertible iff it is a bijection\n", "\n", "- The inverse function $f^{-1}$ is unique.\n", "\n", "- The graph of the inverse function $G(f^{-1})$ is symmetric to the graph $G(f)$ with respect to $y = x$. \n", "\n", "- Monotonic properties of $f$ are preserved on $f^{-1}$\n", "```"]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": []}], "metadata": {"celltoolbar": "Tags", "kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "language_info": {"codemirror_mode": {"name": "ipython", "version": 3}, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.8"}}, "nbformat": 4, "nbformat_minor": 4}