# Evaluate differentiation after replacement

The problem is

Find two linearly independent solutions of $2x^2y'' -xy' + (-4 x + 1)y = 0, \, x>0$ of the form $y_1 = x^{r_1}(1 + a_1 x + a_2 x^2 + a_3 x^3 + \cdots)$ and $y_2 = x^{r_2}(1 + b_1 x + b_2 x^2 + b_3 x^3 + \cdots)$.

What I have done is below:

2 x^2*D[y, {x, 2}] - x D[y, x] + (-4 x + 1) y == 0 /. y -> x^r*(Sum[C[n]*x^n, {n, 0, 5}])


The result mathematica gave is

(1 - 4 x) x^r (C + x C + x^2 C + x^3 C + x^4 C + x^5 C) == 0


from which I conclude that D[y,x]is excuted before the replacement. How can I make D[y,x] excute after the replacement?

• With[{y=replacement},D[y,x]] – Coolwater Apr 27 '14 at 9:03

One method I like to use for this is the Hold/Release, like this (notice the use of D for derivative in the Hold stage.

  ClearAll[x, y, n];
eq = 2 x^2  Hold[D[y[x], {x, 2}]] - x Hold[D[y[x], x]] + (-4 x + 1) y[x] == 0;
Release[eq /. y[x] -> x^r*(Sum[C[n]*x^n, {n, 0, 5}])] solns = y[x] /. First@DSolve[2 x^2*D[y[x], {x, 2}] - x D[y[x], x] + (-4 x + 1) y[x]== 0, y[x], x]
y1[x_] = solns /. {C -> 1, C -> 0}
y2[x_] = solns /. {C -> 0, C -> 1}
(*  E^(2 Sqrt Sqrt[x]) Sqrt[x]  *)
(* -((E^(-2 Sqrt Sqrt[x]) Sqrt[x])/(2 Sqrt))  *)