0

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

  • 5
    Please include Mathematica code in addition to the images. Thanks. – Syed Nov 24 '23 at 03:19
  • 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. – Bill Nov 24 '23 at 04:07
  • 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. – Craig Carter Nov 24 '23 at 07:14

1 Answers1

1

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

Daniel Huber
  • 51,463
  • 1
  • 23
  • 57