0
|
6169 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Finding Coefficients of A Non-polynomial Expression

Posted 11 years ago
 Hi Guys, I am new to Mathematica and I am dealing with symbolic calculations. I am finding trouble finding the coefficient list for non-polynomials. For example, 3x[1]^2+4x[1]x[2]^(-1/2)CoefficientList only applies to polynomials. Any help for non-polynomials?Thanks in advanceArvind Rajan
3 Replies
Sort By:
Posted 11 years ago
 Yes. This can be programmed, but how to program really would depend on how you wanted to use it. In the case that you want to extract all of the numbers at the beginning of each term, you can run:eq = 3 x[1]^2 + 4 x[1] x[2]^(-1/2)(List @@ eq)[[All, 1]]The answer is basically that you will want to become familiar with pattern matching in order to do manipulations with algebra that aren't preprogrammed into Mathematica.
Posted 11 years ago
 Any way I can use {x[1],x[2]}to extract the list of coefficients? Because I know for sure that they are the variables but I might not know their powers. I want to extract the coefficients from user's input expressionThanks
Posted 11 years ago
 You will need to use pattern matching to extract out the parts of the expression you want. The best function for this is Cases. For example:Cases[3 x[1]^2 + 4 x[1] x[2]^(-1/2), cons_ x[1]^2 -> cons]This produces 3 since 3 is result of cons_ x[1]^2 -> cons being matched.