xspan = [1 2];
alpha = 1;
beta = 2;
y10 = [alpha 0];
y20 = [0 1];

opts = odeset('RelTol',1e-8,'AbsTol',1e-8);
sol1 = ode45(@lineareq, xspan, y10);
sol2 = ode45(@lineareq, xspan, y20);

x = linspace(1, 2, 100);
y1 = deval(sol1, x);
y2 = deval(sol2, x);
gam = (beta - y1(1, end))/y2(1, end);
y = y1 + gam*y2;


plot(x, y(1, :));

title('Linear shooting method');
xlabel('x');
ylabel('y');

function dydx = lineareq(x, y)
%LINEAREQ Evaluate the rhs of the ODE in Ex. 2
    dydx = [y(2); -2/x*y(2) + 2/x^2*y(1) + sin(log(x))/x^2];
end

