answered 2 years ago
You may use symbolic variables and interpret the * operator as the inner poduct:
*
sage: u,v,r = var("u v r") sage: (u*(v+r*u)).expand() r*u^2 + u*v