Symbolic Math Toolbox Go to function: Search    Help Desk

Symbolic solution of ordinary differential equations.

Syntax

```r = dsolve('eq1,eq2,...', 'cond1,cond2,...', 'v')
r = dsolve('eq1','eq2',...,'cond1','cond2',...,'v')
```

Description

`dsolve('eq1,eq2,...', 'cond1,cond2,...', 'v')` symbolically solves the ordinary differential equation(s) specified by `eq1`, `eq2,...` using `v` as the independent variable and the boundary and/or initial condition(s) specified by `cond1,cond2,...`.

The default independent variable is `t`.

The letter `D` denotes differentiation with respect to the independent variable; with the primary default, this is `d/dx`. A `D` followed by a digit denotes repeated differentiation. For example, `D2` is `d2/dx2`. Any character immediately following a differentiation operator is a dependent variable. For example, `D3y` denotes the third derivative of `y(x)` or `y(t)`.

Initial/boundary conditions are specified with equations like `y(a) = b` or
`Dy(a) = b`, where `y` is a dependent variable and `a` and `b` are constants. If the number of initial conditions specified is less than the number of dependent variables, the resulting solutions will contain the arbitrary constants `C1`, `C2`,`...`.

You can also input each equation and/or initial condition as a separate symbolic equation. `dsolve` accepts up to 12 input arguments.

With no output arguments, `dsolve` returns a list of solutions.

`dsolve` returns a warning message, if it cannot find an analytic solution for an equation. In such a case, you can find a numeric solution, using MATLAB's `ode23` or `ode45` function.

Examples

`dsolve('Dy = a`*`y')` returns

```exp(a*t)*C1
```
`dsolve('Df = f + sin(t)')` returns

```-1/2*cos(t)-1/2*sin(t)+exp(t)*C1
```
`dsolve('(Dy)^2 + y^2 = 1','s')` returns

```-sin(-s+C1)
```
`dsolve('Dy = a*y', 'y(0) = b')` returns

```exp(a*t)*b
```
`dsolve('D2y = -a^2*y', 'y(0) = 1', 'Dy(pi/a) = 0')` returns

```cos(a*t)
```
`dsolve('Dx = y', 'Dy = -x')` returns

```x=
cos(t)*C1+sin(t)*C2
y =
-sin(t)*C1+cos(t)*C2
```

Diagnostics

If `dsolve` cannot find an analytic solution for an equation, it prints the warning

```Warning: explicit solution could not be found
```
and return an empty `sym` object.

`syms`