Documentation Center

  • Trial Software
  • Product Updates

ode::solve

Solving ordinary differential equations

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

ode::solve(o, options)
solve(o, options)

Description

ode::solve computes solutions for ordinary differential equations.

ode::solve(o) returns the set of solutions of the ordinary differential equation o. You can also call the generic function solve(o).

The solver detects the type of the differential equation and chooses an algorithm according to the detected equation type. If you know the type of the equation, you can use the option Type = OdeType to pass the equation type to the solver. Passing the equation type to the solver increases performance.

The solver recognizes the following values of OdeType:

  • Abel - Abel differential equation

  • Bernoulli - Bernoulli differential equation

  • Chini - Chini differential equation

  • Clairaut - Clairaut differential equation

  • ExactFirstOrder - exact first order ordinary differential equation

  • ExactSecondOrder - exact second order ordinary differential equation

  • Homogeneous - homogeneous first order ordinary differential equation

  • Lagrange - Lagrange differential equation

  • Riccati - Riccati differential equation

See the Background section for more details on the classes of ordinary differential equations.

If the solver cannot identify the equation with the type you indicated, it issues a warning and returns the special value FAIL.

To solve an ordinary differential equation disregarding possible conditions on the parameters of the equation, use IgnoreSpecialCases option. This option eliminates receiving a set of special cases as an answer.

To solve an ordinary differential equation in a simplified manner, use the IgnoreAnalyticConstraints option. This option can provide simple solutions for the equations for which the direct use of the solver gives complicated results. If you use the IgnoreAnalyticConstraints option, always check the answer. This option can lead to wrong or incomplete results. See Example 3.

The solutions of ordinary differential equations can contain arbitrary constants of integration. The solver generates the constants of integration using the format of an uppercase letter C followed by an automatically generated number, for example C13.

The solver does not always verify the uniqueness and completeness of the returned solution. For example:

  • The solver does not validate the Lipschitz-conditions on the ordinary differential equation for the Picard-Lindelöf Theorem.

  • For some complex nonlinear systems of differential equations the solver returns constant solutions and does not warn you that other solutions exist.

The solver might ignore assumptions that you set on symbolic parameters and variables or use them only partially. More precisely, ode::solve passes assumptions to the functions that it calls internally. While these functions can use the specified assumptions, ode::solve itself does not use them in most of its internal algorithms. The same happens if you define an ordinary differential equation using ode and solve it using solve.

Examples

Example 1

To define an ordinary differential equation, use the ode command:

