- #1
- 32
- 0
Homework Statement
I'm trying to solve this DE: 4xy''+2y'+(cosx)y=0 using a series solution.
nmax = 50;
Remove[a, b]
myalist = Sum[Subscript[a, n]*(4*n^2 - 2*n)*x^(n - 1), {n, 0, nmax}] + Sum[((-1)^k/(2*k)!)*Subscript[a, n - k]*x^(n + k),
{n, 0, nmax}, {k, 0, n}];
Subscript[a, 0] = 1;
myatable = Table[Subscript[a, n + 1] = First[Subscript[a, n + 1] /. N[Solve[Coefficient[myalist, x, n] == 0,
Subscript[a, n + 1]]]], {n, 0, nmax - 1}];
myatable = Prepend[myatable, 1];
f1[x_] := c1*Sum[Subscript[a, n]*x^n, {n, 0, nmax - 1}]
they[x_] := f1[x] + f2[x]
thec = NSolve[{they[1] == 0, they'[1] == 1}, {c1, c2}] // First
pa = Plot[they[x] /. thec, {x, 1, 2}]
I honestly don't know how to do it another way... Could you perhaps give me a general idea of the method you are using to get the coefficients?