%% Commands for Series Solutions Chapter
%% 12.1 Series Solutions
% The next input line defines the left-hand side of a linear 2nd order equation.

syms x y(x); Dy = diff(y(x), x);
L1 = diff(y(x), x, 2) - x * diff(y(x), x) - y(x) == 0;
evalin(symengine, "ode::series({y''(x)-x*y'(x)-y(x), D(y)(0) = 1, y(0) = 2}, y(x), x = 0)")

%

evalin(symengine, ...
    "ORDER := 8; ode::series({y''(x)-x*y'(x)-y(x), D(y)(0) = 1, y(0) = 2}, y(x), x = 0)")

%

evalin(symengine, ...
    "ORDER := 4; ode::series(y''(x)-x*y'(x)-y(x), y(x), x = 0)")

%
%% 12.2 Singular Points

L2 = 2*x*diff(y(x), x, 2) + diff(y(x), x) + x*y(x);

%
% The indicial equation here is 2r^2 -r=0, which has roots 0 and 1/2.

evalin(symengine, ...
    "ORDER := 6; ode::series(2*x*y''(x)+y'(x)+x*y(x), y(x), x = 0)")

%
%% 12.3 Other Linear and Nonlinear Equations
% Example 12.3

syms t y(t); dsolve(t^2*diff(y(t), t, 2) + y(t) == 0)
evalin(symengine, "ode::series(t^2*D(D(y))(t) + y(t) = 0, y(t), t = 0)")

%
% Example 12.4

evalin(symengine, "ode::series({y(0) = 0, D(y)(t) + t*y(t)^2 = sin(t)}, y(t), t = 0)")
evalin(symengine, ...
    "ORDER := 10; ode::series({y(0) = 0, D(y)(t) + t*y(t)^2 = sin(t)}, y(t), t = 0)")