Skip to main content
provided expected output
Source Link
BabaYaga
  • 1.9k
  • 1
  • 11
  • 20
 k2[[1]][[1]] = (a + b)^(-1 - e) 
 k2[[1]][[2]] = (x + y)^(2 + e)
 k2[[1]][[3]] = k

 k2[[2]][[1]] = (a + b)^(-1 - e) 
 k2[[2]][[2]] = (x + y)^(2 + e) 
 k2[[2]][[3]] = -z

EDIT::

The expected final output

 k2={
 {{(a + b),(-1 - e)},{ k },{(x + y),(2 + e)}},
 {{(a + b),(-1 - e)},{-z},{(x + y),(2 + e)}}
    }

or

  k2={
  {{{a , b},{-1, - e}},{ k },{{x , y},{2 , e}}},
  {{{a , b},{-1, - e}},{-z},{{x , y},{2 , e}}}
     }

Such that finally I get each of the two terms ( which are separated by +/-)

  (1.)   (a + b)^(-1 - e) k (x + y)^(2 + e) 
  (2.) - (a + b)^(-1 - e) (x + y)^(2 + e) z

Also from (1.) and (2.) I will get each terms which are multiplied i.e.

  (1.)  (a + b)^(-1 - e),  k,  (x + y)^(2 + e)
  (2.)  (a + b)^(-1 - e), -z, (x + y)^(2 + e)

I find the difficult part is to handle this -ve sign.

 k2[[1]][[1]] = (a + b)^(-1 - e) 
 k2[[1]][[2]] = (x + y)^(2 + e)
 k2[[1]][[3]] = k

 k2[[2]][[1]] = (a + b)^(-1 - e) 
 k2[[2]][[2]] = (x + y)^(2 + e) 
 k2[[2]][[3]] = -z


 
 k2[[1]][[1]] = (a + b)^(-1 - e) 
 k2[[1]][[2]] = (x + y)^(2 + e)
 k2[[1]][[3]] = k

 k2[[2]][[1]] = (a + b)^(-1 - e) 
 k2[[2]][[2]] = (x + y)^(2 + e) 
 k2[[2]][[3]] = -z

EDIT::

The expected final output

 k2={
 {{(a + b),(-1 - e)},{ k },{(x + y),(2 + e)}},
 {{(a + b),(-1 - e)},{-z},{(x + y),(2 + e)}}
    }

or

  k2={
  {{{a , b},{-1, - e}},{ k },{{x , y},{2 , e}}},
  {{{a , b},{-1, - e}},{-z},{{x , y},{2 , e}}}
     }

Such that finally I get each of the two terms ( which are separated by +/-)

  (1.)   (a + b)^(-1 - e) k (x + y)^(2 + e) 
  (2.) - (a + b)^(-1 - e) (x + y)^(2 + e) z

Also from (1.) and (2.) I will get each terms which are multiplied i.e.

  (1.)  (a + b)^(-1 - e),  k,  (x + y)^(2 + e)
  (2.)  (a + b)^(-1 - e), -z, (x + y)^(2 + e)

I find the difficult part is to handle this -ve sign.

Source Link
BabaYaga
  • 1.9k
  • 1
  • 11
  • 20

How to protect the expansion of exponent while applyting rules

I am trying to separate/split an expression (consisting of polynomials) to a list. However I want to keep the exponents intact. Here is an example:

k1=((x+y)^(2+e) (a+b)^(-1-e) (k - z) )//Expand
k2=k1 /. Times | Plus  | Power -> List

output:

(a + b)^(-1 - e) k (x + y)^(2 + e) - (a + b)^(-1 - e) (x + y)^(2 + e) z
{{{{a, b}, {-1, {-1, e}}}, k, {{x, y}, {2, e}}}, {-1, {{a, b}, {-1, {-1, e}}}, {{x, y}, {2, e}}, z}}

The problem in this approach is it makes list in which it is not apparant to distinguish -e and -1+e .

 -e /. Times | Plus | Power -> List
 -1+e /. Times | Plus | Power -> List

leads to same {-1, e}. For each - sign it creates a list which is unwanted.

In this example,

How do I prevent applying Plus -> List to the exponent?

The reason is I want to finally get back to the following form from each term of the list at the end, i.e.

k2[[1]], k2[[2]] etc.

where

 k2[[1]][[1]] = (a + b)^(-1 - e) 
 k2[[1]][[2]] = (x + y)^(2 + e)
 k2[[1]][[3]] = k

 k2[[2]][[1]] = (a + b)^(-1 - e) 
 k2[[2]][[2]] = (x + y)^(2 + e) 
 k2[[2]][[3]] = -z