I would like to extract the coefficients A,b0,b1,b2 from the following form:

A0 * Exp [b0 + b1*x + b2*x^2]

I am aware that the command Coefficient or CoefficientList would be able to do so for polynomials. Is there a way to do the same for the expression above?


2 Answers 2

forms = {A0*Exp[b0 + b1*x + b2*x^2],
         Exp[b0 + b1*x + b2*x^2],
         asd asdd Exp[b x^2]};

FirstCase[#, Exp[b__] a_. :> {a, CoefficientList[b, x]}, {}, {0}] & /@ forms // Column

{A0, {b0, b1, b2}}
{1, {b0, b1, b2}}
{asd asdd, {0, 0, b}}


Try to use the TreeForm function to visualize and the Part function to get the parameters. For example, here is your expression:

expr = A0*Exp[b0 + b1*x + b2*x^2]

Let us apply the TreeForm to it:


It returns the tree:

enter image description here

From this image you clearly see that the tree coordinate of A0 is {1}, and of, say, b0 is {2,2,1}. Indeed,


(* A0  *)


expr[[2, 2, 1]]

(*  b0  *)

And the same you can apply to any other part of the expression.

Have fun!


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.