0
$\begingroup$

enter image description here

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.

enter image description here

$\endgroup$
3
  • 5
    $\begingroup$ Please include Mathematica code in addition to the images. Thanks. $\endgroup$
    – Syed
    Commented Nov 24, 2023 at 3:19
  • $\begingroup$ 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 use TraditionalForm 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$
    – Bill
    Commented Nov 24, 2023 at 4:07
  • $\begingroup$ You can change how an expression is presented by using the ComplexityFunction and Simplify. However, for the ordering of symbols, I don’t believe that you can change that. If I need the equation elsewhere, sometimes I’ll use the TeXForm and make my own adjustments. $\endgroup$ Commented Nov 24, 2023 at 7:14

1 Answer 1

1
$\begingroup$

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}

enter image description here

expr2 /.  {x : (-1 + __) :> -x} 

enter image description here

This also works with TraditionalForm, but TraditionalForm puts the "1" at the end like:

expr /. {x : (-1 + __) -> -x} // TraditionalForm

enter image description here

expr2 /.  {x : (-1 + __) :> -x} // TraditionalForm

enter image description here

$\endgroup$

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