5
$\begingroup$
 (a1 q1^2 + b1 p1^2 + c1 q1 + d1 p1 + e1) E^(a2 q1^2 + b2 p1^2 + c2 q1 + d2 p1 + e2)

Is there a command to select factor polynomial

(a1 q1^2 + b1 p1^2 + +c1 q1 + d1 p1 + e1)

and exponent of E

(a2 q1^2 + b2 p1^2 + c2 q1 + d2 p1 + e2)

from the top expression?

$\endgroup$
6
$\begingroup$
myEq = (a1 q1^2 + b1 p1^2 + +c1 q1 + d1 p1 + e1) 
        E^(a2 q1^2 + b2 p1^2 + c2 q1 + d2 p1 + e2);

myEq /. a_ E^b_ -> a

and

myEq /. a_ E^b_ -> b
$\endgroup$
6
$\begingroup$

You can use Exponent and Coefficient as follows:

exp = (a1 q1^2 + b1 p1^2 + c1 q1 + d1 p1 + e1) E^(a2 q1^2 + b2 p1^2 + c2 q1 + d2 p1 + e2);

Exponent[exp, E]

e2 + d2 p1 + b2 p1^2 + c2 q1 + a2 q1^2

Coefficient[exp,  E, Exponent[exp, E]]

e1 + d1 p1 + b1 p1^2 + c1 q1 + a1 q1^2

$\endgroup$
1
$\begingroup$

Another way. It works because both of the sub-expressions to be extracted have head Plus and are the only ones to do so.

expr = 
  (a1 q1^2 + b1 p1^2 + c1 q1 + d1 p1 + e1) 
    E^(a2 q1^2 + b2 p1^2 + c2 q1 + d2 p1 + e2);
{expon, factr} = Extract[expr, Delete[-1] /@ Position[expr, Plus]];

factr
e1 + d1 p1 + b1 p1^2 + c1 q1 + a1 q1^2
expon
e2 + d2 p1 + b2 p1^2 + c2 q1 + a2 q1^2
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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