4
$\begingroup$

I'm looking to factor out the parts of a multiplication type of expression. For example for the expression:

$$20 e^{-t^2}\frac{t^2}{\sqrt{t^2+a}} erf(b+t)$$

I'd like to get a list in the form of: $$\left\{ 20, \left\{t^2,\frac{1}{\sqrt{t^2+a}}, e^{-t^2}, erf(b+t) \right\} \right\}$$

Where only t is defined as a variable.

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – bbgodfrey May 7 '15 at 19:39
5
$\begingroup$

Given

expression = (20*t^2*Erf[b + t])/(E^t^2*Sqrt[a + t^2])

enter image description here

can be achieved via replacement of the Head

List @@ expression

enter image description here

To find constant factors:

GatherBy[List @@ expression, NumberQ]

enter image description here

It is so because Times here is single Head for all first-level factors:

TreeForm[expression]

enter image description here

This also can prove to be useful:

FactorList[expression]

enter image description here

$\endgroup$
  • $\begingroup$ Okay, how do I group all the constants that do not depend on t into a single expression? $\endgroup$ – user1581390 May 7 '15 at 19:53
  • $\begingroup$ @user1581390 Do you mean go back? Not sure I understand. $\endgroup$ – Vitaliy Kaurov May 7 '15 at 19:54
  • $\begingroup$ I mean if the expression was $4 a b t$ I'd like to single out the constant part, in this case $4 a b$, because a and b do not depend on t. $\endgroup$ – user1581390 May 7 '15 at 19:59
  • $\begingroup$ @user1581390 I added an example above. $\endgroup$ – Vitaliy Kaurov May 7 '15 at 20:34

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.