2
$\begingroup$

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?

$\endgroup$
2
$\begingroup$
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}}

$\endgroup$
3
$\begingroup$

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:

TreeForm[expr]

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,

expr[[1]]

(* A0  *)

and

expr[[2, 2, 1]]

(*  b0  *)

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

Have fun!

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