# Differential Equations

You can use the *Mathematica* function DSolve to find symbolic solutions to ordinary and partial differential equations.

Solving a differential equation consists essentially in finding the form of an unknown function. In *Mathematica*, unknown functions are represented by expressions like . The derivatives of such functions are represented by , , and so on.

The *Mathematica* function DSolve returns as its result a list of rules for functions. There is a question of how these functions are represented. If you ask DSolve to solve for , then DSolve will indeed return a rule for . In some cases, this rule may be all you need. But this rule, on its own, does not give values for or even . In many cases, therefore, it is better to ask DSolve to solve not for , but instead for itself. In this case, what DSolve will return is a rule which gives as a pure function, in the sense discussed in "Pure Functions".

In[1]:= |

Out[1]= |

In[2]:= |

Out[2]= |

In[3]:= |

Out[3]= |

In[4]:= |

Out[4]= |

In[5]:= |

Out[5]= |

DSolve[eqn,y[x],x] | solve a differential equation for |

DSolve[eqn,y,x] | solve a differential equation for the function y |

Getting solutions to differential equations in different forms.

In standard mathematical notation, one typically represents solutions to differential equations by explicitly introducing "dummy variables" to represent the arguments of the functions that appear. If all you need is a symbolic form for the solution, then introducing such dummy variables may be convenient. However, if you actually intend to use the solution in a variety of other computations, then you will usually find it better to get the solution in pure-function form, without dummy variables. Notice that this form, while easy to represent in *Mathematica*, has no direct analog in standard mathematical notation.

DSolve[{eqn_{1},eqn_{2},...},{y_{1},y_{2},...},x] | |

solve a list of differential equations |

Solving simultaneous differential equations.

In[6]:= |

Out[6]= |

In[7]:= |

Out[7]= |

You can add constraints and boundary conditions for differential equations by explicitly giving additional equations such as .

In[8]:= |

Out[8]= |

If you ask *Mathematica* to solve a set of differential equations and you do not give any constraints or boundary conditions, then *Mathematica* will try to find a *general solution* to your equations. This general solution will involve various undetermined constants. One new constant is introduced for each order of derivative in each equation you give.

The default is that these constants are named C[n], where the index n starts at for each invocation of DSolve. You can override this choice, by explicitly giving a setting for the option GeneratedParameters. Any function you give is applied to each successive index value n to get the constants to use for each invocation of DSolve.

In[9]:= |

Out[9]= |

In[10]:= |

Out[10]= |

You should realize that finding exact formulas for the solutions to differential equations is a difficult matter. In fact, there are only fairly few kinds of equations for which such formulas can be found, at least in terms of standard mathematical functions.

The most widely investigated differential equations are linear ones, in which the functions you are solving for, as well as their derivatives, appear only linearly.

In[11]:= |

Out[11]= |

In[12]:= |

Out[12]= |

If you have only a single linear differential equation, and it involves only a first derivative of the function you are solving for, then it turns out that the solution can always be found just by doing integrals.

But as soon as you have more than one differential equation, or more than a first-order derivative, this is no longer true. However, some simple second-order linear differential equations can nevertheless be solved using various special functions from "Special Functions". Indeed, historically many of these special functions were first introduced specifically in order to represent the solutions to such equations.

In[13]:= |

Out[13]= |

In[14]:= |

Out[14]= |

In[15]:= |

Out[15]= |

In[16]:= |

Out[16]= |

In[17]:= |

Out[17]= |

Beyond second order, the kinds of functions needed to solve even fairly simple linear differential equations become extremely complicated. At third order, the generalized Meijer G function MeijerG can sometimes be used, but at fourth order and beyond absolutely no standard mathematical functions are typically adequate, except in very special cases.

In[18]:= |

Out[18]= |

In[19]:= |

Out[19]= |

For nonlinear differential equations, only rather special cases can usually ever be solved in terms of standard mathematical functions. Nevertheless, DSolve includes fairly general procedures which allow it to handle almost all nonlinear differential equations whose solutions are found in standard reference books.

In[20]:= |

Out[20]= |

In[21]:= |

Out[21]= |

In[22]:= |

Out[22]= |

In[23]:= |

Out[23]= |

In[24]:= |

Out[24]= |

In practical applications, it is quite often convenient to set up differential equations that involve piecewise functions. You can use DSolve to find symbolic solutions to such equations.

In[25]:= |

Out[25]= |

In[26]:= |

Out[26]= |

Beyond ordinary differential equations, one can consider *differential-algebraic equations* that involve a mixture of differential and algebraic equations.

In[27]:= |

Out[27]= |

DSolve[eqn,y[x_{1},x_{2},...],{x_{1},x_{2},...}] | |

solve a partial differential equation for | |

DSolve[eqn,y,{x_{1},x_{2},...}] | solve a partial differential equation for the function y |

Solving partial differential equations.

DSolve is set up to handle not only *ordinary differential equations* in which just a single independent variable appears, but also *partial differential equations* in which two or more independent variables appear.

In[28]:= |

Out[28]= |

In[29]:= |

Out[29]= |

The basic mathematics of partial differential equations is considerably more complicated than that of ordinary differential equations. One feature is that whereas the general solution to an ordinary differential equation involves only arbitrary *constants*, the general solution to a partial differential equation, if it can be found at all, must involve arbitrary *functions*. Indeed, with independent variables, arbitrary functions of arguments appear. DSolve by default names these functions C[n].

In[30]:= |

Out[30]= |

In[31]:= |

Out[31]= |

In[32]:= |

Out[32]= |

In[33]:= |

Out[33]= |

For an ordinary differential equation, it is guaranteed that a general solution must exist, with the property that adding initial or boundary conditions simply corresponds to forcing specific choices for arbitrary constants in the solution. But for partial differential equations this is no longer true. Indeed, it is only for linear partial differential and a few other special types that such general solutions exist.

Other partial differential equations can be solved only when specific initial or boundary values are given, and in the vast majority of cases no solutions can be found as exact formulas in terms of standard mathematical functions.

In[34]:= |

Out[34]= |

In[35]:= |

Out[35]= |

In[36]:= |

Out[36]= |