# Derivative of a function in undefined dimension

I have a scalar function defined on a $$n$$-dimensional manifold: $$f(x_1, x_2, ..., x_n)$$, where $$n$$ is undefined, and $$x_i$$ are the coordinates. How to define something like "$$∂_af∂^af$$"?

(I'm solving the Einstein equation for a black brane in the large-N limit, where N is the dimension of the brane, so I should keep N in my expression instead of setting N as something like 5)

I've tried:

In[10]:=f/:D[f[i_],x[j_]]=f[i+x[j]]
In[11]:=D[f[0],x[5]]
Out[11]:=f[x[5]]


That's OK but then

In[13]:=D[-f[0],x[5]]
Out[13]:=0


It doesn't work now:(

Edit:

My current solution is just

SetOptions[D, NonConstants -> {f}]


It almost perfectly solved my problem despite the complicated output. I'm not trying to simplify the output.

• What is a, then? Commented Dec 21, 2018 at 12:31
• Commented Dec 21, 2018 at 12:58
• Yes, mathematica.stackexchange.com/q/41907/7936 seems to solve the problem. Commented Dec 21, 2018 at 14:22

 x /: D[c_. f[i_], x[j_]] = c f[i + x[j]]