
% Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are
% met:
%
%     - Redistributions of source code must retain the above copyright
%       notice, this list of conditions and the following disclaimer.
%
%     - Redistributions in binary form must reproduce the above copyright
%       notice, this list of conditions and the following disclaimer in
%       the documentation and/or other materials provided with the
%       distribution.
%
%     - Neither the name of The Numerical ALgorithms Group Ltd. nor the
%       names of its contributors may be used to endorse or promote products
%       derived from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
% TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
% OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES-- LOSS OF USE, DATA, OR
% PROFITS-- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.



% lodo.htex
\spadtype{LinearOrdinaryDifferentialOperator(A, diff)} is the domain of linear
\index{operator!linear ordinary differential}
ordinary differential operators with coefficients in a ring
\spad{A} with a given derivation.
%This includes the cases of operators which are polynomials in \spad{D}
%acting upon scalar or vector expressions of a single variable.
%The coefficients of the operator polynomials can be integers, rational
%functions, matrices or elements of other domains.
\showBlurb{LinearOrdinaryDifferentialOperator}

\head{subsection}{Differential Operators with Series Coefficients}{ugxLinearOrdinaryDifferentialOperatorSeries}
% ----------------------------------------------------------------------

\noindent
{\bf Problem:}
Find the first few coefficients of \spad{exp(x)/x^i} of \spad{Dop(phi)} where
\begin{verbatim}
Dop := D^3 + G/x^2 * D + H/x^3 - 1
phi := sum(s[i]*exp(x)/x^i, i = 0..)
\end{verbatim}

\noindent
{\bf Solution:}
\xtc{
Define the differential.
}{
\spadcommand{Dx: LODO(EXPR INT, f +-> D(f, x)) \bound{Dxd}}
}
\xtc{
}{
\spadcommand{Dx := D() \free{Dxd}\bound{Dx}}
}
\xtc{
Now define the differential operator \spad{Dop}.
}{
\spadcommand{Dop:= Dx^3 + G/x^2*Dx + H/x^3 - 1 \free{Dx}\bound{Dop}}
}
\xtc{
The first $n$ coefficients can be obtained in the following way.
}{
\begin{spadsrc}
firstCoefficients(n) ==
  phi := reduce(+, [subscript(s,[i])*exp(x)/x^i for i in 0..n])
  phi1 := retract((Dop(phi) * x^(n+3) / exp x))@Polynomial(Integer)
  phi2 := phi1 :: UnivariatePolynomial(x, Polynomial Integer)
  sys := [coefficient(phi2, (n+3-i)::NNI) for i in 2..n+1]
  solve(sys, [subscript(s,[i]) for i in 1..n])
\end{spadsrc}
}
\xtc{
Evaluate this function for several values of \spad{n}.
}{
\spadcommand{firstCoefficients(3)}
}
\xtc{
}{
\spadcommand{firstCoefficients(4)}
}
\xtc{
}{
\spadcommand{firstCoefficients(7)}
}

% ----------------------------------------------------------------------
