I try to get result
diff(innerproduct(x,x),x) = 2x
using itensor
The following definition works
---------------
(%i1) load(itensor)$
(%i2) coord(x)$
(%i6) imetric(g)$
(%i9) declare(g,constant)$
(%i10) ishow(idiff( x([],[j])*g([i,j],[])*x([],[i]), k))$
i j j i
(%t10) x g kdelta + x g kdelta
i j k i j k
(%o10) x([], [i]) g([i, j], []) kdelta([k], [j])
+ x([], [j]) g([i, j], []) kdelta([k], [i])
(%i11) ishow(contract(%));
(%t11) 2 x
k
(%o11) 2 x([k], [])
---------------
But,
---------------
(%i12) ishow(idiff( x([i])|x,k));
(%i13) ishow(contract(%));
%1
(%t13) x + x x
k %1,k
(%o13) x([k], []) + x([], [%1]) x([%1], [], k)
---------------
And
----------------
(%i14) components(x([j],[]),g([i,j],[])*x([],[i]));
(%i15) ishow(idiff( x([i],[])*x([],[i]), k));
(%i17) ishow(contract(rename(expand(%))));
%2
(%t17) 2 x g
%2 k
(%o17) 2 x([], [%2]) g([%2, k], [])
---------------
2x^i g_{ik} maybe also collect, but not equal 1st result.
I think this is not right way dealing inner-product.
But I can not find appropriate example in demo(tensor) and manual.