In most cases, my expressions are quite complex, like the following expr and expr2. How can I make them look better, for instance, I want to use expressions like 1-q or 1-c-q and so on.
1 Answer
$\begingroup$
$\endgroup$
With
expr = (-2 q + (-1 + c + q) a)^2/(9 q a);
expr2 = 1/36 (-(a (5 q + 4) (c + q - 1)^2)/(((q - 1) q)) + 4 q/a);
You may first try pattern matching and StandardForm:
expr /. {x : (-1 + __) -> -x}
expr2 /. {x : (-1 + __) :> -x}
This also works with TraditionalForm, but TraditionalForm puts the "1" at the end like:
expr /. {x : (-1 + __) -> -x} // TraditionalForm
expr2 /. {x : (-1 + __) :> -x} // TraditionalForm
TraditionalForm
moves variables first and constants last, which is the traditional way math people write expressions. You don't want it to do that. So do not useTraditionalForm
and without that you seem to get some or maybe most of what you want. But I think you will not like that result either. Maybe find different math software that does EXACTLY and ONLY what you want and you may be much happier and much more productive. $\endgroup$