# Differential Equations

We looked at the `solve` command when we discussed Algebraic Calculations. Maple can also solve differential equations with the `dsolve` command.

First off, define a differential equation in a similar way as you have been doing:

```> sample_DE := x^2 * diff(y(x), x) + y(x)= exp(x);

2 /  d      \
sample_DE := x  |---- y(x)| + y(x) = exp(x)
\ dx      /
```

Now we can solve the differential equation with `dsolve`:

```> dsolve( sample_DE, y(x) );

(x - 1) (x+ 1)
/ exp(---------------)
|             x
y(x) = exp(1/x)  | -------------------- dx + exp(1/x) _C1
|            2
/            x

```

Since we did not define initial conditions, Maple assigned a constant ( `_C1` ) to the equation.
Here is another example, sample2_DE:

```> sample2_DE := diff(y(u),u) + y(u)^2 +(2*u+1)*y(u) + u^2 + u + 1 =0;

/  d      \       2                    2
sample2_DE := |---- y(u)| + y(u)  + (2 u+ 1) y(u) + u  + u + 1 = 0
\ du      /

```

We are going to define the initial conditions, initial, so that y(1)=1:

```> initial := y(1) = 1;

initial := y(1)= 1
```

Now use `dsolve` to solve the differential equation given the initial conditions. Notice that the two definitions are in curly brackets, {}:

```>  dsolve( {sample2_DE, initial}, y(u) );

exp(- u)
y(u) = - u +----------------------
3/2 exp(-1) - exp(- u)

```

We can simplify the above expression:

```> simplify(");

- 3 u exp(-1) + 2 uexp(- u) + 2 exp(- u)
y(u) = ------------------------------------------
- 3 exp(-1) +2 exp(- u)

```

Solutions for equations can be calculated numerically or as a series of equations. Maple also has the capability of solving multiple order differential equations. For more information, look at one of the references listed at the end of this tutorial.