How to force Mathematica to output an expression such as
$a1u1+a2u2+a3u3$
as a Dot
product like this one:
{a1,a2,a3}.{u1,u2,u3}
or A.U
How to force Mathematica to output an expression such as
$a1u1+a2u2+a3u3$
as a Dot
product like this one:
{a1,a2,a3}.{u1,u2,u3}
or A.U
I'm going to answer this in the spirit of the question, making a few reasonable assumptions:
Orderless
attribute of Times
(in other words, don't try this for something like $\mathbf{a}=\{b, p, z\}$ and $\mathbf{u}=\{e,g,l\}$).With the above, the following is a very simple way to achieve the output with a few replacements:
expr = a1 u1 + a2 u2 + a3 u3;
expr /. Times -> List /. List -> CenterDot /. Plus -> List
(* {a1, a2, a3}·{u1, u2, u3} *)
% /. ...
to see what it is they're doing. (+1, btw ... and enough with the edits!)
$\endgroup$
a1 + a2
to, say, a4
and then use the above. In the end, change a4
back to a1 + a2
$\endgroup$
How about
expr = a1 u1 + a2 u2 + a3 u3;
HoldForm[#1.#2] & @@ Transpose[Apply[List, expr, {0, 1}]]
(* {a1,a2,a3}.{u1,u2,u3} *)