# Working with DSolve: A User's Guide

## Introduction

The aim of these tutorials is to provide a self-contained working guide for solving different types of problems with DSolve.

The first step in using DSolve is to set up the problem correctly. The next step is to use DSolve to get an expression for the solution. Once the solution has been found, it can be verified using symbolic or numerical techniques, or it can be plotted using a Wolfram System function such as Plot, Plot3D, or ContourPlot. Plots often reveal information about the solution that might not be evident from its closed-form expression.

If no boundary conditions are specified for a problem, the output from DSolve is some form of a general solution containing arbitrary parameters. The GeneratedParameters option can be used to label these arbitrary parameters.

In many applications, differential equations contain symbolic parameters, such as the rate of growth in the logistic equation. A differential equation can also contain inexact quantities, such as machine numbers arising from previous calculations. Both symbolic parameters and inexact quantities are allowed by DSolve, but it is good to be aware of their presence and interpret the solution correctly.

When DSolve makes any assumptions or encounters difficulty during a calculation, it issues a warning message outlining the problem. These messages can usually be ignored, but sometimes they point to serious limitations in the answer given for the problem.

It is helpful to analyze the statement of the problem for possible ambiguities—in other words, to make sure that the problem is well posed—so that meaningful answers can be obtained from DSolve.

## 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.

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 form of the solution is useful for finding itself, but not for finding derivatives of or the value of at a point.

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].

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.

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

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.

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.

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

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

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

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.

## Verification of the Solution

The solution given by DSolve can be verified using various methods. The easiest method involves substituting the solution back into the equation. If the result is True, the solution is valid.

Sometimes the result of the substitution is more complicated than True or False. Such examples can be verified by using Simplify to simplify the result of the substitution. If the simplified result is True, the solution is valid.

If the equation involves special functions, it may be necessary to use FullSimplify to verify the solution.

If the solution is large or if Simplify and FullSimplify do not succeed in verifying the solution, a numerical check can be made by using RandomReal or RandomComplex to generate values for all the variables and parameters in the problem. It is advisable in such cases to repeat the check with several sets of random values.

Although numerical checks cannot verify a solution with certainty, more rigorous checks can be made by using higher precision or by allowing the variables to take complex values.

The previous methods are of use only when the solution is available in explicit form. The final example shows how to verify the solution of a first-order ODE when it is given in implicit form.

## Plotting the Solution

A plot of the solution given by DSolve can give useful information about the nature of the solution, for instance, whether it is oscillatory in nature. It can also serve as a means of solution verification if the shape of the graph is known from theory or from plotting the vector field associated with the differential equation. A few examples that use different Wolfram Language graphics functions follow.

## Generated Parameters

The general solution to a differential equation contains undetermined coefficients that are labeled C[1], C[2], and so on.

To change the name of the undetermined parameter, use the GeneratedParameters option.

The parameter C should be thought of as a pure function that acts on a set of indices to generate different constants C[i].

Internally, the use of a pure function allows DSolve to increment the argument i in C[i] correctly for higher-order ODEs and systems of ODEs.

Using a pure function is particularly useful if you want to begin indexing the parameters at any value other than 1 (the default).

It is sometimes useful to display the solution using subscripts or other styles for the parameter indices.

Finally, with Module variables, you can get names for the parameters that are unique across different invocations of DSolve.

## Holonomic Solutions

The solutions of linear ODEs with polynomial or rational function coefficients can be expressed in terms of holonomic function DifferentialRoot.

The option Method"Holonomic" forces DSolve to return a holonomic solution for a linear ODE.

## Singular Solutions

By default, DSolve returns a general solution depending on arbitrary parameters for a linear or nonlinear ODE. For some nonlinear ODEs, there can be also singular solutions. These singular solutions cannot be obtained by assigning specific values to the arbitrary constants in the general solution, but are useful in the study of dynamical systems and elsewhere.

The DSolve option IncludeSingularSolutionsTrue returns singular solutions for nonlinear ODEs together with the general solution.

## Assumptions

In some cases, ODEs have different solutions depending on specific types and ranges of parameters or variables. The Assumptions option in DSolve allows one to specify the types or ranges of parameters and variables to choose the necessary solution.

