# Why $u\cdot \operatorname{grad}(u)$ is not equal to $\operatorname{div}(u u)$?

The Navier-Stokes equation contains term

$\vec{u} \cdot \nabla \vec{u}$

which should be equal to

$\nabla \cdot \left(\vec{u}\vec{u} \right)$

provided

$\nabla \cdot \vec{u}=0$.

However this computation gives me different results for these two

In[70]:= u = {2*x^2*(x-1)^2*y*(2*y-1)*(y-1), -2*x*(x-1)*(2x-1)*y^2*(y-1)^2}
Out[70]= {2 (-1+x)^2 x^2 (-1+y) y (-1+2 y),-2 (-1+x) x (-1+2 x) (-1+y)^2 y^2}
In[72]:= div = Div[u, {x, y}, "Cartesian"] // Simplify
Out[72]= 0
Out[73]= {4 (-1+x) x (-1+2 x) (-1+y)^2 y^2 (2 (-1+x)^2 x^2 (1-2 y)^2+(1-6 x+6 x^2) (-1+y)^2 y^2),4 (-1+x)^2 x^2 (-1+y) y (-1+2 y) (2 (1-2 x)^2 (-1+y)^2 y^2+(-1+x)^2 x^2 (1-6 y+6 y^2))}
In[74]:= adv2=Div[TensorProduct[u,u], {x, y}, "Cartesian"] //Simplify
Out[74]= {4 (-1+x)^3 x^3 (-1+2 x) (-1+y)^2 y^2 (1-2 y+2 y^2),4 (-1+x)^2 x^2 (1-2 x+2 x^2) (-1+y)^3 y^3 (-1+2 y)}
Out[75]= {4 (-1+x) x (-1+2 x) (-1+y)^2 y^2 (2 (-1+x)^2 x^2 (1-2 y)^2+(1-6 x+6 x^2) (-1+y)^2 y^2-(-1+x)^2 x^2 (1-2 y+2 y^2)),4 (-1+x)^2 x^2 (-1+y) y (-1+2 y) (2 (1-2 x)^2 (-1+y)^2 y^2-(1-2 x+2 x^2) (-1+y)^2 y^2+(-1+x)^2 x^2 (1-6 y+6 y^2))}


I would expect the difference of the two to be 0. Why is that?

• Is the output of TensorProduct[{x, y, z}, {x, y, z}] what you were expecting it to be? Oct 26, 2017 at 13:24
• Indeed, it seems to be. It agrees with the numerical computation. Oct 26, 2017 at 13:33

I've previously found that Mathematica's arrangement of Grad's output doesn't always agree with fluid mechanics conventions: try transposing it. In general for three dimensions:

u={ux[x,y,z],uy[x,y,z],uz[x,y,z]};
uu=TensorProduct[u,u];
divu=Div[u,{x,y,z}];

FullSimplify[u.gradu - Div[uu,{x,y,z}], divu == 0]


This will return {0,0,0}, as expected.

And in two dimensions, as in the question:

u = {ux[x, y], uy[x, y]};

For all $\vec{u}$ where $\nabla\cdot \vec{u}=0$.