TransWikia.com

How can I separate the coefficients of $x^k$ and $x^k log x$ in a function?

Mathematica Asked on September 29, 2021

I have a function of the following form:

$$f(x) = a_0 + a_1 x + a_2 x^2 + … + b_1 x log x + b_2 x^2 log x + b_3 x^3 log x + …, tag{1}$$

and I would like to collect the coefficient $a_k$ and $b_k$ separately. As an example, when I do e.g. Coefficient[f, x, 1], the output is:

$$a_1 + b_1 log x, tag{2}$$

while I would like the output to be $a_1$ only of course.

One Answer

You can use Coefficient twice. First Coefficient[f, x, 1] to get the coefficients of x^1 and then you can collect the coefficients of Log[x] to separate the two terms:

f = a + b x + c x Log[x];
Coefficient[Coefficient[f, x, 1], Log[x], {0, 1}]

{b, c}

Correct answer by Sjoerd Smit on September 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP