Skip to main content

Overview

Giac provides powerful integration capabilities including symbolic integration (using multiple algorithms like Risch), numerical integration (Romberg, Gauss quadrature), and special integration techniques for definite integrals.

Symbolic Integration

integrate

Main integration function supporting both indefinite and definite integrals.
gen integrate_gen(const gen & e, const gen & f, GIAC_CONTEXT);
gen integrate_id(const gen & e, const identificateur & x, GIAC_CONTEXT);
gen _integrate(const gen & args, GIAC_CONTEXT);
e
gen
required
Expression to integrate
x
identificateur
required
Integration variable
args
gen
For _integrate: [expr, var] or [expr, var, lower_bound, upper_bound]
return
gen
The integral (symbolic expression)
// ∫ x^2 dx
identificateur x("x");
gen expr = pow(x, 2);
gen result = integrate_id(expr, x, context0);
// Returns: x^3/3

integrate_gen_rem

Integration with remainder tracking.
gen integrate_gen_rem(const gen & e, const gen & x, gen & remains_to_integrate, 
                      int intmode, GIAC_CONTEXT);
e
gen
required
Expression to integrate
x
gen
required
Integration variable
remains_to_integrate
gen&
required
Output: parts that could not be integrated
intmode
int
required
Integration mode flags (bit 0: sqrt control, bit 1: step info, bit 2: surd replaced)

risch

Risch algorithm for symbolic integration (handles elementary functions).
gen risch(const gen & e_orig, const identificateur & x, 
          gen & remains_to_integrate, GIAC_CONTEXT);
gen _risch(const gen & g, GIAC_CONTEXT);
e_orig
gen
required
Expression to integrate
x
identificateur
required
Integration variable
remains_to_integrate
gen&
required
Output: non-elementary parts
return
gen
Elementary part of the integral
The Risch algorithm provides a complete solution for integration of elementary functions, determining whether an integral has an elementary form.

Numerical Integration

romberg

Romberg integration method for numerical approximation.
gen romberg(const gen & f0, const gen & x0, const gen & a, const gen & b, 
            const gen & eps, int nmax, GIAC_CONTEXT);
gen _romberg(const gen & args, GIAC_CONTEXT);
double rombergo(const gen & f, const gen & x, const gen & a, const gen & b, 
                int n, GIAC_CONTEXT);
double rombergt(const gen & f, const gen & x, const gen & a, const gen & b, 
                int n, GIAC_CONTEXT);
f0
gen
required
Function to integrate
x0
gen
required
Integration variable
a
gen
required
Lower bound
b
gen
required
Upper bound
eps
gen
required
Desired accuracy
nmax
int
required
Maximum number of iterations
// Numerically compute ∫₀^π sin(x) dx
gen f = sin(x);
gen result = romberg(f, x, 0, cst_pi, 1e-10, 20, context0);
// Returns: ≈ 2.0

gaussquad

Gauss quadrature for numerical integration.
gen _gaussquad(const gen & args, GIAC_CONTEXT);
args
gen
required
Arguments: [function, variable, lower_bound, upper_bound, num_points]
return
gen
Numerical approximation of the integral
Gauss quadrature provides highly accurate numerical integration using optimally chosen evaluation points.

evalf_int

General numerical integration with method selection.
gen evalf_int(const gen & f0, const gen & x0, const gen & a, const gen & b, 
              const gen & eps, int nmax, bool romberg_method, GIAC_CONTEXT, 
              bool exactcheck=true);
romberg_method
bool
required
If true, use Romberg method; otherwise use adaptive method
exactcheck
bool
Check for exact symbolic result first

Special Integration Functions

intgab

Definite integration with advanced techniques (residue theorem, symmetry).
bool intgab(const gen & g, const gen & x, const gen & a, const gen & b, 
            gen & res, GIAC_CONTEXT);
g
gen
required
Function to integrate
x
gen
required
Integration variable
a
gen
required
Lower bound
b
gen
required
Upper bound
res
gen&
required
Output: result of integration
return
bool
True if integration succeeded
This function uses special techniques like:
  • Residue theorem for complex integrals
  • Symmetry detection (even/odd functions)
  • Meromorphic function handling

linear_integrate

Integration using linearity.
gen linear_integrate(const gen & e, const gen & x, gen & remains_to_integrate, 
                     int intmode, GIAC_CONTEXT);
Decomposes the expression into linear terms and integrates term by term.

Utility Functions

is_constant_wrt

Check if an expression is constant with respect to a variable.
bool is_constant_wrt(const gen & e, const gen & x, GIAC_CONTEXT);

is_linear_wrt

Check if expression is linear in a variable and extract coefficients.
bool is_linear_wrt(const gen & e, const gen & x, gen & a, gen & b, GIAC_CONTEXT);
e
gen
required
Expression to check
x
gen
required
Variable
a
gen&
required
Output: coefficient of x (if linear)
b
gen&
required
Output: constant term (if linear)
Returns true if e = a*x + b.

is_quadratic_wrt

Check if expression is quadratic in a variable.
bool is_quadratic_wrt(const gen & e, const gen & x, gen & a, gen & b, gen & c, 
                      GIAC_CONTEXT);
Returns true if e = ax² + bx + c.

preval

Evaluate definite integral using fundamental theorem of calculus.
gen preval(const gen & f, const gen & x, const gen & a, const gen & b, 
           GIAC_CONTEXT);
Computes F(b) - F(a) where F is the antiderivative of f.

Summation

sum

Discrete summation (analogue of integration).
gen sum(const gen & e, const gen & x, gen & remains_to_sum, GIAC_CONTEXT);
gen sum(const gen & e, const gen & x, const gen & a, const gen & b, GIAC_CONTEXT);
gen _sum(const gen & args, GIAC_CONTEXT);
e
gen
required
Expression to sum
x
gen
required
Summation variable
a
gen
Lower bound
b
gen
Upper bound
// Σ(i=1 to n) i = n(n+1)/2
gen result = sum(i, i, 1, n, context0);

rational_sum

Summation of rational functions using Gosper’s algorithm.
bool rational_sum(const gen & e, const gen & x, gen & res, 
                  gen & remains_to_sum, bool allow_psi, GIAC_CONTEXT);

gosper

Gosper’s algorithm for hypergeometric summation.
bool gosper(const polynome & P, const polynome & Q, const polynome & R, 
            polynome & Y, gen & deno, GIAC_CONTEXT);

Integration by Parts

ibpdv

Integration by parts helper.
gen _ibpdv(const gen & args, GIAC_CONTEXT);
args
gen
required
Arguments for integration by parts setup

Notes

  • Symbolic integration attempts multiple algorithms (Risch, rational function decomposition, pattern matching)
  • Numerical methods are used when symbolic integration fails or for approximations
  • The Romberg method is efficient for smooth functions
  • Gauss quadrature excels for polynomial integrands
  • Special techniques handle improper integrals and singularities

Build docs developers (and LLMs) love