I am trying to use Mathematica to simplify a symbolic expression involving Sum
. The expression is defined as follows:
y = (x - x0)^α Sum[a[n] (x - x0)^n, {n, 0, Infinity}]
I am trying to use FullySimplify
on the derivative of the expression with respect to x
via
FullSimplify[D[y, x]]
This yields $$(x-\text{x0})^{\alpha -1} \left(\alpha \sum _{n=0}^{\infty } a(n) (x-\text{x0})^n+(x-\text{x0}) \sum _{n=0}^{\infty } n a(n) (x-\text{x0})^{n-1}\right)$$ However, the expression above can be easily simplified further to $$(x-\text{x0})^{\alpha -1} \sum _{n=0}^{\infty } ( a(n) (x-\text{x0})^n(\alpha+n) ) $$
Is there a way to "make" Mathematica recognise this simplification? I presume the problem has something to do with the fact that I use the unknown function a[n]
in the expression, but I am not sure what can I do about it to get similar functionality.
I am new to Mathematica and would like to apologise if this is a trivial question.
Answer
In our case a simple and direct approach would be defining a list of rules. Here is an example:
rules =
{ c_ Sum[n a[n] c_^(n-1), {n, 0, Infinity}] :> Sum[n c^n a[n], {n, 0, Infinity}],
α_ Sum[a[n] c_^n, {n, 0, Infinity}] + Sum[n a[n] c_^n, {n, 0, Infinity}] :>
Sum[(α + n) a[n] c^n, {n, 0, Infinity}]};
Let's define an appropriate function for TransformationFunctions
applying rules to an expression:
tf[expr_] := expr /. rules
and now FullSimplify
with tf
does the expected transformation:
FullSimplify[ D[y, x], TransformationFunctions -> {Automatic, tf}]//TraditionalForm
alternatively one can do this:
FullSimplify[ D[y, x]] //. rules
Note: Applying rules
in TransformationFunctions
it was quite sufficient to play with ReplaceAll
(/.
) while in the latter case we had to use rules
repeatedly i.e. with ReplaceRepeated
(//.
) .
Comments
Post a Comment