# Difference between f[x] and f as arguments of functions

I'm new to Mathematica and trying to better understand the syntax. In the documentation, the function Limit has the signature:

Limit[f[x], x -> x0]


whereas FixedPoint has:

FixedPoint[f, expr]


What is the difference between arguments of the form f and f[x]? I seem to be unable to pass pure functions in the case of Limit.

• A pure function does not involve any variable names, so as you vary x, it will not change, and the limiting value will just be the pure function. – Alan May 24 '18 at 15:08
• @Alan Is that the only difference between these cases? – TheMountainThatCodes May 24 '18 at 15:17

The difference here is that f in FixedPoint is a function that (in the first iteration) gets applied to expr to form f[expr]. Then in the second iteration it gets applied again to form f[f[expr]] and FixedPoint checks if f[f[expr]] is the same as f[expr].

You couldn't apply f[x] to expr, because you'd get f[x][expr] rather than f[expr]. In the second iteration you'd get f[x][f[x][expr]]. In most cases this would be meaningless. Technically, though, f[x] CAN be a function if you do something like:

f[x_] := Function[{y}, x + y]


In this case f would be the "add one" operator that you can apply to other values:

f
(* 3 *)


Now Limit on the other hand uses a substitution rule (or at least: the syntax of one). The best function to illustrate this with is ReplaceAll (or /. for short), which is a function that inspects an expression and replaces bits based on replacement rules you give. For example:

Clear[x];
{1, 2, 3, x} /. x -> 4


results in {1, 2, 3, 4}. The reason I first do Clear[x] is that this wouldn't work correctly if x had a value, so you have to be a bit careful when you use them. For example:

x = 1;
{1, 2, 3, x} /. x -> 4


which gives you {4, 2, 3, 4}. If you use TracePrint[{1, 2, 3, x} /. x -> 4], you can see what happens: first x gets evaluated to 1 in the list; then x evaluates to 1 in the replacement rule and you end up with:

 {1,2,3,1} /. 1 -> 4


Hence the result.

There are other functions that do replacements like this (such as Table), except they use a slightly different mechanism and syntax. Table localizes its iterator, which you can spot from the syntax highlighting of i in the following example.

i = 2
Table[i^2, {i, 1, 4}]


So I hope that these examples help you understand the differences between function application and value substitution.

• Your examples made it a lot more clear. Could you summarize in one sentence what can be passed on as "f" and what as "f[x]"? I'm not sure I understand in general, even though you explained this particular case. – TheMountainThatCodes May 24 '18 at 16:13
• You use f whenever you need to pass on a function that gets applied repeatedly to arguments (e.g., Map, Nest, Fold, Select). In these cases you can use pure functions (i.e., Function). You use f[x] to pass on an expression into which x will be substituted with some other value. In this case, pure functions generally don't work. – Sjoerd Smit May 24 '18 at 18:18