Maxima Function
ode2 (eqn, dvar, ivar)
The function ode2
solves an ordinary differential equation (ODE)
of first or second order. It takes three arguments: an ODE given by
eqn, the dependent variable dvar, and the independent
variable ivar. When successful, it returns either an explicit or
implicit solution for the dependent variable. %c
is used to
represent the integration constant in the case of first-order equations,
and %k1
and %k2
the constants for second-order
equations. The dependence of the dependent variable on the independent
variable does not have to be written explicitly, as in the case of
desolve
, but the independent variable must always be given as the
third argument.
If ode2
cannot obtain a solution for whatever reason, it returns
false
, after perhaps printing out an error message. The methods
implemented for first order equations in the order in which they are
tested are: linear, separable, exact - perhaps requiring an integrating
factor, homogeneous, Bernoulli's equation, and a generalized homogeneous
method. The types of second-order equations which can be solved are:
constant coefficients, exact, linear homogeneous with non-constant
coefficients which can be transformed to constant coefficients, the
Euler or equi-dimensional equation, equations solvable by the method of
variation of parameters, and equations which are free of either the
independent or of the dependent variable so that they can be reduced to
two first order linear equations to be solved sequentially.
In the course of solving ODE's, several variables are set purely for
informational purposes: method
denotes the method of solution
used (e.g., linear
), intfactor
denotes any integrating
factor used, odeindex
denotes the index for Bernoulli's method or
for the generalized homogeneous method, and yp
denotes the
particular solution for the variation of parameters technique.
In order to solve initial value problems (IVP) functions ic1
and
ic2
are available for first and second order equations, and to
solve second-order boundary value problems (BVP) the function bc2
can be used.
Example:
(%i1) <b><code class="literal">x^2*'diff(y,x) + 3*y*x = sin(x)/x;</code></b> 2 dy sin(x) (%o1) x -- + 3 x y = ------ dx x (%i2) <b><code class="literal">ode2(%,y,x);</code></b> %c - cos(x) (%o2) y = ----------- 3 x (%i3) <b><code class="literal">ic1(%o2,x=%pi,y=0);</code></b> cos(x) + 1 (%o3) y = - ---------- 3 x (%i4) <b><code class="literal">'diff(y,x,2) + y*'diff(y,x)^3 = 0;</code></b> 2 d y dy 3 (%o4) --- + y (--) = 0 2 dx dx (%i5) <b><code class="literal">ode2(%,y,x);</code></b> 3 y + 6 %k1 y (%o5) ------------ = x + %k2 6 (%i6) <b><code class="literal">ratsimp(ic2(%o5,x=0,y=0,'diff(y,x)=2));</code></b> 3 2 y - 3 y (%o6) - ---------- = x 6 (%i7) <b><code class="literal">bc2(%o5,x=0,y=1,x=1,y=3);</code></b> 3 y - 10 y 3 (%o7) --------- = x - - 6 2