0
$\begingroup$

I am getting output as

(-T1**T2**T3)**T4**T5 

How to get rid of the brackets that are appearing in the output?

I want my output as

-T1**T2**T3**T4**T5
$\endgroup$
1
  • $\begingroup$ 1. Please put any code you post in code blocks. Formatting help is automatically displayed for all new users when they edit a post. 2. It is not clear what you are asking. Give a complete example, include your input, explain what you want to achieve in plain terms. Ask a friend to read your question before submitting it. Make sure he understands it. $\endgroup$
    – Szabolcs
    Mar 25 '19 at 10:23
4
$\begingroup$

Non-commutative multiplication is by definition associative but not commutative. The minus sign in your formula, which is a regular multiplication with the number $-1$, blocks the automatic application of the associative property. You can see this by using FullForm:

(-T1 ** T2 ** T3) ** T4 ** T5 // FullForm

NonCommutativeMultiply[Times[-1, NonCommutativeMultiply[T1, T2, T3]], T4, T5]

To circumvent this problem you have to state the allowed transformation rules yourself, for example the associativity with regular multiplication by a number:

(-T1 ** T2 ** T3) ** T4 ** T5 /. (u_?NumericQ a_) ** b_ -> u (a ** b)

-T1 ** T2 ** T3 ** T4 ** T5

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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