Giac.jl
Symbolic mathematics, naturally in Julia
A fast Julia interface to the Giac computer algebra system, with more than 2,000 commands and integrations across the Julia ecosystem.
Symbolic algebra
Factor, expand, simplify, and solve symbolic expressions with Giac's mature computer algebra engine.
Calculus
Differentiate, integrate, compute limits and series, and solve differential equations from Julia.
More than 2,000 commands
Use generated Julia functions or invoke any Giac command dynamically through one consistent interface.
Julia ecosystem integration
Exchange symbolic expressions with Symbolics.jl and work naturally with Julia functions and types.
Pluto-ready
Explore symbolic mathematics interactively with reactive notebooks and automatic LaTeX rendering.
GiacSlate.jl
Use Giac.jl through its integration with the KaimonSlate interactive computing environment.
Extensible by design
Connect Giac to MathJSON, Tables, LibPARI, terminal interfaces, and Model Context Protocol tools.
A Julia interface to Giac
Giac.jl wraps the Giac computer algebra system with Julia-native expressions, operations, conversions, and extension points.
Features
- Dynamic Command Invocation: Access all 2200+ Giac commands via
invoke_cmd(:cmd, args...) - Commands Submodule: All ~2000+ commands available via
Giac.Commandsfor clean namespace - Expression Evaluation: Parse and evaluate mathematical expressions
- Command Discovery: Search commands, browse by category, built-in help via
?cmd - Arithmetic Operations: +, -, *, /, ^, unary negation, equality
- Algebra: Factorization, expansion, simplification, equation solving and GCD
- Calculus: Differentiation, integration, limits, and series expansion
- Infinity Support: Use Julia's
Infand-Infdirectly in limits and improper integrals - Linear Algebra: Symbolic matrices with determinant, inverse, trace, transpose operations
- Base Extensions: Use
sin(expr),cos(expr),exp(expr)with GiacExpr - Method Syntax: Call commands as methods:
expr.factor(),expr.diff(x) - Variable Substitution: Symbolics.jl-compatible
substitute(expr, Dict(var => value))interface - Laplace Transform:
laplaceandilaplacecommands for continuous-time signal processing - Z-Transform:
ztransandinvztranscommands for discrete-time signal processing - Type Conversion: Convert results to Julia native types (Int64, Float64, Rational)
- Symbolics.jl Integration: Bidirectional conversion with Symbolics.jl
- Tables.jl Compatibility: Convert GiacMatrix and command help to DataFrames, CSV export
- LaTeX Support: Automatic LaTeX rendering in Pluto notebooks
Installation
using Pkg
Pkg.add("Giac") # when registered to Julia General RegistryFor full Giac integration with C++ library, see the Installation Guide.
Command Access
Giac commands are available through multiple access patterns:
1. Selective Import from Commands Submodule (Recommended)
using Giac
using Giac.Commands: factor, expand, ifactor
@giac_var x
factor(x^2 - 1)2. Full Import (Interactive Use)
using Giac
using Giac.Commands
@giac_var x
factor(x^2 - 1)
ifactor(120) # All ~2000+ commands available3. Universal Command Invocation
using Giac
# Works for ALL commands, including those conflicting with Julia
invoke_cmd(:factor, giac_eval("x^2-1"))
invoke_cmd(:sin, giac_eval("pi/6"))Type Conversion and Introspection
Convert Giac results to native Julia types:
using Giac
# Boolean conversion
to_julia(giac_eval("true")) # true::Bool
to_julia(giac_eval("1==1")) # true::Bool (comparison result)
to_julia(giac_eval("1")) # 1::Int64 (integer, not boolean)
# Use in control flow
if to_julia(giac_eval("2 > 1"))
println("Works!")
end
# Automatic type conversion
g = giac_eval("[1, 2, 3]")
result = to_julia(g) # Vector{Int64}
# Boolean detection
is_boolean(giac_eval("true")) # true
is_boolean(giac_eval("1")) # false
# Type introspection
using Giac.GenTypes: VECT
giac_type(g) == VECT # true
is_vector(g) # true
# Fraction components
frac = giac_eval("3/4")
numer(frac) # 3
denom(frac) # 4
# Complex components
z = giac_eval("3+4*i")
real_part(z) # 3
imag_part(z) # 4
# Matrix conversion
m = GiacMatrix(giac_eval("[[1, 2], [3, 4]]"))
to_julia(m) # 2×2 Matrix{Int64}Vector Indexing and Iteration
Access Giac vectors with Julia's native indexing:
using Giac
g = giac_eval("[10, 20, 30]")
g[1] # GiacExpr(10)
g[2] # GiacExpr(20)
# Iterate over elements
for elem in g
println(to_julia(elem))
end
# Collect to Julia vector
to_julia(g) # [10, 20, 30]::Vector{Int64}Infinity Support
Use Julia's native Inf and -Inf in limits and improper integrals:
using Giac
using Giac.Commands: limit, integrate
@giac_var x
# Limits at infinity
limit(1/x, x, Inf) # 0
limit(1/x, x, -Inf) # 0
limit(x^2, x, Inf) # +infinity
# Improper integrals
integrate(exp(-x), x, 0, Inf) # 1
integrate(1/x^2, x, 1, Inf) # 1
integrate(exp(x), x, -Inf, 0) # 1Modules
- Core API: Types, evaluation, and main functions
- Commands: All Giac commands as functions
- Constants: Symbolic mathematical constants (pi, e, i)
Documentation
Getting Started
Mathematics
- Algebra - Factorization, expansion, simplification, solving
- Calculus - Differentiation, integration, limits, series
- Linear Algebra - Matrices, determinants, eigenvalues
- Differential Equations - ODE solving with D operator
- Trigonometry - Identities, simplification, equations
Physics
- Mechanics - Kinematics, dynamics, oscillations, energy
- Electromagnetism - Circuits, fields, waves
API Reference
- Core API - Types, evaluation, and main functions
- Commands Submodule - All Giac commands as functions
Related Projects
- Giac - The underlying computer algebra system
- libgiac-julia-wrapper - CxxWrap bindings for Giac
- CxxWrap.jl - C++ wrapper generator for Julia
- GiacSlate.jl - Integrates Giac.jl with KaimonSlate