This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Domain of ordinary differential equations

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


ode(eq, y(x))
ode({eq, <inits>}, y(x))
ode({eq1, eq2, , …, <inits>}, {y1(x), y2(x), …})


ode(eq, y(x)) represents an ordinary differential equation (ODE) for the function y(x).

ode({eq1, eq2, ...}, {y1(x), y2(x), ...}) represents a system of ODEs for the functions y1(x), y2(x) etc.

In the equations eq, eq1 etc., the unknown functions must be represented by y(x), y1(x) etc. Derivatives may be represented either by the diff function or by the differential operator D. Note that the token ' provides a handy shortcut: y'(x) = D(y)(x) means the same as diff(y(x), x).

The unknown functions must be univariate in the independent variable x. Multivariate expressions such as y(x, t) are not accepted.

The ode function does not accept piecewise input.

Initial and boundary conditions are defined by sequences of equations involving the unknown functions or their derivatives on the left hand side. The corresponding values must be specified on the right hand side of the equations. In particular, the differential operator D (or the token ') must be used to specify values of derivatives at some point. E.g.,

is a valid sequence of boundary conditions for inits.

Boundary conditions of the first and second kind are allowed. Mixed conditions are not accepted.

The initial/boundary points and the corresponding initial/boundary values may be symbolic expressions.

For scalar initial value or boundary value problems, use ode({eq, inits}, y(x)) to specify the conditions.

For systems of ODEs, there must be as many equations as unknown functions.

The main purpose of the ode domain is to provide an environment for overloading the function solve.

In the case of one single equation (possibly together with initial or boundary conditions), solve returns a set of explicit solutions or an implicit solution. Each element of the set represents a solution branch.

In the case of a system of equations, solve returns a set of lists of equations for the unknown functions. Each list represents a solution branch.

An symbolic solve call is returned if no solution is found.


Example 1

In the following, we show how to create and solve a scalar ODE. First, we define the ODE . We use the quote token ' to represent derivatives:

eq := ode(x^2*y'(x) + 3*x*y(x) = sin(x)/x, y(x))

We get an element of the domain ode which we can now solve:


delete eq:

Example 2

An initial value problem is defined as a set consisting of the ODE and the initial conditions:

ivp := ode({f''(t) + 4*f(t) = sin(2*t), 
            f(0) = a, f'(0) = b}, f(t))


delete ivp:

Example 3

With some restrictions, it is also possible to solve systems of ODEs. First, define a system:

sys := {x'(t) - x(t) + y(t) = 0, y'(t) - x(t) - y(t) = 0}

A call to solve yields the general solution with arbitrary parameters:

solution := solve(ode(sys, {x(t), y(t)}))

To verify the result, substitute it back into the system sys. However, for the substitution, you must rewrite the system into a notation using the diff function:

eval(subs(rewrite(sys, diff), op(solution)))

delete sys, solution:

If you have a system of differential equations in a matrix form, extract the components of the matrix to a set of differential equations:

Y:= matrix([x(t), y(t)]):
A:= matrix([[1, 2], [-1, 6]]):
s := ode({op(diff(Y, t) - A*Y)}, {x(t), y(t)})

Now, use the solve function to solve the system:


Example 4

In this example, we point out the various return formats of ode's solve facility. First, we solve an ODE with an initial condition. The solution involves a symbolic integral:

solve(ode({y'(x) + x*y(x) = cos(x), y(0) = 3}, y(x)))

For the next equation, we get an implicit solution:

solve(ode((x*y'(x) - y(x))^4*exp(x*y'(x) - y(x)) 
          - ln(x*y'(x) - y(x)), y(x)))

This is an algebraic equation for y. Its solution defines y as a function of x and an arbitrary parameter C followed by a number automatically generated by MuPAD® (constant of integration). However, the algebraic equation does not have a solution in closed form.

delete sys, solution:

Example 5

It may happen that MuPAD cannot solve a given equation. In such a case, a symbolic solve command is returned:

solve(ode(x*diff(y(x),x)-y(x)*(x*ln(x^3/y(x))+2), y(x)))

Example 6

The MuPAD ODE solver contains algebraic algorithms for computing Liouvillian and non-Liouvillian solutions of linear ordinary differential equations. These algorithms are based on differential Galois theory and on additional methods for finding solutions of linear ordinary differential equations given in terms of special functions. For the famous Kovacic's example


the solution can be found as:

solve(ode(y''(x) + (3/(16*x^2) + 2/(9*(x - 1)^2)
                    - 3/(16*x*(x - 1)))*y(x), y(x)))

MuPAD may find Liouvillian and non-Liouvillian solutions for higher order equations as well. However, in case of Liouvillian solutions, there is no guarantee that all of them are found.

MuPAD also finds non-Liouvillian solutions in terms of the Bessel, Airy, and Whittaker functions:

eq := y'(x) + y(x)^2 + b + a*x

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

We check this solution:

simplify(eval(subs(rewrite(eq, diff), y(x) = op(%))))

Example 7

It is also possible to compute the series solutions of an ordinary differential equation (cf. ode::series for further details):

series(ode(y''(x) + 4*y(x) = sin(w*x), y(x)), x = 0, 8)

Related Examples


eq, eq1, eq2, …

Equations or arithmetical expressions in the unknown functions and their derivatives with respect to x. An arithmetical expression is regarded as an equation with vanishing right hand side.

y, y1, y2, …

The unknown functions: identifiers


The independent variable: an identifier


The initial or boundary conditions: a sequence of equations

Return Values

Object of type ode.


[1] E. Kamke. "Differentialgleichungen: Lösungmethoden und Lösungen". B.G. Teubner, Stuttgart, 1997.

[2] G.M. Murphy. "Ordinary differential equations and their solutions". Van Nostrand, Princeton, 1960.

[3] D. Zwillinger. "Handbook of differential equations". San Diego: Academic Press, 1992.

[4] W. Fakler. Algebraische Algorithmen zur Lösung von linearen Differentialgleichungen. Stuttgart, Leipzig: Teubner, Reihe MuPAD Reports, 1999.

[5] M. van der Put and M.F. Singer. "Galois theory of linear differential equations". Grundlehren der Mathematischen Wissenschaften, 328, Springer-Verlag, Berlin, 2003.

[6] F. Ulmer and M.F. Singer. Liouvillian and algebraic solutions of second and third order linear differential equations. "J. Symb. Comp.", 16:37-74, 1993.

Was this topic helpful?