Skip to main content

Overview

Giac provides a comprehensive set of functions for symbolic differentiation, including ordinary derivatives, partial derivatives, gradients, and implicit differentiation.

Core Functions

derive

Compute the derivative of an expression with respect to a variable.
gen derive(const gen & e, const identificateur & i, GIAC_CONTEXT);
gen derive(const gen & e, const gen & vars, GIAC_CONTEXT);
gen derive(const gen & e, const gen & vars, const gen & nderiv, GIAC_CONTEXT);
e
gen
required
The expression to differentiate
i
identificateur
The variable to differentiate with respect to (single variable)
vars
gen
Variable or list of variables for differentiation
nderiv
gen
Order of derivative (for higher-order derivatives)
return
gen
The derivative of the expression
// Compute d/dx(x^2)
identificateur x("x");
gen expr = pow(x, 2);
gen result = derive(expr, x, context0);
// Returns: 2*x

grad

Compute the gradient of a scalar function (vector of partial derivatives).
gen _grad(const gen & args, GIAC_CONTEXT);
args
gen
required
Arguments: [expression, variables]
return
gen
Vector of partial derivatives (gradient)
// Compute gradient of f(x,y) = x^2 + y^2
gen f = pow(x, 2) + pow(y, 2);
gen vars = makevecteur(x, y);
gen result = _grad(makesequence(f, vars), context0);
// Returns: [2*x, 2*y]

function_diff

Differentiate a function definition.
gen _function_diff(const gen & g, GIAC_CONTEXT);
g
gen
required
Function to differentiate
return
gen
Derivative of the function

implicit_diff

Compute implicit differentiation for equations of the form F(x,y) = 0.
extern const unary_function_ptr * const at_implicit_diff;
Useful for finding dy/dx when y is defined implicitly as a function of x.
// For x^2 + y^2 = 1, find dy/dx
// Result: -x/y

Utility Functions

depend

Check if an expression depends on a variable.
bool depend(const gen & g, const identificateur & i);
g
gen
required
Expression to check
i
identificateur
required
Variable to check dependency on
return
bool
True if the expression depends on the variable

domain

Determine the domain of a function.
gen domain(const gen & f, const gen & x, int mode, GIAC_CONTEXT);
f
gen
required
Function expression
x
gen
required
Variable
mode
int
required
Domain computation mode

critical

Find critical points of a function.
gen critical(const gen & g, bool extrema_only, GIAC_CONTEXT);
g
gen
required
Function to analyze
extrema_only
bool
required
If true, return only extrema (not inflection points)
return
gen
List of critical points

Symbolic Construction

symb_derive

Create a symbolic derivative expression (unevaluated).
symbolic symb_derive(const gen & a, const gen & b);
gen symb_derive(const gen & a, const gen & b, const gen & c);
a
gen
required
Expression to differentiate
b
gen
required
Variable
c
gen
Order of derivative

Notes

  • All derivative functions use symbolic computation
  • Higher-order derivatives can be computed by specifying the order
  • The system applies differentiation rules automatically (product rule, chain rule, etc.)
  • For vector-valued functions, use grad to compute the gradient
  • Implicit differentiation is useful for equations that cannot be solved explicitly for one variable

Build docs developers (and LLMs) love