5
$\begingroup$

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

$\endgroup$
10
  • $\begingroup$ What's your question? $\endgroup$ Sep 25 '15 at 9:56
  • $\begingroup$ What is “pointwise”, in the context of function composition? $\endgroup$ Sep 25 '15 at 9:58
  • $\begingroup$ Welcome to math.stackexchange! This website is for people who study mathemathics at all possible levels. The only prerequisite here is willingness to expand your understanding of maths so don't worry about your lack of background. Note that terms that you mention in your post come up in many disperate branches of mathemathics and from what you wrote I can't quite pin down what you are looking for. Can you elaborate on that? Maybe give us some more context? Cheers. $\endgroup$
    – Blazej
    Sep 25 '15 at 10:02
  • $\begingroup$ I agree, you should try to give the sentence in which it appears. $\endgroup$
    – Stravog
    Sep 25 '15 at 10:03
  • $\begingroup$ The wikipedia article says, what this means... Maybe you should read it a second time or ask specifically, with which part of the explanation you struggle. Currently your question is very rough.. $\endgroup$ Sep 25 '15 at 10:04
12
$\begingroup$

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.'

$\endgroup$
3
  • $\begingroup$ I agree, especially in programming if you are not working on a formal calculus software, everything ends being discrete. $\endgroup$
    – Stravog
    Sep 25 '15 at 10:19
  • 1
    $\begingroup$ I agree, pointwise seems pointless ;) $\endgroup$
    – mrf
    Sep 25 '15 at 11:35
  • $\begingroup$ @mrf That is pretty much the optimal way to summarize the situation :) $\endgroup$
    – rschwieb
    Sep 25 '15 at 13:21
6
$\begingroup$

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).

$\endgroup$
5
  • 1
    $\begingroup$ It does! Although I'm gonna have to reflect on it more than you can probably imagine. But thanks! $\endgroup$ Sep 25 '15 at 10:22
  • 1
    $\begingroup$ That's a reasonable interpretation, although I'm not sure if that's what the author of that sentence of he article was thinking. Either way, this is helpful $\endgroup$
    – rschwieb
    Sep 25 '15 at 10:30
  • $\begingroup$ @ferhtgoldaraz Same here. This doesn't say much to programmers :/ $\endgroup$ Jan 24 '18 at 22:49
  • 1
    $\begingroup$ @KarlMorrison See the edit. $\endgroup$
    – dtldarek
    Mar 28 '18 at 8:22
  • $\begingroup$ Thanks for the Python snippet, it helps a lot! It also illustrates, nicely, the intersection of math and programming =) $\endgroup$
    – user537890
    Mar 29 '18 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.