Overview
The equation solving module provides comprehensive tools for solving various types of equations including:- Single variable algebraic equations
- Polynomial equations (exact and numeric)
- Systems of equations
- Linear systems
- Numeric root finding
- Modular polynomial roots
Core Solving Functions
solve
The equation or expression to solve
The variable to solve for
Mode flags: bit 0 for complex mode, bit 1 for principal solutions only
Context pointer for evaluation
Vector of solutions
isolate_mode parameter controls whether complex solutions are returned and whether only principal solutions are computed.
protect_solve
The equation to solve
The variable to solve for
Solving mode flags
Context pointer
Protected solution vector
_solve
Arguments containing equation and variable
Context pointer
Solutions as a gen expression
Numeric Solvers
fsolve
Equation, variable, and optional initial guess/interval
Context pointer
Numeric solution(s)
newton
Function to find roots of
Variable
Initial guess for the root
Maximum number of iterations
Initial tolerance
Final tolerance
If true, restrict random re-initialization to real values
Lower boundary for x
Upper boundary for x
Lower boundary for random re-initialization
Upper boundary for random re-initialization
Initial step size prefactor
Context pointer
Approximate root
bisection_solver
The equation to solve
Variable
Left endpoint of interval
Right endpoint of interval
Input/output status flag (see description)
Context pointer
Vector of roots or intervals with sign changes
iszero parameter controls behavior:
- Input: 0 for single root, -1 for multiple roots without step count, positive for multiple with nstep
- Output: -2 if same sign at endpoints, -1 if error, 1 if zero found, 2 if sign reversal
solve_zero_extremum
Equation to analyze
Variable
Initial guess (can be interval with xmin, xmax)
Input: 0 for zeros, 1 for extrema. Output: actual type found
Context pointer
Zeros or extrema found
Linear Systems
linsolve
System of linear equations
Vector of variables
Context pointer
Solution vector
linsolve_u / linsolve_l
Upper/lower triangular matrix
Right-hand side vector
Output solution vector
aspen_linsolve
Coefficient matrix (augmented with right-hand side)
Context pointer
0 for no solution, 1 for unique solution, 2 for infinite solutions, -1 for error
System Solving
gsolve
System of equations
Vector of variables
Whether to find complex solutions
Whether to evaluate solutions numerically after solving
Context pointer
Vector of solution sets
Modular Arithmetic
modpolyroot
Polynomial coefficients
Prime modulus
Output vector of roots modulo p
Whether to compute gcd with x^p-x first
Context pointer
True if successful
dogcd to false if you’ve already computed gcd with x^p-x.
Gröbner Bases
gbasis
Vector of polynomials
Monomial ordering
Whether to use CoCoA library if available
Modular algorithm flag
Polynomial environment
Rational univariate representation flag
Context pointer
Additional parameters for Gröbner basis computation
Optional pointer to store transformation coefficients
Gröbner basis
eliminate
System and variables to eliminate
Context pointer
System with variables eliminated
greduce
Polynomial and basis to reduce with
Context pointer
Reduced polynomial
Optimization
fmin_cobyla
Objective function to minimize
Vector of constraint expressions (must be positive for feasibility)
Variables to optimize
Initial point
Tolerance
Maximum iterations
Context pointer
Optimal point or error
Constraints must be written so that positive values indicate feasibility. For example, to express x ≤ MAX, use the constraint MAX - x.
giac_cobyla
Structure containing function, constraints, and variables
Input: initial point. Output: final point
Input: max evaluations. Output: actual evaluations
Tolerance (default 1e-8)
Verbosity level 0-3 (default 0)
Return code indicating success or failure
Utility Functions
find_singularities
Expression
Variable
Complex mode flag
Context pointer
Vector of singularities
solvepostprocess
Raw solution
Variable
Context pointer
Processed solution
solvepreprocess
Input arguments
Whether complex mode is enabled
Context pointer
Preprocessed equations and variables
Related Functions
- Sturm Sequences - Root counting and isolation methods
- Polynomial roots - See polynomial module
- Numeric evaluation - See evalf module
