How to | Solve a Differential Equation
Mathematica's differential equation solving functions can be applied to many different classes of differential equations, automatically selecting the appropriate algorithms without needing pre-processing by the user.
Use
DSolve to solve the differential equation

for

with independent variable

:
| Out[1]= |  |
The solution given by
DSolve is a list of lists of rules. The outermost list encompasses all the solutions available, and each smaller list is a particular solution.
If you want to use a solution as a function, first assign the rule to something, in this case,
solution:
| Out[2]= |  |
Now, use
Part to take the first part of the solution using the short form
solution[[1]]. Replace
y[x] using
/. (the short form of
ReplaceAll) and then use = to define the function
f[x]:
| Out[3]= |  |
Now,
f[x] evaluates like any normal function:
| Out[4]= |  |
To specify initial conditions, enclose the equation and the initial conditions (

and

) in a list:
| Out[5]= |  |
If not enough initial conditions are given, constants
C[n] are returned:
| Out[6]= |  |
To indicate which functions should be solved for, use a second list:
| Out[7]= |  |
Here the solutions are not elementary functions:
| Out[8]= |  |
You can use
DSolve,
/.,
Table, and
Plot together to graph the solutions to an underspecified differential equation for various values of the constant.
First, solve the differential equation using
DSolve and set the result to
solution:
| Out[9]= |  |
Use = and
/. and
Part to define a function
g[x] using
solution:
| Out[10]= |  |
Define a table of functions
t[x] for integer values of
C[2] between 1 and 10:
| Out[11]= |  |
Use
Plot to plot the table over the range

:
| Out[12]= |  |