Shooting Demo 10.2.1

Shooting method: adjust the guess of the initial value by using information about the “shot”

lambda = 0.6;
phi = (r,w,dwdr) -> lambda/w^2 - dwdr/r;

f = (y,p,r) -> [ y[2]; phi(r, y[1], y[2])];
a,b = eps(),1.0;

plt = plot(xaxis = L"x", yaxis = L"w(x)",
           title = "Different initial values", leg=:bottomright);

for w0 in 0.4:0.1:0.9
    IVP = ODEProblem(f, [w0,0], (a,b))
    y = solve(IVP, Tsit5())
    plot!(y, vars = [1], label="w(0) = $w0")
end

plt