How to | Solve a Differential Equation

The Wolfram Language's differential equation solving functions can be applied to many different classes of differential equations, automatically selecting the appropriate algorithms without needing preprocessing by the user.

Use DSolve to solve the differential equation for with independent variable :

In[1]:=
Click for copyable input
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, :

In[2]:=
Click for copyable input
Out[2]=

Now, use Part to take the first part of the solution using the short form . Replace using (the short form of ReplaceAll) and then use to define the function :

In[3]:=
Click for copyable input
Out[3]=

Now, evaluates like any normal function:

In[4]:=
Click for copyable input
Out[4]=

To specify initial conditions, enclose the equation and the initial conditions ( and ) in a list:

In[5]:=
Click for copyable input
Out[5]=

If not enough initial conditions are given, constants C[n] are returned:

In[6]:=
Click for copyable input
Out[6]=

To indicate which functions should be solved for, use a second list:

In[7]:=
Click for copyable input
Out[7]=

Here the solutions are not elementary functions:

In[8]:=
Click for copyable input
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 :

In[1]:=
Click for copyable input
Out[1]=

Use , , and Part to define a function using :

In[2]:=
Click for copyable input
Out[2]=

Define a table of functions for integer values of C[2] between 1 and 10:

In[3]:=
Click for copyable input
Out[3]=

Use Plot to plot the table over the range :

In[4]:=
Click for copyable input
Out[4]=