1
$\begingroup$

I have a polynomial of variables $x,y$, where $|x|<1$ and $|y|<1$. When I apply the Simplify function to this expression, I get an expression of the form

$(x-1) (y-1)^3 y + x^n (x-a)^5 (y-b)^7 + ..$, where $|a| \geq 1$ and $|b| \geq 1$.

Contrary, I want Mathematica to give me an expression of the form $(1-x) (1-y)^3 y+ x^n (a-x)^5(y-b)^7 + ...$

That is, I want in the simplified expression $(a-x^n)$ instead of $(x^n-a)$ and $(b-y^n)$ instead of $(y^n-b)$, if $a$, $b$ and $n$ are greater than or equal to $1$. Is there a way to do this by aiding a parameter/ an option to the Simplify or FullSimplify function? If not, is there any easy way to do it? I tried doing it with the replacement rule {(x + a_?NumericQ) :> (-(-a - x))}, but could not get the desired result.

Edit: Here is the Mathematica code for the expression I want to rewrite

(x - 1) (y - 1)^3 y + x^3 (x - 1)^5 (y - 2)^7 + x^3 (x^2 - 3) (y^3 - 3 )

and here is the desired result

(1 - x) (1 - y)^3 y + x^3 (1 - x)^5 (2 - y)^7 + x^3 (3 - x^2) (3 - y^3).
$\endgroup$
2
  • 1
    $\begingroup$ Please upload Mathematica code for the expression. Thanks. $\endgroup$
    – Syed
    Commented Dec 11, 2023 at 10:05
  • 2
    $\begingroup$ Mathematical uses its own way to order terms. It needs this order to work. When you need to look at the result in the habitual form for whatever reason, you can apply TraditionalForm to it. For example, have a look at (x - 1) (y - 1)^3 y // TraditionalForm. $\endgroup$ Commented Dec 11, 2023 at 10:44

1 Answer 1

2
$\begingroup$
Clear["Global`*"];
expr = (x - 1) (y - 1)^3 y + x^3 (x - 1)^5 (y - 2)^7 + 
  x^3 (x^2 - 3) (y^3 - 3)

enter image description here

Replace[expr, (Plus[a_?Negative, b_])^c_. :> 
   g^c (Abs@a - b) , {1, ∞}] /. {g^x_?EvenQ :> 1, 
  g^x_?OddQ :> -1}

enter image description here

$\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.