First-Order Ordinary Differential Equations

Mathematica has two routines that are designed to solve differential equations, DSolve and NDSolve. DSolve is used to find closed-form solutions, and NDSolve finds solutions numerically. Both can find solutions to ordinary as well as partial differential equations. See Mathematica's Help Browser for syntax and other useful information.

Mathematica can solve the homogeneous linear ODE:

DSolve[y'[x]  +  p[x] y[x]  == 0, y[x], x]

The dummy integration variables and any integration constants are picked by Mathematica .  Note that we asked Mathematica to solve the most general form of homogeneous linear first-order ODE, and we got a solution in a very general form that is equivalent to Kreyszig Eq. (3), p. 33.  Here is a more specific problem and the solution found by Mathematica:

DSolve[y'[x] + (2 x + 1) y[x]  == 0,  y[x], 
      x]

Boundary conditions are introduced in the following way to generate a particular solution:

DSolve[{y'[x] + (2 x + 1) y[x]  == 0, y[0] == 4},  
      y[x], x]

Mathematica can solve the heterogeneous linear ODE:

DSolve[y'[x]  +  p[x] y[x]  == r[x], y[x], x]

Again, we asked Mathematica to solve the most general form of homogeneous linear first-order ODE, and we got a solution in a very general form that is equivalent to Kreyszig Eq. (4), p. 34.  Here is a more specific problem and the solution found by Mathematica (see Kreyszig Example 1, p. 34):

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

The Bernoulli equation is a first-order nonlinear ODE that has a form that can be reduced to a linear ODE as described in Kreyszig, pp. 36–38.

BernoulliEquation  =  y'[x]  +  p[x] y[x]  ==  
        r[x] (y[x])^(a)

The substitution y(x) = (((u (x)))^(1/(1 - a)))is made, resulting in a linear ODE that can be solved for u(x):

yRep  =  u[x]^((1/(1 - a)))
DyRep  =  D[yRep, x]

step1  = 
      BernoulliEquation /. {y[x] -> yRep, y'[x]  ->  
            DyRep}

step2  = PowerExpand[step1]

step3  = Simplify[step2]

Solve[step3, u'[x]]

This last result is the first-order linear ODE that results from the Bernoulli equation. Its solution gives the function u(x) which can be converted back to y(x) with the relation y(x) = (((u (x)))^(1/(1 - a))).

Numerical Solutions to ODEs

The following nonlinear ODE either does not have a solution, or takes too long to find.

DSolve[Sin[2 Pi y'[x]^2]  ==  y[x] x, y[x], x]

NDSolve is a numerical method for finding a solution. An initial condition and the desired range of solution are required.

solution  = 
      NDSolve[{Sin[2 Pi y'[x]^2]  ==  y[x] x, y[0] == 1}, 
        y, {x, 0, 3.5}]

The results look kind of strange, perhaps, but they are a set of rules that provide a function that interpolates between values.   
    Here is how to find the approximate solution at three different values of x on the specified interval:

y[0.5]  /.  solution

y[1] /. solution

y[Pi] /. solution

Note that Mathematica has found two solutions, the first is real and the second is complex. Below are plots of the real and imaginary parts for both solutions:

Plot[Evaluate[Re[y[x] /. solution]], {x, 0, 3.5}, 
      PlotStyle -> {{Hue[1], Thickness[0.01]}, {Hue[0.6], 
            Thickness[0.01]}}]

Plot[Evaluate[Im[y[x] /. solution]], {x, 0, 3.5}, 
      PlotStyle -> {{Hue[1], Thickness[0.01]}, {Hue[0.6], 
            Thickness[0.01]}}]

Note that for x < 0.85 (approximately), both solutions are real.