Products & Services Solutions Academia Support User Community Company

Learn more about Symbolic Math Toolbox   

dsolve - Symbolic solution of ordinary differential equations

Syntax

dsolve('eq1','eq2',...,'cond1','cond2',...,'v')
dsolve(...,'IgnoreAnalyticConstraints',value)

Description

dsolve('eq1','eq2',...,'cond1','cond2',...,'v') symbolically solves the ordinary differential equations eq1, eq2,... using v as the independent variable. Here cond1,cond2,... specify boundary or initial conditions or both. You also can use the following syntax: dsolve('eq1, eq2',...,'cond1,cond2',...,'v'). The default independent variable is t.

The letter D denotes differentiation with respect to the independent variable. The primary default is d/dx. The letter 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).

You can specify initial and boundary conditions by 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 the specified initial conditions is less than the number of dependent variables, the resulting solutions contain the arbitrary constants C1, C2,....

You can input each equation or a condition as a separate symbolic equation. The dsolve command accepts up to 12 input arguments.

dsolve can produce the following three types of outputs:

If dsolve cannot find a closed-form (explicit) solution, it attempts to find an implicit solution. When dsolve returns an implicit solution, it issues a warning. If dsolve cannot find either an explicit or an implicit solution, then it issues a warning and returns the empty sym. In such a case, you can find a numeric solution, using the MATLAB ode23 or ode45 functions. In some cases involving nonlinear equations, the output is an equivalent lower order differential equation or an integral.

dsolve(...,'IgnoreAnalyticConstraints',value) accepts the following values:

If you do not set the value of the option IgnoreAnalyticConstraints to none, the solver applies the following rules to the expressions on both sides of an equation:

Examples

Solving Ordinary Differential Equations Symbolically

dsolve('Dx = -a*x')
ans =
C2/exp(a*t)

Specifying the Dependent Variable

The following differential equation presents f as a dependent variable:

dsolve('Df = f + sin(t)')
ans =
C4*exp(t) - sin(t)/2 - cos(t)/2

Specifying the Independent Variable

dsolve('(Dy)^2 + y^2 = 1','s')
ans =
                                                                        1
                                                                       -1
 (4*tan(C11/4 + s/4)*(tan(C11/4 + s/4)^2 - 1))/(tan(C11/4 + s/4)^2 + 1)^2
    (4*tan(C7/4 - s/4)*(tan(C7/4 - s/4)^2 - 1))/(tan(C7/4 - s/4)^2 + 1)^2

Setting Initial and Boundary Conditions

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

Solving a System of Differential Equations

z = dsolve('Dx = y', 'Dy = -x')
z = 
    x: [1x1 sym]
    y: [1x1 sym]

Enter z.x and z.y to see the results:

z.x
ans =
C20*cos(t) + C19*sin(t)
z.y
ans =
C19*cos(t) - C20*sin(t)

Using the IgnoreAnalyticConstraints Option

By default, the solver applies the set of purely algebraic simplifications that are not correct in general, but that can result in simple and practical solutions:

y = dsolve('Dy=1+y^2','y(0)=1')
y =
tan(pi/4 + t)

To obtain complete and generally correct solutions, set the value of the option IgnoreAnalyticConstraints to none:

y = dsolve('Dy=1+y^2','y(0)=1',...
'IgnoreAnalyticConstraints','none')
y =
piecewise([C29 in Z_, tan(pi/4 + t + pi*C29)])

The algebraic simplifications also allow you to obtain solutions for the equations that the solver cannot compute when it uses strict mathematical rules:

dsolve('Dv=19.6-0.00196*v^2','v(0)=0')
ans = 
-(100/exp((49*t)/125) - 100)/(1/exp((49*t)/125) + 1)

versus

dsolve('Dv=19.6-0.00196*v^2','v(0)=0',...
'IgnoreAnalyticConstraints','none') 
Warning: Explicit solution could not be found. 
> In dsolve at 104
 
ans =
[ empty sym ]

Diagnostics

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

Warning: Explicit solution could not be found.

and returns an empty sym object.

See Also

syms

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS