How to represent $f(x) = (y-x)^k \log(y-x)$ as a summation of the form $f(x) = \sum\limits_{j=0}^\infty \cdots$?
Complete rewrite of answer
The expression to be expanded as a series is the argument of
ser = Series[(y - x)^k*Log[y - x], {x, 0, 5}]
I attempted to obtain the result in an earlier version of this answer by means of SeriesCoefficient
but obtain an incorrect result, because I failed specify that k
is a nonnegative integer. The answer provided by Carl Woll in a comment below, which does specify k
as a nonnegative integer, involves a DifferenceRoot
that does not evaluate for n > 1
. Here is a workaround. The Log
and Power
terms of the expression can be expanded separately and then combined as follows.
sc1 = SeriesCoefficient[(y - x)^k, {x, 0, n1}]
(* Piecewise[{{(-1)^n1*y^(k - n1)*Binomial[k, n1], n1 >= 0}}, 0] *)
sc2 = SeriesCoefficient[Log[y - x], {x, 0, n2}]
(* Piecewise[{{(-1)^(1 + n2)/(n2*(-y)^n2), n2 >= 1}, {Log[y], n2 == 0}}, 0] *)
The corresponding series coefficient of the product then is
c[n_] := Sum[sc1 sc2 /. n2 -> n - n1, {n1, 0, n}]
and Sum
for the original expression is
Sum[c[n] x^n, {n, 0, Infinity}]
To test the validity of this expression, compare it with ser
.
Simplify[Sum[c[n] x^n, {n, 0, 5}] == ser // Normal]
(* True *)
Note that Sum
will try to recover the original expression, so it may be necessary to use Inactivate
to prevent this, depending on how the Sum
is to be used. (My thanks to MaTECmatica for suggesting that Inactivate
is superior to Hold
in this instance.)
Addendum
The Sum
in the formula for c
can be performed symbolically, although the result is complicated.
innersum = FullSimplify[c[n], k >= 0 && k ∈ Integers && n >= 0 && n ∈ Integers];
innersum[[1, 1, 1]] = Simplify[innersum[[1, 1, 1]] /. n -> 0];
innersum[[1, 1, 2]] = n == 0; innersum
(* Piecewise[{{y^k*Log[y], n == 0}, {-(y^(-1 + k)*(1 + k*Log[y])), n == 1}},
((-1)^n*y^(-1 + k - n)*((1 + k - n)*y*Binomial[k, -1 + n]*(HarmonicNumber[k] -
HarmonicNumber[k - n]) + n*(y*Binomial[k, n]*Hypergeometric2F1[1, -k + n, 1 + n, y^(-1)]
+ Binomial[k, 1 + n]*Hypergeometric2F1[1, 1 - k + n, 2 + n, y^(-1)])*Log[y]))/n] *)
The second and third lines of code perform further simplification for n == 0
.
You can use a old trick: $$\frac{\partial (y-x)^{t+k}}{\partial t}\text{/.}\, t\to 0=(-x+y)^k \log (-x+y)$$
The corresponding series coefficient is:
sc = SeriesCoefficient[(y - x)^(t + k), {x, 0, n}]
(* Piecewise[{{(-1)^n*y^(k - n + t)*Binomial[k + t, n], n >= 0}}, 0]*)
Compute derivative respect to t
and t=0
:
FullSimplify[(D[sc[[1, 1, 1]], t] /. t -> 0), Assumptions ->
n >= 0 && n \[Element] Integers && k >= 0 && k \[Element] Integers]
(* (-1)^n y^(k - n)Binomial[k, n] (HarmonicNumber[k] - HarmonicNumber[k - n] + Log[y]) *)
c[n_] := (-1)^n y^(k - n)*Binomial[k, n] (HarmonicNumber[k] - HarmonicNumber[k - n] + Log[y])
Series coefficient is simpler as previously presented by bbgodfrey.
and Sum
for the expression is:
Sum[c[n] x^n, {n, 0, Infinity}]
$$\sum _{n=0}^{\infty } (-1)^n x^n y^{k-n} \binom{k}{n} \left(H_k-H_{k-n}+\log (y)\right)$$
To test the validity of this expression, compare it for k=1
:
Series[(y - x)^k*Log[y - x] /. k -> 1, {x, 0, 5}] // Normal // Expand
$-x+\frac{x^5}{20 y^4}+\frac{x^4}{12 y^3}+\frac{x^3}{6 y^2}+\frac{x^2}{2 y}-x \log (y)+y \log (y)$
Sum[Limit[c[n]*x^n, k -> 1], {n, 0, 5}] // FullSimplify // Expand
$-x+\frac{x^5}{20 y^4}+\frac{x^4}{12 y^3}+\frac{x^3}{6 y^2}+\frac{x^2}{2 y}-x \log (y)+y \log (y)$
(* True *)