o:= ode(y'(x) = y(x)^2, y(x))

To solve the equation, enter:

ode::solve(o)

or more efficiently:

solve(o)

Internally, the function ode::solve calls the function solve.

Example 2

You can solve an ordinary differential equation with a symbolic parameter and an initial condition:

o:= ode({y'(x) = a*y(x)^2, y(a) = ln(a)}, y(x)):
solve(o)

To reduce the number of returned solutions, use the option IgnoreSpecialCases. For example, you can drop the solution for the parameter a = 1:

solve(o, IgnoreSpecialCases)

With the IgnoreSpecialCases option, a returned set of solutions can be incomplete.

Example 3

The solver can return piecewise solutions:

o:= ode(y'(x) = a/y(x)^2 + b*y(x), y(x)):
solve(o)

This solution is complete and mathematically correct for all possible values of the parameter a and variable x. Also you can try the option IgnoreAnalyticConstraints to obtain a particular solution that is correct under a set of common assumptions:

solve(o, IgnoreAnalyticConstraints)

The solver accepts several options:

solve(o, Type = Bernoulli, IgnoreAnalyticConstraints)

Example 4

Suppose, you want to solve an ordinary differential equation from the class of Bernoulli equations:

o:= ode(y'(x) = (- 1/x + 2*I)*y(x) + 1/x*y(x)^2, y(x)):
solve(o)

The solver recognizes the type of the equation and uses the algorithm for solving Bernoulli equations. To improve performance, you can explicitly pass the type of the equation to the solver:

solve(o, Type = Bernoulli)

To solve the Clairaut equation with the initial conditions, enter:

o:= ode({(x*y'(x)-y(x))^2 - y'(x)^2 - 1 = 0, y(1) = 1}, y(x)):
solve(o, Type = Clairaut)

If the solver cannot identify the equation with the type you indicated, it issues a warning and returns the special value FAIL:

o:= ode({(x*y'(x)-y(x))^2 - y'(x)^2 - 1 = 0, y(1) = 1}, y(x)):
solve(o, Type = Lagrange)
Warning: Cannot detect the Lagrange ODE. [ode::lagrange]

Example 5

Some ordinary differential equations belong to several classes. For example, some Chini equations are also homogeneous and some Lagrange equations are also Clairaut equations. If an equation belongs to several classes simultaneously, the solver can present its solution in different forms. The form of a solution depends on the class with which an equation is identified. For example, suppose you want to solve the Chini differential equation. You can explicitly pass the type of the equation to the solver:

o:= ode(y'(x) = 1/x*y(x)^2 + 1/x*y(x) + x, y(x)):
L:= solve(o, Type = Chini)

You also can let the solver recognize the type of the equation:

solve(o)

The solver does not return the type with which an ordinary differential equation is internally identified. If you want to verify that both solution sets are equivalent, use the rewrite function with target exp on the first set of solutions:

rewrite(L, exp)

Example 6

MuPAD® solves some classes of Riccati ordinary differential equations that involve arbitrary functions. For example, the following equation contains the arbitrary function f(x):

eq := diff(y(x), x) - f(x)*y(x)^2 + a^2*x^(2*n)*f(x) - a*n*x^(n - 1)

For this equation the solver returns:

solve(ode(eq,y(x)))

You also can solve an equation with more than one arbitrary function. For example, the following equations contain f(x) and g(x):

eq:= diff(y(x), x) - g(x)*f(x)*y(x) - g(x) - diff(f(x), x)*y(x)^2

The returned solution is:

solve(ode(eq,y(x)))

Example 7

Suppose, you want to solve the following second-order ordinary differential equation:

eq:= x^2*(x^2+1)*diff(y(x),x,x)+x*(2*x^2+1)*diff(y(x),x)-(nu*(nu+1)*x^2+n^2)*y(x)

The solver returns the result in terms of the hypergeometric function 1F2 (see hypergeom):

solve(ode(eq,y(x)))

Example 8

The solver can handle some third- and higher-order ordinary differential equations. For example, solve the following third-order linear differential equations:

eq := ode(sin(x)*y'''(x) + cos(x)*y(x), y(x)):
solve(eq)

eq := ode(6*y(x) + x^3*y'''(x), y(x)):
solve(eq)

Example 9

The solver also can handle some nonlinear first-order ordinary differential equations. For example, solve the following first-order linear differential equations:

eq := ode(y(x)*diff(y(x), x) - y(x) - x^3 - 4*x^4 - 4*x^7, y(x)):
solve(eq)

eq := ode(exp(x/2)/4 - 2*exp(x) - y(x) + x*exp(x/2) + y(x)*y'(x), y(x)):
solve(eq)

Parameters

o

An ordinary differential equation, an object of the type ode.

Options

Type

Option, specified as Type = OdeType

Indicates the type of the ordinary differential equation and accepts the following arguments: Abel, Bernoulli, Chini, Clairaut, ExactFirstOrder, ExactSecondOrder, Homogeneous, Lagrange, Riccati.

MaxDegree

Option, specified as MaxDegree = n

Pass the option to the generic solver, which is called internally for all intermediate equations. See the list of options for the solve function for further information.

IgnoreSpecialCases

Pass the option to the generic solver, which is called internally for all intermediate equations, and to the integrator int, which is called for computing all intermediate integrals. See the list of options for the solve function for further information.

IgnoreAnalyticConstraints

Pass the option to the generic solver, which is called internally for all intermediate equations, and to the integrator int, which is called for computing all intermediate integrals. See the list of options for the solve function for further information.

Return Values

Set of solutions of the ordinary differential equation or the special value FAIL. For additional information on the return values, see the solve help page.

References

For more information on the particular classes of ordinary differential equations see:

  • E. Kamke: Differentialgleichungen: Lösungmethoden und Lösungen. B.G. Teubner, Stuttgart, 1997

  • G.M. Murphy: Ordinary differential equations and their solutions. Van Nostrand, Princeton, 1960

  • Andrei D. Polyanin and Valentin F. Zaitsev: Handbook of exact solutions for ordinary differential equations, second ed., Chapman & Hall/CRC, Boca Raton, FL, 2003

  • D. Zwillinger: Handbook of differential equations. San Diego: Academic Press, 1992

More About

Was this topic helpful?