Overview
Giac provides comprehensive power series expansion capabilities including Taylor series, Laurent series, limits, and asymptotic analysis using sparse polynomial representation.
Taylor Series
series
Compute series expansion of an expression.
gen series ( const gen & e , const identificateur & x , const gen & lim_point ,
int ordre , int direction , GIAC_CONTEXT );
gen series ( const gen & e , const gen & vars , const gen & lim_point ,
int ordre , int direction , GIAC_CONTEXT );
gen series ( const gen & e , const gen & vars , const gen & lim_point ,
const gen & ordre , GIAC_CONTEXT );
gen _series ( const gen & args , GIAC_CONTEXT );
Point of expansion (usually 0 for Maclaurin series)
Order of expansion (number of terms)
Direction: 0 (bidirectional), 1 (right), -1 (left)
Series expansion with order term O(x^n)
Taylor series at 0
Taylor series at arbitrary point
Multivariate series
// Expand sin(x) around x=0 to order 5
identificateur x ( "x" );
gen result = series ( sin (x), x, 0 , 5 , 0 , context0);
// Returns: x - x^3/6 + O(x^5)
taylor
Compute Taylor series coefficients.
bool taylor ( const gen & f_x , const gen & x , const gen & lim_point ,
int ordre , vecteur & v , GIAC_CONTEXT );
Output: vector of Taylor coefficients
True if expansion succeeded
Sparse Polynomial Representation
Giac uses sparse_poly1 for efficient series representation.
sparse_poly1 Conversions
sparse_poly1 vecteur2sparse_poly1 ( const vecteur & v );
void vecteur2sparse_poly1 ( const vecteur & v , sparse_poly1 & p );
bool sparse_poly12vecteur ( const sparse_poly1 & p , vecteur & v , int & shift );
gen sparse_poly12gen ( const sparse_poly1 & p , const gen & x , gen & remains ,
bool with_order_size );
sparse_poly1 gen2spol1 ( const gen & g );
porder
Get the order of a series (valuation of remainder term).
gen porder ( const sparse_poly1 & a );
Order of the series, or plus_inf if exact
ptruncate
Truncate a series to specified order.
bool ptruncate ( sparse_poly1 & p , const gen & ordre , GIAC_CONTEXT );
Series Arithmetic
Addition and Subtraction
bool padd ( const sparse_poly1 & a , const sparse_poly1 & b ,
sparse_poly1 & res , GIAC_CONTEXT );
sparse_poly1 spadd ( const sparse_poly1 & a , const sparse_poly1 & b , GIAC_CONTEXT );
sparse_poly1 spsub ( const sparse_poly1 & a , const sparse_poly1 & b , GIAC_CONTEXT );
bool pneg ( const sparse_poly1 & a , sparse_poly1 & res , GIAC_CONTEXT );
sparse_poly1 spneg ( const sparse_poly1 & a , GIAC_CONTEXT );
Multiplication
bool pmul ( const sparse_poly1 & a , const gen & b , sparse_poly1 & res ,
GIAC_CONTEXT );
bool pmul ( const gen & b , const sparse_poly1 & a , sparse_poly1 & res ,
GIAC_CONTEXT );
bool pmul ( const sparse_poly1 & a , const sparse_poly1 & b , sparse_poly1 & res ,
bool n_truncate , const gen & n_valuation , GIAC_CONTEXT );
sparse_poly1 spmul ( const sparse_poly1 & a , const sparse_poly1 & b , GIAC_CONTEXT );
Division
bool pdiv ( const sparse_poly1 & a , const sparse_poly1 & b , sparse_poly1 & res ,
int ordre , GIAC_CONTEXT );
bool pdiv ( const sparse_poly1 & a , const gen & b , sparse_poly1 & res ,
GIAC_CONTEXT );
sparse_poly1 spdiv ( const sparse_poly1 & a , const sparse_poly1 & b , GIAC_CONTEXT );
// (1 + x + x²/2) * (1 - x + x²)
sparse_poly1 s1 = gen2spol1 ( 1 + x + pow (x, 2 ) / 2 );
sparse_poly1 s2 = gen2spol1 ( 1 - x + pow (x, 2 ));
sparse_poly1 result = spmul (s1, s2, context0);
Power
bool ppow ( const sparse_poly1 & base , int m , int ordre , sparse_poly1 & res ,
GIAC_CONTEXT );
bool ppow ( const sparse_poly1 & base , const gen & e , int ordre , int direction ,
sparse_poly1 & res , GIAC_CONTEXT );
sparse_poly1 sppow ( const sparse_poly1 & a , const gen & b , GIAC_CONTEXT );
General exponent (can be fractional)
Series Composition
pcompose
Compose series: compute f(g(x)) where both f and g are series.
bool pcompose ( const vecteur & v , const sparse_poly1 & p , sparse_poly1 & res ,
GIAC_CONTEXT );
Coefficients of outer series f
Output: composed series f(g(x))
Series Integration and Reversion
pintegrate
Integrate a series term by term.
bool pintegrate ( sparse_poly1 & p , const gen & t , GIAC_CONTEXT );
Series to integrate (modified in place)
prevert
Compute compositional inverse (reversion) of a series.
bool prevert ( const sparse_poly1 & p_orig , sparse_poly1 & q , GIAC_CONTEXT );
Series y = f(x) to invert
Output: inverse series x = f⁻¹(y)
Given y = f(x), finds x = g(y) such that f(g(y)) = y.
// If y = x + x², find x in terms of y
// Result: x = y - y² + 2y³ - 5y⁴ + ...
gen _revert ( const gen & args , GIAC_CONTEXT );
Limits
limit
Compute limits using series expansion.
gen limit ( const gen & e , const identificateur & x , const gen & lim_point ,
int direction , GIAC_CONTEXT );
gen _limit ( const gen & args , GIAC_CONTEXT );
Direction: 0 (two-sided), 1 (right/+), -1 (left/-)
Limit value (may be a number, ±∞, or undefined)
// lim(x→0) sin(x)/x = 1
gen result = limit ( sin (x) / x, x, 0 , 0 , context0);
// lim(x→∞) (1 + 1/x)^x = e
gen result2 = limit ( pow ( 1 + 1 / x, x), x, plus_inf, 0 , context0);
// One-sided limit: lim(x→0⁺) ln(x) = -∞
gen result3 = limit ( ln (x), x, 0 , 1 , context0);
limit_symbolic_preprocess
Preprocess expression before limit computation.
gen limit_symbolic_preprocess ( const gen & e0 , const identificateur & x ,
const gen & lim_point , int direction ,
GIAC_CONTEXT );
Special Series Functions
bounded_function
Marker for bounded functions in asymptotic analysis.
gen _bounded_function ( const gen & args , GIAC_CONTEXT );
gen bounded_function ( GIAC_CONTEXT );
Represents functions that remain bounded (used in Big-O notation).
euler_mac_laurin
Euler-MacLaurin formula for sum-to-integral conversion.
gen _euler_mac_laurin ( const gen & args , GIAC_CONTEXT );
bool convert_to_euler_mac_laurin ( const gen & g , const identificateur & n ,
gen & res , GIAC_CONTEXT );
Arguments: [expression, antiderivative, variable, lower_bound, upper_bound]
Converts sums to integrals with correction terms, useful for asymptotic analysis.
Low-Level Series Functions
series__SPOL1
Internal series expansion returning sparse_poly1.
bool series__SPOL1 ( const gen & e , const identificateur & x ,
const gen & lim_point , int ordre , int direction ,
sparse_poly1 & s , GIAC_CONTEXT );
sparse_poly1 series__SPOL1 ( const gen & e , const identificateur & x ,
const gen & lim_point , int ordre , int direction ,
GIAC_CONTEXT );
pnormal
Normalize a series (simplify coefficients).
bool pnormal ( sparse_poly1 & v , GIAC_CONTEXT );
pshift
Shift the variable in a series.
bool pshift ( const sparse_poly1 & a , const gen & b , sparse_poly1 & res ,
GIAC_CONTEXT );
Replaces x with x+b in the series.
Utility Functions
is_analytic
Check if a function is analytic.
bool is_analytic ( const gen & g );
True if the function is analytic (has convergent Taylor series)
lcmdeno
Clear denominators in series coefficients.
void lcmdeno ( vecteur & v , gen & e , GIAC_CONTEXT );
void lcmdeno ( sparse_poly1 & v , gen & e , GIAC_CONTEXT );
Vector or series to clear denominators from
Output: LCM of all denominators
Notes
Series expansions are computed using automatic differentiation and pattern matching
The sparse_poly1 representation efficiently handles series with many zero coefficients
Laurent series (with negative powers) are supported
Multivariate series expansions are available
The order term O(x^n) tracks truncation accuracy
Series arithmetic automatically propagates order terms
Limits are computed by series expansion when possible, falling back to other methods
Direction parameter is important for functions with discontinuities