1
$\begingroup$

My particular problem is to find a way how to manipulate a term so that it is not multiplied into a vector (as being a list or matrix, and potentially being displayed in MatrixForm) for as long as I want. For example,

$ term \; \{{1},{2},{3}\} $

shall not be simplified automatically to

$ \{{term},{2 \; term},{3 \; term}\} $.

But the question is more general: How can I exclude a term in an expression from any computation, from participating in any simplification, while all other simplifications, not involving term, shall take place as usual?

I can't find a functionality in Mathematica allowing this. So in particular, I can't find a way to keep a factor in front of a vector. I tried Framed, Inactive, Inactivate, Defer, HoldForm, etc. All this doesn't help, as far as I can see. Defering the vector itself as in the answer of Mr.Wizard to question 125577 does not help either, because e.g. it inhibits MatrixForm display of the vector. Furthermore, it does not solve the general problem of how to inactivate a term with respect to any simplification.

I could imagine that any of the Box functions (FormBox, TagBox, etc.) could do the job of paralyzing the term, but so far I haven't found a way.

So far the best partial solution I found is to wrap both term and the vector separately in TraditionalForm. Wrapping term prevents it from some/most(?) operations while wrapping the vector inhibits term being multiplied into it. Display in MatrixForm remains possible. The drawback is that all other simplifications with vector are inhibited as well, e.g. multiplying some other, unprotected term into it. So this solution is not quite satisfactory yet.

I wonder why Mathematica apparently does not provide a clean and easy way to achieve this functionality. Keeping a factor temporarily outside of a vector, matrix etc. seems to me to have obvious benefits.

$\endgroup$

1 Answer 1

1
$\begingroup$

I find that it in Mathematica it is better to introduce new objects than to attempt to redefine existing ones.

For example, you could use list rather than List as the head of your expression. You can then increase the functionality of list to meet your needs.

For example, you can make them appear as ordinary Lists

Format[a__list] := List @@ a

list[b, c, d]
(* {b, c, d} *)

7 list[b, c, d]
(* 7 {b, c, d} *)

You can add a definition for a dot product

Dot[a__list, b__list] ^:= (List @@ a).(List @@ b)

list[1, 2, 3] . list[4, 5, 6]
(* 32 *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.