I have some expressions of the type
$f(x) \,+\, g(x) \,\log(x) \,+\, h(x) \,\log(1-x^2)$
where $f$, $g$, and $h$ can be any rational functions of $x$. I am trying to use Mathematica to extract each function separately, given the expression.
I cannot simply use
Coefficient[expr, Log[x]] (* g *)
Coefficient[expr, Log[1-x^2]] (* h *)
because the expression is not necessarily written in the nice form I gave above. Sometimes Mathematica prefers to write it using Log[x^2]
, or to decompose Log[1-x^2]
into Log[1-x] + Log[1+x]
and then separate the logs... For some expressions I have even seen ArcTanh[x]
.
I have tried to use FullSimplify
with a custom ComplexityFunction
to force Mathematica to write the expression in the form I want, but it does not always work, and some of my expression are so long that I can't use FullSimplify
on them.
I don't see how I could use anything related to the asymptotics or series expansions either, because the functions $f, g$ or $h$ can have poles or zeros at $x=0$ or $1$.
Is there a way to do what I want ? I should say that what I really care about is to obtain equations equivalent to g[x] == 0
and h[x] == 0
. If there is a way to do that without getting $g$ and $h$ that is fine as well.
Thanks.
Coefficient
doesn't work? That way, we can actually test out various solutions. $\endgroup$1 + (3+n) Log[1-x] + (3+n) Log[1-x]
. Mathematica will not rewrite it in the form I want, even after FullSimplify. In this case I simply need the equation n = -3. I did not provide the example because I have a lot of different forms, sometimes involving ArcTanh as I said, and I don't want to make separate cases for each. $\endgroup$1 + (3+n) Log[1-x] + (3+n) Log[1+x]
(with a +). I can no longer edit my previous comment. See also my comment on the answer below for another kind of example, for whichCoefficient
would actually work. $\endgroup$