Exploring Existence & Uniqueness for 1st Order ODEs

a.k.a. ∃ & !

So far, we have just aimed directly at determining a solution for an ODE without worrying about whether such a solution exists or whether there might actually be more than one.

This will be our usual mode, but let's take a quick look at issues of existence and uniqueness.

Consider the example ((∂y)/(∂x))=(Sqrt[y]). We saw that this equation is separable, and we integrated to obtain a general solution y=(((((x+c)/2)))^2).

This also provides a venue for some introduction to Mathematica.
What is Mathematica? It is a software package for general support of mathematical endeavors; i.e. it provides a unified environment for symbolic manipulation, numeric computation, and graphics creation/display (all tucked in behind a nice, user-friendly interface).
You will get a tailored introduction to Mathematica in the near future, but for the moment let's just look at some relevant things we can do with it. In particular, let's consider issues of existence and uniqueness of solutions of 1st order ODEs.

solns[x_] := Table[((x+c)/2)^2, {c,-4,4,2}]

solns[x]

solnsPlot = Plot[Evaluate[solns[x]], {x,-4,4}, 
PlotStyle -> AbsoluteThickness[3] , 
PlotRange -> {0,4},
AxesLabel->{"X","Y"}]

So we have found a family of parabolas resulting from solving the ODE.
Do these look like legitimate solution curves?
What is the solution corresponding to the initial condition y[0]=1?

To help answer such questions, let's consider a graphical approach to solving ODEs. Consider creating a solution by using a marker particle that flows along in the x,y plane (starting at some initial condition). If we assume that the particle has unit speed in the x-direction, the speed in the y-direction is given by the explicit form of the 1st order ODE, y' = f[x,y]. So the vector field {1,f} determines the velocity at any point, and we can normalize (i.e. divide by the length of the vector) to obtain a field of unit vectors, (({1,f})/(Sqrt[1+(f^2)])), that specify the direction of the solution curve at every point in the x,y plane.

While Mathematica has a veritable plethora of built-in functions, this is not one of them. However, we can find something useful for visualizing such fields in the add-on package "Graphics`Plotfield`". Let's load the package and adapt the PlotVectorField function to meet our needs.

<<"VectorFieldPlots`"

dirPlot=VectorFieldPlot[(({1,(Sqrt[y])})/(Sqrt[1+y])),{x,-4,4},{y,0,4},Axes->True,AxesLabel->{"X","Y"}]

Show[solnsPlot, dirPlot]

So do our solution curves follow the direction field arrows?
Only on the right half of each parabola. What went wrong? 
We inadvertently allowed both values of the square root (which makes our f[x,y] ill-defined). If we choose the poisitive sign for (Sqrt[y]), then our solution curves should be non-decreasing (corresponding to the right half of each parabola).

Does that resolve all of our issues? 
Does the family of half-parabolas encompass all possible solutions?
Can you look at the direction field and spot another solution curve we have missed?

Note that all the arrows on the horizontal X-axis point horizontal, so the X-axis, or y≡0, is a SINGULAR SOLUTION, i.e. a solution not belonging to the family specified by a general solution.

Try summarizing existence and uniqueness for this problem.
Is there a solution corresponding to every possible initial condition?
If not, what fanily of initial conditions lead to real solutions?
What initial conditions produce unique solutions?
Where are the singular points (where more than one solution curve passes through)?

Another Example

Consider the 1st order ODE: y'=(1/(1-(x^2))).

The equation is separable and the itegration can be done using partial fractions. It also turns out that Mathematica is "smart" enough to solve this equation (if you know how to ask it the question with proper syntax...)

DSolve[y'[x] == 1/(1-x^2), y[x], x]

So are we done? Can we just plug in any initial condition, solve for the arbitrary constant, and follow our solution curve along for as long as we like?

To answer such questions, it is again helpful to look at the direction field specified by our ODE.

VectorFieldPlot[(({1,(1/(1-(x^2)))})/(Sqrt[1+(1/(((1-(x^2)))^2))])),{x,-2,2},{y,-2,2},Axes->True]

Can you spot signs of "trouble"?
At x=±1, the direction arrows become vertical (corresponding to y'becoming unbounded), so our solution curves cannot cross x=±1. Essentially, we end up needing different versions of the solution in each of the three regions (so that the arguments of the Logs will be positive).

In this problem, almost all initial conditions (except those at x=±1) lead to unique solutions. However, those solutions do not extend across the full domain of the x-axis.

As far as what Mathematica can do to help here, it is"smart" enough to evaluate the solution that is valid in the interval containing the initial x value: (Note the addition of y[0]==1 to specify the initial condition)

DSolve[{y'[x] == 1/(1-x^2), y[0]==1}, y[x], x]

solnCurve =%[[1,1,2]] (* some tricks to grab the useful part *)

Plot[solnCurve, {x,0, 2}]

Previous versions of Mathematica were not "smart" enough to figure out what to do when asked to plot the solution over a domain extending across the boundary. Now, it does a reasonably sane thing and plots up to the singularity.

We could also try a numerical solution:

NDSolve[{y'[x] == 1/(1-x^2), y[0]==1}, y[x], {x,0,2}]

Plot[%[[1,1,2]], {x,0, 2}, PlotRange -> {-10, 10}]

Note the trouble encountered near x=1. Even with all the built-in numerical solvers in the world, a human user who understands the capabilities and limitations adds a lot of value to the system...