%-*-EMaxima-*-

\section{Ordinary Differential Equations}

\subsection{Defining Ordinary Differential Equations}

There are three standard ways to represent an ordinary differential
equation, such as 
$$ x^2y'+3xy=\sin(x)/x,$$
in Maxima.  The simplest way is to represent the derivatives by
\texttt{'diff(y,x)},\\
\texttt{'diff(y,x,2)}, etc.  The above ordinary
differential equation would then be entered as
\beginmaximasession
x^2*'diff(y,x) + 3*x*y = sin(x)/x;
\maximatexsession
\C1.  x^2*'diff(y,x) + 3*x*y = sin(x)/x; \\
\D1.   x^{2}\*\left({{d}\over{d\*x}}\*y\right)+3\*x\*y={{\sin x}\over{x
 }} \\
\endmaximasession
\noindent
Note that the derivative \texttt{'diff(y,x)} is quoted, to prevent it
from being evaluated (to \texttt{0}).  
The second way is to use the \texttt{depends} command to tell Maxima
that \texttt{y} is a functions of \texttt{x}, making the quotes
unnecessary.   The above equation would then be entered as
\beginmaximasession
depends(y,x);
x^2*diff(y,x) + 3*x*y = sin(x)/x;
\maximatexsession
\C2.  depends(y,x); \\
\D2.   \left[ y\left(x\right) \right]  \\
\C3.  x^2*diff(y,x) + 3*x*y = sin(x)/x; \\
\D3.   x^{2}\*\left({{d}\over{d\*x}}\*y\right)+3\*x\*y={{\sin x}\over{x
 }} \\
\endmaximasession
\noindent
The third way would be to write \texttt{y(x)} explicitly as a function
of \texttt{x}.  The above equation would then be entered as
\beginmaximasession
x^2*diff(y(x),x) + 3*x*y(x) = sin(x)/x;
\maximatexsession
\C4.  x^2*diff(y(x),x) + 3*x*y(x) = sin(x)/x; \\
\D4.   x^{2}\*\left({{d}\over{d\*x}}\*y\left(x\right)\right)+3\*x\*y
 \left(x\right)={{\sin x}\over{x}} \\
\endmaximasession
\noindent
Different commands for working with differential equations require
different representations of the equations.  For the command
\texttt{ode2} (see subsection \ref{subsec:ode2}), it is often more useful
to use one of the first two representations, while for the command 
\texttt{desolve} (see subsection \ref{subsec:desolve})
it is required to use the third representation.

\subsection{Solving Ordinary Differential Equations: \texttt{ode2}}
\label{subsec:ode2}

\subsubsection{Using \texttt{ode2}}

Maxima can solve first and second order differential equations using
the \texttt{ode2} command.  The command
\texttt{ode2(}\textit{eqn}\texttt{,}\textit{depvar}\texttt{,}%
\textit{indvar}\texttt{)}  will solve the differential equation
given by \textit{eqn}, assuming that \textit{depvar} and
\textit{indvar} are the dependent and independent variables,
respectively.  (If an expression \textit{expr} is given instead of an
equation, it is assumed that the expression represents the equation
\textit{expr}\texttt{=0}.)

\beginmaximasession
ode2(x^2*diff(y,x) + 3*x*y = sin(x)/x, y, x);
\maximatexsession
\C5.  ode2(x^2*diff(y,x) + 3*x*y = sin(x)/x, y, x); \\
\D5.   y={{\mathrm{\%C}-\cos x}\over{x^{3}}} \\
\endmaximasession
\noindent
If \texttt{ode2} cannot solve a given equation, it returns
the value \texttt{FALSE}.

\subsubsection{Initial and Boundary Conditions}

After a differential equation is solved by \texttt{ode2}, initial
values or boundary conditions can be given to the solution.  The
commands for giving the conditions to the solution, however, require
that the differential equation \textbf{not} be given explicitly as a
function of the variable; i.e., \texttt{diff(y,x)} would have to be used
rather than \texttt{diff(y(x),x)} to denote the derivative.

For a first order differential equation, the initial condition can be
given using \texttt{ic1}. If \texttt{ode2} returns the general
solution \textit{soln} to a first order differential equation, the
command
\texttt{ic1(}\textit{soln}\texttt{, }\textit{indvar}\texttt{=}$a$%
\texttt{, }\textit{depvar}\texttt{=}$b$\texttt{)} will return the
particular solution which equals $b$ when the variable equals $a$.
\beginmaximasession
soln1:ode2(x^2*diff(y,x) + 3*x*y = sin(x)/x, y, x);
ic1(soln1, x=1, y=1);
\maximatexsession
\C6.  soln1:ode2(x^2*diff(y,x) + 3*x*y = sin(x)/x, y, x); \\
\D6.   y={{\mathrm{\%C}-\cos x}\over{x^{3}}} \\
\C7.  ic1(soln1, x=1, y=1); \\
\D7.   y=-{{\cos x-\cos 1-1}\over{x^{3}}} \\
\endmaximasession

For a second order differential equation, conditions can be given as
initial conditions, using \texttt{ic2}, or as boundary conditions,
using \texttt{bc2}.  If \texttt{ode2} returns the general solution
\textit{soln} to a second order differential equation, the command
\texttt{ic2(}\textit{soln}\texttt{, }\textit{indvar}\texttt{=}$a$%
\texttt{, }\textit{depvar}\texttt{=}$b$\texttt{, }%
\texttt{diff(}\textit{depvar}\texttt{, }\textit{indvar}\texttt{)=}%
$c$\texttt{)} will return the particular solution which
equals $b$ and whose derivative equals $c$ when the variable equals
$a$.
\beginmaximasession
eqn2: diff(y,x,2) + y = 4*x;
soln2: ode2(eqn2, y, x);
ic2(soln2, x=0, y=1, diff(y,x)=3);
\maximatexsession
\C8.  eqn2: diff(y,x,2) + y = 4*x; \\
\D8.   {{d^{2}}\over{d\*x^{2}}}\*y+y=4\*x \\
\C9.  soln2: ode2(eqn2, y, x); \\
\D9.   y=\mathrm{\%K1}\*\sin x+\mathrm{\%K2}\*\cos x+4\*x \\
\C10.  ic2(soln2, x=0, y=1, diff(y,x)=3); \\
\D10.   y=-\sin x+\cos x+4\*x \\
\endmaximasession
\noindent
Similarly, if \texttt{ode2} returns the general solution \textit{soln}
to a second order differential equation, the command 
\texttt{bc2(}\textit{soln}\texttt{, }\textit{indvar}\texttt{=}$a$%
\texttt{, }\textit{depvar}\texttt{=}$b$\texttt{, }%
\textit{indvar}\texttt{=}$c$\texttt{, }\textit{\mbox{depvar}}%
\texttt{=}$d$\texttt{)} will return the particular
solution which equals $b$ when the variable equals $a$
and which equals $d$ when the variable equals $c$.

\beginmaximasession
bc2(soln2, x=0, y=3, x=2, y=1);
\maximatexsession
\C11.  bc2(soln2, x=0, y=3, x=2, y=1); \\
\D11.   y=-{{\left(3\*\cos 2+7\right)\*\sin x}\over{\sin 2}}+3\*\cos x+
 4\*x \\
\endmaximasession


\subsubsection{\texttt{ode2} Methods}

To solve a given differential equation, \texttt{ode2} will attempt a
series of standard methods for solving differential equations.  These
methods will be described below, more in-depth discussions of these
techniques can be found in any standard introductory text on ordinary
differential equations (such as \textsl{Elementary Differential
  Equations and Boundary Value Problems} by Boyce and DiPrima, from 
which most of these routines were taken).

The first thing \texttt{ode2} will do with a differential equation is
determine whether it is first order or second order.  For first order
differential equations, \texttt{ode2} will check to see if the
equation falls into one of the following categories, in which case the
equation will be solved appropriately.

\medskip

\noindent
\textit{Linear.}\quad
A first order differential equation is \textit{linear} if it can be
written in the form $y' + p(x)y = q(x)$.  In this case, the solution 
is given by $y=\left(I(x)+c\right)/\mu(x)$, where $\mu(x)$ is
$e^{P(x)}$ for some antiderivative $P(x)$ of $p(x)$, 
$I(x)$ is an antiderivative of $\mu(x)q(x)$,
and $c$ is an arbitrary constant.
\beginmaximasession
linode:diff(y,x) + x*y = x^2;
ode2(linode,y,x);
\maximatexsession
\C12.  linode:diff(y,x) + x*y = x^2; \\
\D12.   {{d}\over{d\*x}}\*y+x\*y=x^{2} \\
\C13.  ode2(linode,y,x); \\
\D13.   y=e^ {- {{x^{2}}\over{2}} }\*\left({{\sqrt{2}\*\sqrt{\pi}\*i\*
 \mathrm{erf}\left({{i\*x}\over{\sqrt{2}}}\right)}\over{2}}+x\*e^{{{x
 ^{2}}\over{2}}}+\mathrm{\%C}\right) \\
\endmaximasession

\smallskip

\noindent
\textit{Separable.}\quad
A first order differential equation is \textit{separable} if it can be
put in the form $M(x)=N(y)y'$.  In this case, an implicit solution is
obtained by integrating both sides of $M(x)dx = N(y)dy$.  (It may or
may not be possible to solve for $y$ explicitly.)
\beginmaximasession
separableode:(3*x^2+4*x+2)=(2*y-1)*diff(y,x);
ode2(separableode, y, x);
\maximatexsession
\C14.  separableode:(3*x^2+4*x+2)=(2*y-1)*diff(y,x); \\
\D14.   3\*x^{2}+4\*x+2=\left(2\*y-1\right)\*\left({{d}\over{d\*x}}\*y
 \right) \\
\C15.  ode2(separableode, y, x); \\
\D15.   y^{2}-y=x^{3}+2\*x^{2}+2\*x+\mathrm{\%C} \\
\endmaximasession

\smallskip

\noindent
\textit{Exact.}\quad
A first order differential equation is 
\textit{exact} if it can be put in the form $p(x,y)y'+q(x,y)=0$, where
$p(x,y) = \partial M(x,y) /\partial y$ and 
$q(x,y) = \partial M(x,y) /\partial x$ for some $M(x,y)$.  In this
case, the solution will be given implicitly by $M(x,y)=0$.
(It may or may not be possible to solve for $y$ explicitly.)
\beginmaximasession
exactode:x^2*cos(x*y)*diff(y,x) + (sin(x*y) + x*y*cos(x*y))=0;
ode2(exactode,y,x);
\maximatexsession
\C16.  exactode:x^2*cos(x*y)*diff(y,x) + (sin(x*y) + x*y*cos(x*y))=0; \\
\D16.   \sin \left(x\*y\right)+x^{2}\*\left({{d}\over{d\*x}}\*y\right)
 \*\cos \left(x\*y\right)+x\*y\*\cos \left(x\*y\right)=0 \\
\C17.  ode2(exactode,y,x); \\
\D17.   x\*\sin \left(x\*y\right)=\mathrm{\%C} \\
\endmaximasession
\noindent
If the given differential equation can be put in the form 
$p(x,y)y' + q(x,y)=0$ but is not exact, \texttt{ode2} checks to see if
there is an integrating factor $\mu(x,y)$ which will make
$\mu(x,y)p(x,y)y' + \mu(x,y)q(x,y)=0$ exact, in which case this new
equation will be solved as above.
\beginmaximasession
intfactorode:(2*x*y - exp(-2*y))*diff(y,x) + y =0;
ode2(intfactorode,y,x);
\maximatexsession
\C18.  intfactorode:(2*x*y - exp(-2*y))*diff(y,x) + y =0; \\
\D18.   \left(2\*x\*y-e^ {- 2\*y }\right)\*\left({{d}\over{d\*x}}\*y
 \right)+y=0 \\
\C19.  ode2(intfactorode,y,x); \\
\D19.   x\*e^{2\*y}-\log y=\mathrm{\%C} \\
\endmaximasession

\smallskip

\noindent
\textit{Homogeneous.}\quad
A first order differential equation is \textit{homogeneous} if it can
be put in the form $y'=F(y/x)$.  In this case, the substitution
$v=y/x$ will transform the equation into the separable equation
$xv'+v=F(v)$, which can be solved as above.
\beginmaximasession
homode:diff(y,x) = (y/x)^2 + 2*(y/x);
ode2(homode,y,x);
\maximatexsession
\C20.  homode:diff(y,x) = (y/x)^2 + 2*(y/x); \\
\D20.   {{d}\over{d\*x}}\*y={{y^{2}}\over{x^{2}}}+{{2\*y}\over{x}} \\
\C21.  ode2(homode,y,x); \\
\D21.   -{{x\*y+x^{2}}\over{y}}=\mathrm{\%C} \\
\endmaximasession

\smallskip

\noindent
\textit{Bernoulli.}\quad
The equation $y'+p(x)y=q(x)y^n$, $n \ne 0,1$, is called
\textit{Bernoulli's equation} with index $n$. The transformation
$v=y^{1-n}$ will transform Bernoulli's equation into the linear
equation $v' + (1-n)p(x)v = (1-n)q(x)$, which can be solved as above. 
\beginmaximasession
berode:diff(y,x) + (2/x)*y = (1/x^2)* y^3;
ode2(berode, y, x);
\maximatexsession
\C22.  berode:diff(y,x) + (2/x)*y = (1/x^2)* y^3; \\
\D22.   {{d}\over{d\*x}}\*y+{{2\*y}\over{x}}={{y^{3}}\over{x^{2}}} \\
\C23.  ode2(berode, y, x); \\
\D23.   y={{1}\over{\sqrt{{{2}\over{5\*x^{5}}}+\mathrm{\%C}}\*x^{2}}} \\
\endmaximasession

\smallskip

\noindent
\textit{General Homogeneous.}\quad
A first order differential equation is said to be \textit{general
  homogeneous} of index $n$ if it can be written in the form $y' =
(y/x)G(yx^n)$.  In this case, a solution is given implicitly by
$x=ce^{I(yx^n)}$, where $I(u)$ is an antiderivative of $1/(u(n+G(u)))$
and $c$ is an arbitrary constant. (It may or may not be possible to
solve for $y$ explicitly.)
%\beginmaximasession
%genhomode:x*diff(y(x),x) = y(x)*(y(x)*x^2);
%ode2(genhomode, y(x), x);
%\endmaximasession

\medskip

If the differential equation is second order, then \texttt{ode2} will
determine if the equation is linear or not.  In the linear case,
when the equation can be written $y'' + p(x)y' + q(x)y = r(x)$,
\texttt{ode2} will try to solve the equation by first solving the
homogeneous part, $y'' + p(x)y' + q(x)y = 0$.
The general solution of the homogeneous part
will be of the form $y = k_1y_1 + k_2y_2$ for arbitrary constants $k_1$ and
$k_2$.  If $r(x) \ne 0$, \texttt{ode2} will then use variation of
parameters to find a particular solution $y_p$ of the original
equation.  The general solution of the full equation will then be 
$y=k_1y_1 + k_2y_2 + y_p$.
To solve the homogeneous part, \texttt{ode2} will check to see if the
equation falls into one of the following categories, in which case 
the equation will be solved appropriately.

\medskip

\noindent
\textit{Constant Coefficients.}\quad
If the differential equation has constant coefficients, and so is of
the form $y'' + ay' + by=0$, then the solution is 
$y=k_1 e^{r_1x} + k_2 e^{r_2x}$, where $r_1$ and $r_2$ are the
solutions of $r^2 + ar + b=0$. In case $r^2 + ar + b=0$ has a double
root, the solution of the differential equation is $y=k_1e^{rx} + k_2
xe^{rx}$. In some cases where the equation doesn't have constant
coefficients, \texttt{ode2} will attempt to use a simple
transformation to reduce it to constant coefficents.
\beginmaximasession
ccode1: diff(y,x,2) - 3*diff(y,x) + 2*y=0;
ccode2: diff(y,x,2) - 4*diff(y,x) + 4*y=0;
ode2(ccode1, y, x);
ode2(ccode2, y, x);
\maximatexsession
\C24.  ccode1: diff(y,x,2) - 3*diff(y,x) + 2*y=0; \\
\D24.   {{d^{2}}\over{d\*x^{2}}}\*y-3\*\left({{d}\over{d\*x}}\*y\right)
 +2\*y=0 \\
\C25.  ccode2: diff(y,x,2) - 4*diff(y,x) + 4*y=0; \\
\D25.   {{d^{2}}\over{d\*x^{2}}}\*y-4\*\left({{d}\over{d\*x}}\*y\right)
 +4\*y=0 \\
\C26.  ode2(ccode1, y, x); \\
\D26.   y=\mathrm{\%K1}\*e^{2\*x}+\mathrm{\%K2}\*e^{x} \\
\C27.  ode2(ccode2, y, x); \\
\D27.   y=\left(\mathrm{\%K2}\*x+\mathrm{\%K1}\right)\*e^{2\*x} \\
\endmaximasession

\smallskip

\noindent
\textit{Exact.}\quad
A second order differential equation is \textit{exact} if it can be written in
the form $[f(x)y']' + [g(x)y]' = 0$.  Integrating this equation will
reduce it to a first order differential equation, which can be solved
as above.
\beginmaximasession
exactode2: x^2*diff(y,x,2) + x*diff(y,x) - y =0;
ode2(exactode2, y,x);
\maximatexsession
\C28.  exactode2: x^2*diff(y,x,2) + x*diff(y,x) - y =0; \\
\D28.   x^{2}\*\left({{d^{2}}\over{d\*x^{2}}}\*y\right)+x\*\left({{d
 }\over{d\*x}}\*y\right)-y=0 \\
\C29.  ode2(exactode2, y,x); \\
\D29.   y=\mathrm{\%K2}\*x-{{\mathrm{\%K1}}\over{2\*x}} \\
\endmaximasession

\smallskip

\noindent
\textit{Euler.}\quad
The equation $x^2y'' + axy' + by=0$ is \textit{Euler's equation}.  
The solution is given by $y=k_1x^{r_1} + k_2x^{r_2}$, where $r_1$ and
$r_2$ are solutions of $r(r-1) + ar + b=0$.
In case $r(r-1) + ar + b=0$ has a double root,
the solution is given by $y=k_1x^{r} + k_2\ln(x)x^{r}$.
\beginmaximasession
eulerode1: x^2*diff(y,x,2) + 4*x*diff(y,x) + 2*y = 0;
eulerode2: x^2*diff(y,x,2) + 5*x*diff(y,x) + 4*y = 0;
ode2(eulerode1, y, x);
ode2(eulerode2, y, x);
\maximatexsession
\C30.  eulerode1: x^2*diff(y,x,2) + 4*x*diff(y,x) + 2*y = 0; \\
\D30.   x^{2}\*\left({{d^{2}}\over{d\*x^{2}}}\*y\right)+4\*x\*\left({{d
 }\over{d\*x}}\*y\right)+2\*y=0 \\
\C31.  eulerode2: x^2*diff(y,x,2) + 5*x*diff(y,x) + 4*y = 0; \\
\D31.   x^{2}\*\left({{d^{2}}\over{d\*x^{2}}}\*y\right)+5\*x\*\left({{d
 }\over{d\*x}}\*y\right)+4\*y=0 \\
\C32.  ode2(eulerode1, y, x); \\
\D32.   y={{\mathrm{\%K1}}\over{x}}+{{\mathrm{\%K2}}\over{x^{2}}} \\
\C33.  ode2(eulerode2, y, x); \\
\D33.   y={{\mathrm{\%K2}\*\log x+\mathrm{\%K1}}\over{x^{2}}} \\
\endmaximasession

\smallskip

\noindent
\textit{Bessel's Equation.}\quad
The equation $x^2y'' + xy' + (x^2-\nu^2)y=0$ is called \textit{Bessel's
equation} of order $\nu$.  For $\nu = 1/2$, the solution is
$y=k_1\sin(x)/\sqrt{x} + k_2\cos(x)/\sqrt{x}$; 
for integer $\nu$, the answer will be 
$y=k_1 Y_\nu(x) + k_2 J_\nu(x)$, where
$J_\nu$ and $Y_\nu$ are the Bessel functions of the first and second
kind. 
\beginmaximasession
besselode1:x^2*diff(y,x,2) + x*diff(y,x) + (x^2 - 1/4)*y=0;
besselode2:x^2*diff(y,x,2) + x*diff(y,x) + (x^2 - 4)*y=0;
ode2(besselode1, y, x);
ode2(besselode2, y, x);
\maximatexsession
\C34.  besselode1:x^2*diff(y,x,2) + x*diff(y,x) + (x^2 - 1/4)*y=0; \\
\D34.   x^{2}\*\left({{d^{2}}\over{d\*x^{2}}}\*y\right)+x\*\left({{d
 }\over{d\*x}}\*y\right)+\left(x^{2}-{{1}\over{4}}\right)\*y=0 \\
\C35.  besselode2:x^2*diff(y,x,2) + x*diff(y,x) + (x^2 - 4)*y=0; \\
\D35.   x^{2}\*\left({{d^{2}}\over{d\*x^{2}}}\*y\right)+x\*\left({{d
 }\over{d\*x}}\*y\right)+\left(x^{2}-4\right)\*y=0 \\
\C36.  ode2(besselode1, y, x); \\
\D36.   y={{\mathrm{\%K1}\*\sin x+\mathrm{\%K2}\*\cos x}\over{\sqrt{x}
 }} \\
\C37.  ode2(besselode2, y, x); \\
\D37.   y=\mathrm{\%K2}\*\mathrm{\%Y}_{2}(x)+\mathrm{\%K1}\*
 \mathrm{\%J}_{2}(x) \\
\endmaximasession
\noindent
\texttt{ode2} can also handle translates of Bessel's equation; i.e., 
differential equations of the form
$(x-a)^2y'' + (x-a)y' + ((x-a)^2-\nu^2)y=0$
\beginmaximasession
besselode3:(x-1)^2*diff(y,x,2) + (x-1)*diff(y,x) + ((x-1)^2 - 4)*y=0;
ode2(besselode3, y, x);
\maximatexsession
\C38.  besselode3:(x-1)^2*diff(y,x,2) + (x-1)*diff(y,x) + ((x-1)^2 - 4)*y=0; \\
\D38.   \left(x-1\right)^{2}\*\left({{d^{2}}\over{d\*x^{2}}}\*y\right)+
 \left(x-1\right)\*\left({{d}\over{d\*x}}\*y\right)+\left(\left(x-1
 \right)^{2}-4\right)\*y=0 \\
\C39.  ode2(besselode3, y, x); \\
\D39.   y=\mathrm{\%K2}\*\mathrm{\%Y}_{2}(x-1)+\mathrm{\%K1}\*
 \mathrm{\%J}_{2}(x-1) \\
\endmaximasession

\medskip

If \texttt{ode2} successfully solves the homogeneous part of an
inhomogeneous equation, it then tries to find a particular solution
using variation of parameters.

\medskip

\noindent
\textit{Variation of Parameters.}\quad
If $y=k_1y_1 + k_2y_2$ is the general solution of
$y'' + p(x)y' + q(x)y = 0$,  then a particular solution 
of $y'' + p(x)y' + q(x)y = r(x)$ can
be found by replacing the arbitrary constants $k_1$ and $k_2$ with
arbitrary functions $u_1$ and $u_2$, and looking for a solution of the
form $y=u_1y_1 + u_2y_2$.  One such solution is given if $u_1$ and
$u_2$ are antiderivatives of $-y_2r/(y_1y_2' - y_2y_1')$ and
$y_1r/(y_1y_2' - y_2y_1')$, respectively.
\beginmaximasession
varparode:diff(y,x,2) + 2*diff(y,x) + y = exp(x);
ode2(varparode,y,x);
\maximatexsession
\C40.  varparode:diff(y,x,2) + 2*diff(y,x) + y = exp(x); \\
\D40.   {{d^{2}}\over{d\*x^{2}}}\*y+2\*\left({{d}\over{d\*x}}\*y\right)
 +y=e^{x} \\
\C41.  ode2(varparode,y,x); \\
\D41.   y={{e^{x}}\over{4}}+\left(\mathrm{\%K2}\*x+\mathrm{\%K1}\right)
 \*e^ {- x } \\
\endmaximasession

\medskip

In case the second order differential equation is not linear,
\texttt{ode2} will check to see if either the dependent variable or
the independent variable is missing, in which case one of the following two
methods will be used.

\smallskip

\noindent
\textit{Missing dependent variable.}\quad
If the undifferentiated dependent variable $y$ is not present in a
second order differential equation, the substitution $v=y'$, $v'=y''$
will reduce the differential equation to first order.  This can be
solved as above. Once $v$ is obtained, $y$ can be obtained by
integrating $v$. 
\beginmaximasession
noyode:x*diff(y,x,2) + (diff(y,x))^2=0;
ode2(noyode,y,x);
\maximatexsession
\C42.  noyode:x*diff(y,x,2) + (diff(y,x))^2=0; \\
\D42.   x\*\left({{d^{2}}\over{d\*x^{2}}}\*y\right)+
 \mathrm{\%DERIVATIVE}^{2}\left(\left(y,\linebreak[0]x,\linebreak[0]1
 \right)\right)=0 \\
\C43.  ode2(noyode,y,x); \\
\D43.   y=\int {{{1}\over{\log x+\mathrm{\%K1}}}}{\;dx}+\mathrm{\%K2} \\
\endmaximasession

\smallskip

\noindent
\textit{Missing independent variable.}\quad
If the independent variable $x$ is not present in a second order
differential equation, then making the dependent variable $y$ a
temporary independent variable and using the substitution $v=y'$,
$v'=y''$, the equation can again be reduced to first order.
Since the derivatives are taken with respect to $x$, however, 
the new equation will involve three variables.  This can be resolved
by noting that $v'=\textrm{d}v/\textrm{d}x =
(\textrm{d}v/\textrm{d}y)(\textrm{d}y/\textrm{d}x)  
= (\textrm{d}v/\textrm{d}y) v$, and so $v'= \textrm{d}v/\textrm{d}x$
can be replaced by $v\textrm{d}v/textrm{d}y$.  This will result in a
first order differential equation with dependent variable $v$ and
independent variable $y$.  This can be solved as above.
Once $v$ is obtained (in terms of $y$), $y$ is a solution of the
differential equation $y'=v(y)$, which can be solved as above.
\beginmaximasession
noxode: y*diff(y,x,2) + (diff(y,x))^2 = 0;
ode2(noxode,y,x);
\maximatexsession
\C44.  noxode: y*diff(y,x,2) + (diff(y,x))^2 = 0; \\
\D44.   y\*\left({{d^{2}}\over{d\*x^{2}}}\*y\right)+
 \mathrm{\%DERIVATIVE}^{2}\left(\left(y,\linebreak[0]x,\linebreak[0]1
 \right)\right)=0 \\
\C45.  ode2(noxode,y,x); \\
\D45.   {{y^{2}}\over{2\*\mathrm{\%K1}}}=x+\mathrm{\%K2} \\
\endmaximasession

\subsubsection{Information on the Method}

The \texttt{ode2} routine will store information about the method used
to solve the differential equations in various variables.
The variable \texttt{method} will keep track of the method used to
solve the differential equations.
\beginmaximasession
ode2(separableode, y, x);
method;
\maximatexsession
\C46.  ode2(separableode, y, x); \\
\D46.   y^{2}-y=x^{3}+2\*x^{2}+2\*x+\mathrm{\%C} \\
\C47.  method; \\
\D47.   \mathrm{SEPARABLE} \\
\endmaximasession
\noindent
In the case where an integrating factor was used to make a
differential equation exact, the variable \texttt{intfactor} will be
the integrating factor used.
\beginmaximasession
ode2(intfactorode, y, x);
method;
intfactor;
\maximatexsession
\C48.  ode2(intfactorode, y, x); \\
\D48.   x\*e^{2\*y}-\log y=\mathrm{\%C} \\
\C49.  method; \\
\D49.   \mathrm{EXACT} \\
\C50.  intfactor; \\
\D50.   {{e^{2\*y}}\over{y}} \\
\endmaximasession
\noindent
When Bernoulli's equation or a generalized homogeneous equation is
solved, the variable \texttt{odeindex} will be the index of the
equation.
\beginmaximasession
ode2(berode, y, x);
method;
odeindex;
\maximatexsession
\C51.  ode2(berode, y, x); \\
\D51.   y={{1}\over{\sqrt{{{2}\over{5\*x^{5}}}+\mathrm{\%C}}\*x^{2}}} \\
\C52.  method; \\
\D52.   \mathrm{BERNOULLI} \\
\C53.  odeindex; \\
\D53.   3 \\
\endmaximasession
\noindent
When an inhomogeneous second degree linear differential equation is
solved, the variable \texttt{yp} will be the particular solution
arrived at by variation of parameters.
\beginmaximasession
ode2(varparode, y, x);
method;
yp;
\maximatexsession
\C54.  ode2(varparode, y, x); \\
\D54.   y={{e^{x}}\over{4}}+\left(\mathrm{\%K2}\*x+\mathrm{\%K1}\right)
 \*e^ {- x } \\
\C55.  method; \\
\D55.   \mathrm{VARIATIONOFPARAMETERS} \\
\C56.  yp; \\
\D56.   {{e^{x}}\over{4}} \\
\endmaximasession


\subsection{Solving Ordinary Differential Equations: \texttt{desolve}}
\label{subsec:desolve}

\subsubsection{Using \texttt{desolve}}

Maxima can solve systems of linear ordinary differential equation
with constant coefficients
using the  \texttt{desolve} command. The differential
equations must be given using functional notation, rather than with
dependent variables; i.e., \texttt{diff(y(x),x)} would have to be used
rather than \texttt{diff(y,x)} to denote the derivative.  
The command 
\texttt{desolve(}\textit{delist}\texttt{, }\textit{fnlist}\texttt{)},
will solve the system of differential equations given by the list
\textit{delist}, where \textit{fnlist} is a list of the functions to
be solved for.
\beginmaximasession
de1:diff(f(x),x)=diff(g(x),x)+sin(x);
de2:diff(g(x),x,2)=diff(f(x),x) - cos(x);
desolve([de1,de2],[f(x),g(x)]);
\maximatexsession
\C57.  de1:diff(f(x),x)=diff(g(x),x)+sin(x); \\
\D57.   {{d}\over{d\*x}}\*f\left(x\right)={{d}\over{d\*x}}\*g\left(x
 \right)+\sin x \\
\C58.  de2:diff(g(x),x,2)=diff(f(x),x) - cos(x); \\
\D58.   {{d^{2}}\over{d\*x^{2}}}\*g\left(x\right)={{d}\over{d\*x}}\*f
 \left(x\right)-\cos x \\
\C59.  desolve([de1,de2],[f(x),g(x)]); \\
\D59.   \left[ f\left(x\right)=e^{x}\*\left(\left.{{d}\over{d\*x}}\*g
 \left(x\right)\right|_{x=0}\right)-\left.{{d}\over{d\*x}}\*g\left(x
 \right)\right|_{x=0}+f\left(0\right),\linebreak[0]g\left(x\right)=e
 ^{x}\*\left(\left.{{d}\over{d\*x}}\*g\left(x\right)\right|_{x=0}
 \right)-\left.{{d}\over{d\*x}}\*g\left(x\right)\right|_{x=0}+\cos x+
 g\left(0\right)-1 \right]  \\
\endmaximasession
\noindent
A single differential equation of a single unknown function can also
be solved by \texttt{desolve}; in this case, it isn't  
necessary to enter them as lists.
\beginmaximasession
de3:'diff(f(x),x,2)+ f(x) = 2*x;
desolve(de3, f(x));
\maximatexsession
\C60.  de3:'diff(f(x),x,2)+ f(x) = 2*x; \\
\D60.   {{d^{2}}\over{d\*x^{2}}}\*f\left(x\right)+f\left(x\right)=2\*x \\
\C61.  desolve(de3, f(x)); \\
\D61.   f\left(x\right)=\sin x\*\left(\left.{{d}\over{d\*x}}\*f\left(x
 \right)\right|_{x=0}-2\right)+f\left(0\right)\*\cos x+2\*x \\
\endmaximasession

\subsubsection{Initial Conditions}

Initial conditions can be specified for solutions given by
\texttt{desolve} using the \texttt{atvalue} command.
The conditions, however, can only be given at \texttt{0}, and
must be given before the equations are solved.
\beginmaximasession
atvalue(f(x),x=0,1);
atvalue(g(x),x=0,2);
atvalue(diff(g(x),x),x=0,3);
desolve([de1,de2],[f(x),g(x)]);
\maximatexsession
\C62.  atvalue(f(x),x=0,1); \\
\D62.   1 \\
\C63.  atvalue(g(x),x=0,2); \\
\D63.   2 \\
\C64.  atvalue(diff(g(x),x),x=0,3); \\
\D64.   3 \\
\C65.  desolve([de1,de2],[f(x),g(x)]); \\
\D65.   \left[ f\left(x\right)=3\*e^{x}-2,\linebreak[0]g\left(x\right)=
 \cos x+3\*e^{x}-2 \right]  \\
\endmaximasession

\subsubsection{\texttt{desolve} Method}

The \texttt{desolve} routine uses the LaPlace transform to solve the
systems of differential equations.
If $f(t)$ is defined for all $t \ge 0$, then the LaPlace transform of
$f$ is given by $F(s)={\cal L}\{f(t)\} = \int_0^\infty
e^{-st}f(t)\textrm{d}t$.   The LaPlace transform has the useful
property that a derivative is transformed into multiplication by the
variable; if ${\cal L}\{f(t)\} = F(s)$, then 
${\cal L}\{f'(t)\} = sF(s)-f(0)$.  The LaPlace transform can thus
transform a system of linear differential equations into a system of
ordinary equations.  
(Note, however, that the LaPlace transform will transform
multiplication by a variable into differentiation; 
if ${\cal L}\{f(t)\} = F(s)$, then ${\cal L}\{tf(t)\} = -F'(s)$. 
The original differential equations need to have constant
coefficients to prevent this.)
If this new system can be solved, the LaPlace
tranform can be inverted to give solutions of the original system of
differential equations.
