# Issue with Differentiation over a tensor

I am new user in Mathematica. I am working with liquid crystal theory, and one of the notation there is the tensor:

$\Pi_{ij} = \frac {\partial {F_{el}}} { \partial ( \partial {n_i} / \partial { x_j})}$

Where numerator is scalar, denominator is tensor (matrix).

In order to calculate it in Mathematica, I introduce:

r={x,y,z}
nd[x_, y_, z_] = {n1[x, y], n2[x, y], 0}
Fel = ***Some expression (nd) ***
g = D[nd[x, y, z], {r}]


After that I need to take a derivative of Fel over a tensor g. But as long as I am restricted to a 2D space {x,y}, my tensor g looks like:

g= (n1^(1,0)(x,y)   n1^(0,1)(x,y)   0
n2^(1,0)(x,y)   n2^(0,1)(x,y)   0
0               0               0)


It is not allowed to differentiate over zero. Mathematically, zero values must be omitted (the corresponding term must be set to zero).

Thanks,

## 1 Answer

In five days no one gave an answer, so I will post what I developed, although it is a poor solution:

You can fill zeros of the tensor with variables that are not used, like z1,z2,z3,.... Now the derivative over this variables is zero, so I got desired result