Skip to main content

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);
e
gen
required
Expression to expand
x
identificateur
required
Expansion variable
lim_point
gen
required
Point of expansion (usually 0 for Maclaurin series)
ordre
int
required
Order of expansion (number of terms)
direction
int
required
Direction: 0 (bidirectional), 1 (right), -1 (left)
return
gen
Series expansion with order term O(x^n)
// 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);
f_x
gen
required
Function to expand
x
gen
required
Variable
lim_point
gen
required
Expansion point
ordre
int
required
Order
v
vecteur&
required
Output: vector of Taylor coefficients
return
bool
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);
return
gen
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);
base
sparse_poly1
required
Base series
m
int
Integer exponent (m ≥ 0)
e
gen
General exponent (can be fractional)
ordre
int
required
Order to compute to

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);
v
vecteur
required
Coefficients of outer series f
p
sparse_poly1
required
Inner series g(x)
res
sparse_poly1&
required
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);
p
sparse_poly1&
required
Series to integrate (modified in place)
t
gen
required
Integration variable

prevert

Compute compositional inverse (reversion) of a series.
bool prevert(const sparse_poly1 & p_orig, sparse_poly1 & q, GIAC_CONTEXT);
p_orig
sparse_poly1
required
Series y = f(x) to invert
q
sparse_poly1&
required
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);
e
gen
required
Expression
x
identificateur
required
Variable
lim_point
gen
required
Limit point (can be ±∞)
direction
int
required
Direction: 0 (two-sided), 1 (right/+), -1 (left/-)
return
gen
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);
args
gen
required
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);
return
bool
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);
v
vecteur&
required
Vector or series to clear denominators from
e
gen&
required
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

Build docs developers (and LLMs) love