Setting Up the Problem

The first argument given to DSolve is the differential equation, the second argument is the unknown function, and the last argument identifies the independent variable.

Here is the input for solving for a first-order linear ODE using DSolve. The variable identifies the solution for use in further work.
In[1]:=
Click for copyable input
Out[1]=

The output of DSolve is a list of solutions for the differential equation. The extra list is required since some equations have multiple solutions. Here, since the equation is of order 1 and is linear, there is only one solution: y[x]->+-5 x C[1]. The solution has an undetermined constant C[1] because no initial condition was specified. The solution can be extracted from the list of solutions using a part specification.

This extracts the solution.
In[2]:=
Click for copyable input
Out[2]=

This form of the solution is useful for finding itself, but not for finding derivatives of or the value of at a point.

This shows the value of given by the solution.
In[3]:=
Click for copyable input
Out[3]=
The solution does not apply to or because the solution is a rule for only.
In[4]:=
Click for copyable input
Out[4]=
In[5]:=
Click for copyable input
Out[5]=

If the solution will be used in further work, it is best to specify the unknown function using rather than . This gives the solution using pure functions of the type Function[x, expr].

Here, the unknown function is specified as . The solution is a pure function.
In[6]:=
Click for copyable input
Out[6]=

When the solution is in the form of pure functions, expressions can be found for derivatives of and for the values of at specific points.

This gives expressions for , , and .
In[7]:=
Click for copyable input
Out[7]=
In[8]:=
Click for copyable input
Out[8]=
In[9]:=
Click for copyable input
Out[9]=
In[10]:=
Click for copyable input
Out[10]=

When a problem has multiple solutions, you can pick out individual solutions from the solution list or you can work directly with the list.

This solves a nonlinear first-order equation. There are two solutions.
In[11]:=
Click for copyable input
Out[11]=
The solutions can be extracted using part specifications.
In[12]:=
Click for copyable input
Out[12]=
In[13]:=
Click for copyable input
Out[13]=
This returns a list of both expressions.
In[14]:=
Click for copyable input
Out[14]=

To solve a system of equations, the first argument to DSolve must be a list of the equations and the second argument must be a list of the unknown functions.

Here is an example of a system of first-order linear equations with three unknowns. Because this system is linear, there is only one solution.
In[15]:=
Click for copyable input
Out[15]=

Each solution to the system is a list of replacement rules for the unknown functions. The expressions for the unknown functions can be extracted as in previous examples.

This gives a list of the expressions for the unknown functions. Simplify is used to return the expressions in a compact form.
In[16]:=
Click for copyable input
Out[16]=

If initial conditions are prescribed for the problem, some or all of the undetermined constants can be eliminated.

Here the value of the unknown function and its derivative are both prescribed at the initial point.
In[17]:=
Click for copyable input
Out[17]=
If only the initial value is specified, then the solution still contains an arbitrary constant.
In[18]:=
Click for copyable input
Out[18]=

For a partial differential equation, the third argument to DSolve is a list of the independent variables for the equation.

This solves a PDE with independent variables and . C[1] represents an arbitrary function of y + Cos[y[x]].
In[19]:=
Click for copyable input
Out[19]=

A differential-algebraic equation is specified in the same way as a system of ordinary differential equations.

Here is an example of a DAE with an initial condition.
In[20]:=
Click for copyable input
Out[20]=

Note that it is not always possible to give the solutions for a problem in explicit form. In this case, the solution is given using an unevaluated Solve object or using InverseFunction.

The solution to this equation is not available explicitly. The output represents an implicit solution.
In[21]:=
Click for copyable input
Out[21]=
The solution can be extracted as usual with a part specification.
In[22]:=
Click for copyable input
Out[22]=
The solutions to this equation are given as InverseFunction objects.
In[23]:=
Click for copyable input
Out[23]=
Each solution can be rewritten as an implicit equation by eliminating the InverseFunction object as follows.
In[24]:=
Click for copyable input
Out[24]=
In[25]:=
Click for copyable input
Out[25]=
New to Mathematica? Find your learning path »
Have a question? Ask support »