Skip to main content
9 votes

How to extract coefficients and powers from expressions with non integer powers?

Clear["Global`*"]; expr = 3 - 2 x + 7 x^2.1 + x^2.4 - 5 x^3; Transpose[{Exponent[#, x], # /. x -> 1}] & /@ List @@ expr {{0, 3}, {1, -2}, {2.1, 7....
Syed's user avatar
  • 55.7k
7 votes

How to extract coefficients and powers from expressions with non integer powers?

ce = Apply[List/*Map[List]/*ReplaceAll[a_. x^b_. :> Splice @ {b, a}]/*PadLeft]; ce[3 - 2 x + 7 x^2.1 + x^2.4 - 5 x^3] ...
kglr's user avatar
  • 398k
7 votes

How to extract coefficients and powers from expressions with non integer powers?

You may use pattern matching to achieve what you want: ...
Daniel Huber's user avatar
  • 53.1k
6 votes

How to extract coefficients and powers from expressions with non integer powers?

coefList = List @@ # /. #2 -> 1 &; expList = Exponent[##, List] &; expCoefList = Transpose @* Through @* {expList, coefList} Examples: ...
kglr's user avatar
  • 398k
5 votes

How to extract coefficients and powers from expressions with non integer powers?

Using Cases: ...
E. Chan-López's user avatar
5 votes

How to extract coefficients and powers from expressions with non integer powers?

? Maybe: MapAt[Total@*(Exponent[#,x]&/@Variables[expr] #&),1]/@List@@@CoefficientRules[expr] (* {{3.,-5.},{1.,-2.},{2.1,7.},{2.4,1.},{0.,3.}} *)
user1066's user avatar
  • 20.2k
5 votes

How to extract coefficients and powers from expressions with non integer powers?

I'd expand the exponents until they are integers: ...
Roman's user avatar
  • 48.3k
5 votes

Creating a list of functions with desired coefficients

Instead of using Subscript[x, 1], I suggest using x[1]. You can still use Format to display ...
Domen's user avatar
  • 27.3k
4 votes

How to extract coefficients and powers from expressions with non integer powers?

expr = 3 - 2 x + 7 x^2.1 + x^2.4 - 5 x^3; Using ReplaceAll ...
eldo's user avatar
  • 78.2k
4 votes

How to extract coefficients and powers from expressions with non integer powers?

Direct pattern-matching solution: expr = 3 - 2 x + 7 x^2.1 + x^2.4 - 5 x^3; List@@expr /. {a_. x^b_. :> {b, a}, c_?NumberQ :> {0, c}}
TheDoctor's user avatar
  • 2,870
4 votes
Accepted

Getting coefficients list of a series expansion at a point different from 0

One way is to do the following: expand to whatever order you want, and subsequently substitute $x-1$ by $y$. Do CoefficientList in the ...
bmf's user avatar
  • 16.2k
4 votes
Accepted

How can I extract a matrix and vectors of coefficients from this quadratic expression?

The function you are looking for is "CoefficientArrays". E.g. for your polynomial: var = {x, y, z}; poly = (x - y + a)^2 + (x - z + b)^2; we get the ...
Daniel Huber's user avatar
  • 53.1k
3 votes

Extracting the constant term

expr = 1/4 (-1 - Subscript[φ, 49, 50] - Subscript[φ, 50, 49]) + Subscript[φ, 50, 50]]; Two positional solutions For subscripted variables ...
eldo's user avatar
  • 78.2k
2 votes
Accepted

Comparing two power series and extracting their coefficients

In sum2, the powers of x and y are less than or equal to 6, whereas in ...
march's user avatar
  • 23.9k
2 votes
Accepted

Extracting coefficients from a list of expressions

Here's an automated solution that detects the relevant variables in the expression: ...
march's user avatar
  • 23.9k
2 votes

Neglecting coefficients of a given list

Using CoefficientRules and FromCoefficientRules: ...
E. Chan-López's user avatar
2 votes

Neglecting coefficients of a given list

Clear["Global`*"]; exp1 = a1*a2*24 + a1*a2*a3*kk*25 + a1*a2^2 + a1*a2*a3*34; DeleteCases[List @@ exp1, _?NumericQ | kk, {2}] {a1 a2, a1 a2^2, a1 a2 a3, ...
Syed's user avatar
  • 55.7k
1 vote

Differential behaviour of FreeQ function depending on the number of terms in a sum

I think these produce the desired output: ...
Michael E2's user avatar
  • 238k
1 vote

Extracting matrix coefficients from multivariate matrices

Not sure why you're using C array indices (start at zero) instead of Mma indices (start at one), nor why you ignore one of the matrix entries in the output. If that's not what you're doing, then I've ...
Michael E2's user avatar
  • 238k
1 vote
Accepted

How can I find coefficients of quadratic and cubic terms?

We can use a trick here: Instead of writing just r[t_, l_] = rb[l] + 𝜁[t, l]*nr[l]; x1[t_, l_] = xb[l] + 𝜁[t, l]*nx[l]; I used ...
justJasper's user avatar
1 vote

Inversion in Fourier coefficients estimation problems

This is pretty easy. Note, I am using indexed variables instead of subscripts because these give less problems than subscripted variables: For an example I use n=2, m=3. We first create the matrices ...
Daniel Huber's user avatar
  • 53.1k

Only top scored, non community-wiki answers of a minimum length are eligible