I have two expressions (with dot and non-commutative product):
$f=J^T.x+J.x$
$g=J^T**x+J**x$
I want to simplify them and get the following expressions:
$f=(J^T+J).x$
$g=(J^T+J)**x$
In an attempt to solve this problem, I used some tricks from: Symbolic Tensors
$Assumptions = {x \[Element] Arrays[{3, 1}, Reals], J \[Element] Matrices[{3, 3}, Reals]}; expr = Transpose[J].x + J.x // TensorReduce But the expression doesn't change. What needs to be done so that Mathematica can simplify expressions with scalar and non-commutative products?
Some EDIT:
Clear["Derivative"]; ClearAll["Global`*"]; Unprotect[Dot, Plus]; (*Dot rules*) Dot[A_, x_] + Dot[B_, x_] := Dot[A + B, x]; Protect[Dot, Plus]; (***) J.x + Transpose[J].x // TraditionalForm; Clear["Derivative"]; ClearAll["Global`*"]; Unprotect[NonCommutativeMultiply, Plus]; (*NonCommutativeMultiply rules*) NonCommutativeMultiply[A_, x_] + NonCommutativeMultiply[B_, x_] := NonCommutativeMultiply[A + B, x]; Protect[NonCommutativeMultiply, Plus]; (***) J ** x + Transpose[J] ** x // TraditionalForm;