dsolve
Solves ordinary differential equations symbolically.
Category: Mathematics > Equation Solving
Syntax
S = dsolve(eqn)
General solution, with arbitrary constants C1, C2, and so on.
S = dsolve(eqn, cond)
Particular solution that meets the initial or boundary conditions cond.
Description
The unknown must be declared as a symbolic function, for instance syms y(t). Without conditions the answer contains integration constants; each condition fixes one of them. Equations the solver cannot handle are returned unsolved with a warning.
For a numerical answer use ode45 and friends, after turning the equation into a first-order system with odeToVectorField.
Input arguments
eqn- Equation using
diffof a symbolic function, such asdiff(y,t,2) + y == 0. cond- Conditions such as
y(0) == 1. A derivative condition is written withsubs(diff(y,t), t, 0) == 1, or with a variableDy = diff(y,t)andDy(0) == 1.
Output arguments
S- Symbolic expression for the solution.
Examples
First order with an initial value
syms y(t)
dsolve(diff(y,t) == -2*y, y(0) == 1)
Output
ans = exp(-2*t)
General solution with a parameter
syms y(t) a
dsolve(diff(y,t) == a*y)
Output
ans = C1*exp(a*t)
Notes
Linear equations and the common first-order types are handled; systems of coupled differential equations are not supported in MatLivre.