1.Introduction
Power series are implemented within the class series from series.hpp.
#include <numerix/rational.hpp>
#include <algebramix/series.hpp>
series<rational> z (rational (1), 1); // variable z
series<rational> f = 1 / (1 - z);
mmout << f[10] << "\n"; |
Series are implemented in a lazy way, which means that the precision
has not to be specified in advance. Computations are actually done
when a coefficient is actually needed.
The precision used for printing the power series can be set to n in the following way:
series<C,V>::set_output_order (n); |
Instead of printing an approximation of the series, it is possible to
display the formula it has been built from, as follows:
series<C,V>::set_formula_output (true); |
Withing equality test the precision to be taken into account can be
set to n via:
series<C,V>::set_cancel_order (n); |
The name of the variable to be printed can be set to z with the following command:
series<C,V>::set_variable_name ("z"); |
2.Naive algorithms
Naive algorithms for power series are implemented in series_naive.hpp. For instance
the product implemented therein has a quadratic cost.
Over numerical types, elementary functions are available from series_elementary.hpp.
3.Relaxed algorithm
The relaxed product for power series is implemented in series_relaxed.hpp.
#include <numerix/rational.hpp>
#include <algebramix/series.hpp>
#include <algebramix/series_relaxed.hpp>
#define V series_relaxed<series_naive>
series<rational,V> z (rational (1), 1); // variable z
series<rational,V> f = 1 / (1 - z);
mmout << z[10] << "\n"; |
The relaxed product has a softly linear cost.
4.Recursive series
A series is said to be recursive if it
satisfies an equation that allows to compute
the -th coefficient of
as the -th coefficient of
with the only knowledge of the first
coefficients of , whenever
is larger than an integer called the
index.
For example +1, with
can be implemented as follows:
template<typename C, typename V>
struct example_series_rep : recursive_series_rep<C,V>
example_series_rep () {}
syntactic expression (const syntactic& z) const {
return apply ("example", z); }
series<C,V> initialize () {
series<C,V> f= this->me ();
this->initial (0)= C(1);
return lshiftz (square (f), 1) + C(1); }
template<typename C, typename V>
example_series () {
series_rep<C,V>* rep= new example_series_rep<C,V> ();
return recursive (series<C,V> (rep)); } |
On this example, the fact that the -th
coefficient of depends only on the first coefficients of is due to
the multiplication by . This multiplication
must be done using the left shift lshiftz
function, defined by lshiftz(f)[n]
returns f[n-1].
Otherwise when seeking a new coefficient f[n]
of , the recursive series mechanism would call
recursively f[n] and
fall into an infinite loop.
4.1.Polynomial regular root
Many commonly used series are recursive series. For example, a regular
series root of a polynomial ,
that is and , is a
recursive series.
The file series.hpp contains a template function
template<typename C, typename V, typename L> inline series<C,V>
polynomial_regular_root_init (const polynomial<L>& P, const C& init) |
which computes the unique regular root of
whose zeroth term is init.
This lifting of the solution from its first
coefficient is done by transforming the implicit equation into a recursive equation and by
applying the recursive series mechanism.
A variant slp_polynomial_regular_root
of this function for polynomials given as evaluation programs (or
straight-line program) can be found in series_carry_naive.hpp.
5.Implicit series
Implicit series are implemented in series_implicit.hpp.
6.Vectorial operations
Vectorial and matricial auxiliary functions are available from series_vector.hpp
and series_matrix.hpp respectively. They are useful for computing recursive vectors
of series, which is the generalization of recursive series. Commonly
used recursive vectors of series include in particular solutions of
invertible linear systems, regular roots of multivariate polynomials.
Linear system resolution over series can be found in the file series_carry_linear_algebra.hpp.
7.Mathemagix
interface
Mmx] |
use "algebramix";
type_mode? := true; |
Mmx] |
z == series (0 :> Rational, 1 :> Rational) |
:
:
:
© 2010 Romain Lebreton, Grégoire Lecerf
Permission is granted to copy, distribute and/or modify this document
under the terms of the
GNU General Public License. If you
don't have this file, write to the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston, MA 02111-1307, USA.