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 sol
identifies the solution for use in further work.
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:
. The solution has an undetermined constant C
because no initial condition was specified. The solution can be extracted from the list of solutions using a part specification.
This extracts the solution.
This form of the solution is useful for finding y[x]
itself, but not for finding derivatives of y[x]
or the value of y[x]
at a point.
This shows the value of y[x]
given by the solution.
The solution does not apply to y[x]
because the solution is a rule for y[x]
If the solution will be used in further work, it is best to specify the unknown function using y
rather than y[x]
. This gives the solution using pure functions of the type Function[x, expr]
Here, the unknown function is specified as y
. The solution is a pure function.
When the solution is in the form of pure functions, expressions can be found for derivatives of y
and for the values of y
at specific points.
This gives expressions for y[x]
, and y
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.
The solutions can be extracted using part specifications.
This returns a list of both expressions.
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.
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.
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.
If only the initial value is specified, then the solution still contains an arbitrary constant.
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 x
represents an arbitrary function of y + Cos[y[x]]
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.
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 can be extracted as usual with a part specification.
Each solution can be rewritten as an implicit equation by eliminating the InverseFunction
object as follows.