Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to define some basic functions known from "discrete analysis":

$$I(f)(x):=f(x)$$ $$E(f)(x):=f(x+1)$$ $$\Delta(f)(x) := (E-I)(f)(x) = f(x+1)-f(x)$$ $$\nabla(f)(x) := (I-E^{-1})(f)(x) = f(x)-f(x-1)$$

And I know that I can define a function f[x_] := x^2 like that, but how can I take a function and evaluate it at the given position like E[fn_] := evaluate fn at x+1?

share|cite|improve this question
up vote 0 down vote accepted

You can use the Apply command to make a definition such as Eval[f_,x_]:= Apply[f,{x}] (you can't use E as the name of your function, though - this is reserved by Mathematica for the number $e=2.71828\ldots$).

For example:

Eval[f_,x_]:= Apply[f,{x}]


Then you can define

share|cite|improve this answer
It does not work like expected! E.g. $E(f)(x)$ is now called TranslateEx. TranslateEx[fn_] := Apply[fn, {x + 1}] and then TranslateEx[x] leads to the result x[1 + x]. What does this mean? I expected x + 1 as the result. EDIT It seems i cannot enter a function directly and i need to specify it explicitly... – Christian Ivicevic Oct 8 '11 at 23:52
@Christian: x by itself is not a function. You need to define a function g[x_]:=x, and then you can do TranslateEx[g]=1+x. – Zev Chonoles Oct 8 '11 at 23:56
Is there any way, like in programming languages, to define an "anonymous function" (a.k.a. lambda-expression) the way i tried? – Christian Ivicevic Oct 8 '11 at 23:57
You might be able to do it with the Function command, but I'm not familiar with it myself. – Zev Chonoles Oct 9 '11 at 0:00
eval[k_][f_]:=f[k] – Gus Wiseman Oct 9 '11 at 0:08

Actually, for Mathematica 7 and later versions, you have the functions Identity[], DiscreteShift[], and DifferenceDelta[]:


DiscreteShift[f[x], x]
f[1 + x]

DifferenceDelta[f[x], x]
-f[x] + f[1 + x]

The backward difference needs a bit more work:

DifferenceDelta[DiscreteShift[f[x], {x, 1, -1}], x]
-f[-1 + x] + f[x]


bdf[f_, x_] := f - (f /. x -> x - 1)

bdf[f[x], x]
-f[-1 + x] + f[x]

In fact, Mathematica supports more traditional notation (see the manual for details):

shifts and differences

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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