## Symbolic Parameters and Inexact Quantities

The differential equations that arise in practice are of two types.

- Equations in which the only variables are the independent and dependent variables. Thus, all the variables that appear in the first argument to DSolve are also in the second or third arguments.
- Equations in which there are other symbolic quantities, such as mass or the spring constant. The solution in this case depends on the independent variables, the dependent variables, and the additional symbolic parameters.

DSolve is equipped to deal with both types of equations. It is extremely useful to have the solution available for all possible values of the parameters in the second type of equation.

It should be noted that the presence of symbolic parameters can lead to fairly complicated output.

However, for some special values of the parameters, the solution might be significantly simpler.

Occasionally, a solution is valid for most, but not all, values of the parameters.

In summary, the ability to solve differential equations with symbolic parameters is a *powerful and essential feature* of any symbolic solver such as DSolve. However, the following points should be noted.

- The solution might be complicated, and such calculations often require significant time and memory.
- The answer might not be valid for certain exceptional values of the parameters.
- The solution might be easy to verify symbolically for some special values of the parameters, but in the general case a numerical verification method is preferable.

Numerical quantities in the Wolfram Language can be of three types: infinite precision, machine precision, or arbitrary precision. The first type of number is referred to as "exact", while the remaining two types represent incomplete information and are therefore called "inexact".

Since DSolve is a symbolic solver, the algorithms used by it are primarily based on the assumption of exact input. However, equations that contain inexact quantities are handled by DSolve in the usual way.

Inexact input could arise, for example, when the coefficients in the equations are derived from a previous calculation and are known only approximately. In such cases, it might not be practical to convert the equations to exact form, as this could slow down the calculation significantly.

Thus, it is often desirable to continue working with inexact quantities even within a symbolic function such as DSolve. However, it should be noted that the solution obtained in such cases could have a certain amount of numerical error and should be checked carefully. It is therefore recommended that if the problem size is not too large (for instance, if there are fewer than five equations), the input should be converted to exact form using the Rationalize function.

## Is the Problem Well-Posed?

DSolve returns a general solution for a problem if no initial or boundary conditions are specified.

However, if initial or boundary conditions are specified, the output from DSolve must satisfy both the underlying differential equation as well as the given conditions.

In such cases, it is useful to check whether DSolve has been asked a reasonable question—in other words, to check whether the problem is well-posed. An initial or boundary value problem is said to be *well-posed* if a solution for it is guaranteed to exist in some well-known class of functions (for example, analytic functions), if the solution is unique, and if the solution depends continuously on the data. Given an ODE of order (or a system of first-order equations) and initial conditions, there are standard existence and uniqueness theorems that show that the problem is well-posed under a specified set of conditions. The right-hand side of the first-order linear ODE in the previous example is a polynomial in and hence infinitely differentiable. This is sufficient to apply Picard's existence and uniqueness theorem, which only requires that the right-hand side be Lipschitz-continuous.

Most problems that arise in practice are well-posed since they are derived from sound theoretical principles. However, as a note of caution, the following are examples where DSolve might have difficulty finding a satisfactory solution to the problem.

Finally, it is possible that a problem has a solution, but that DSolve fails to find it because the general solution is in implicit form or involves higher transcendental functions.

## Working with DSolveValue

Together with DSolve, the function DSolveValue can also be used for solving differential equations. DSolveValue can solve ordinary differential equations (ODEs), partial differential equations (PDEs), differential algebraic equations (DAEs), delay differential equations (DDEs), integral equations, integro-differential equations and hybrid differential equations.

The output of DSolveValue is controlled by the form of the dependent function, or .

In contrast with DSolve, the second argument of DSolveValue can be any expression of dependent and independent variables. DSolveValue[eqn,expr,x] gives the value of expr determined by a symbolic solution to the ordinary differential equation eqn with independent variable .

If the solution of a differential equation has more then one branch, then DSolveValue generates a warning message and returns only one of the solutions.

This concludes the discussion of the basic principles for effectively working with DSolve. See the list of "references" that were found to be useful either during the development of DSolve or during the preparation of this documentation.