What is "pointwise", in the context of function composition?

4.9k Views Asked by At

APOLOGY: This question is asked by someone foreign to math, with the expectation that math.stackexchange can be a resource to (among other things) understand math concepts.

I'm a self-taught project-of programmer. I would like to understand "projection", beacuse it's used in functional programming (related to lamda calculus I hear), and in a database called MongoDB.

For the math term of projection Wikipedia links to "function composition", whose page in turn links to "pointwise".

The question is: What is “pointwise”, in the context of function composition?

So that (from wikipedia's "projection")

"In mathematics, a projection is a mapping of a set (or other mathematical structure) into a subset (or sub-structure), which is equal to its square for mapping composition (or, in other words, which is idempotent)."

Can be understood once (from wikipedia's "function composition"):

In mathematics, function composition is the pointwise application of one function to the result of another to produce a third function.

Is understood...

Thanks in advance.

Also, resources to material that can help with this kind of doubts are very much welcome

2

There are 2 best solutions below

5
On BEST ANSWER

It means that the composition of $f$ and $g$ is defined as

$$(f \circ g)(x) = f\big(g(x)\big)$$

where $f$ is applied to the result of $g$ separately for each $x$, rather than applying $f$ globally to $g$ itself like this:

$$x \mapsto \big(f(g)\big)(x).$$

To give you an example, let $f(h) = x \mapsto \langle h(x), h(x) \rangle$ and define $g$ as $$ g(x) = \begin{cases} y \mapsto y+2 & \text{if } x = 0, \\ y \mapsto y\cdot 2 & \text{otherwise}. \end{cases} $$ Then $$(f \circ g)(x) = \begin{cases} y \mapsto \langle y+2, y+2 \rangle & \text{if } x = 0, \\ y \mapsto \langle y\cdot 2, y \cdot 2\rangle & \text{otherwise}, \end{cases} $$ while $$\big(f(g)\big)(x) = \begin{cases} \langle y \mapsto y+2, y \mapsto y+2 \rangle& \text{if } x = 0, \\ \langle y \mapsto y\cdot 2, y \mapsto y\cdot 2 \rangle & \text{otherwise}. \end{cases} $$

I hope this helps $\ddot\smile$

Edit: For programmers (in Python):

def f(h):
  return lambda x: (h(x), h(x))

def g(x):
  if x == 0:
    return lambda y: y+2
  else:
    return lambda y: y*2

def compose(f, g):
  return lambda x: f(g(x))

def fg_compose(x):
  if x == 0:
    return lambda y: (y+2, y+2)
  else:
    return lambda y: (y*2, y*2)

def fg_apply(x):
  if x == 0:
    return (lambda y: y+2, lambda y: y+2)
  else:
    return (lambda y: y*2, lambda y: y*2)

Now compose(f, g) is equivalent to fg_compose, and f(g) is equivalent to fg_apply, that is, under most circumstances compose(f,g)(x) should give you the same result as fg_compose(x), and f(g)(x) should give you same result as fg_apply(x).

That being said, in programming few objects are pure, and while the corresponding ideal mathematical functions are equal, the execution paths in whatever language you are using are probably different, and so the final results might sometimes fail to match (the easiest example that comes to mind is that compose(f,g)(x) probably uses more memory than fg_compose(x) and so in the rightly contrived circumstances the former will fail while the latter might still work).

3
On

IMO that is a needlessly confusing application of the word 'pointwise' in that article intro.

I have always seen "pointwise multiplication" refer to the operation of multiplying two functions via the rule $fg(x)=f(x)g(x)$. That is, you multiply the values as if they were parallel lists, and you multiply corresponding terms. Similarly, you could say that vector addition is 'pointwise addition' because you're adding the entries in parallel according to their indices.

In the article, rather, it is just using it to mean that they are describing the value of a newly formed function at $x$ in terms of a point $x$ and the two functions $f,g$.

Whoever wrote that probably could argue why the phrase is technically correct, but I don't think it clarifies anything. It is so common to describe functions by their action on each individual point that it does not seem helpful to call it 'pointwise.'