Commands Submodule

Giac.CommandsModule
Giac.Commands

A submodule containing all exportable GIAC commands as functions.

This module provides access to ~2000+ GIAC commands while keeping the main Giac namespace clean. Commands can be accessed through three patterns:

Access Patterns

  1. Qualified access (cleanest namespace):

    using Giac
    Giac.Commands.factor(expr)
    Giac.Commands.diff(expr, x)
  2. Selective import (recommended for most use cases):

    using Giac
    using Giac.Commands: factor, expand, diff
    factor(expr)  # Works directly
  3. Full import (for interactive exploration):

    using Giac
    using Giac.Commands
    factor(expr)   # All ~2000+ commands available
    ifactor(expr)  # Works directly

Conflicting Commands

Commands that conflict with Julia keywords, builtins, or standard library functions (like eval, sin, det) are NOT exported from this module. Use invoke_cmd to call them:

using Giac
invoke_cmd(:eval, expr)  # Works for any command
invoke_cmd(:sin, x)      # Including conflicting ones

Exports

  • invoke_cmd: Universal command invocation function
  • All ~2000+ non-conflicting GIAC commands (runtime-generated)

See also

source

The Giac.Commands submodule provides access to all exportable GIAC commands as Julia functions.

Usage

Selective Import (Recommended)

using Giac
using Giac.Commands: factor, expand, diff

expr = giac_eval("x^2 - 1")
factor(expr)  # (x-1)*(x+1)

Full Import

using Giac
using Giac.Commands

# All ~2000+ commands available
factor(giac_eval("x^2-1"))
ifactor(giac_eval("120"))

Qualified Access

using Giac

Giac.Commands.factor(giac_eval("x^2-1"))

Core Function

Giac.Commands.invoke_cmdFunction
invoke_cmd(cmd::Symbol, args...) -> GiacExpr

Invoke any GIAC command by name and return the result as a GiacExpr.

This is the core function for dynamic command invocation, enabling access to all 2200+ GIAC commands through a uniform interface. It works for all commands, including those that conflict with Julia builtins.

Arguments

  • cmd::Symbol: GIAC command name (e.g., :factor, :sin, :integrate)
  • args...: Command arguments (GiacExpr, String, Number, or Symbol)

Returns

  • GiacExpr: Result of command execution

Throws

  • GiacError(:eval): If command is unknown or execution fails
  • ArgumentError: If arguments cannot be converted to GIAC format

Examples

using Giac

# Single argument
expr = giac_eval("x^2 - 1")
result = invoke_cmd(:factor, expr)  # Returns (x-1)*(x+1)

# Multiple arguments
x = giac_eval("x")
derivative = invoke_cmd(:diff, expr, x)  # Returns 2*x

# Trigonometric functions (conflicts with Base)
result = invoke_cmd(:sin, giac_eval("pi/6"))  # Returns 1/2

# Evaluation (conflicts with Base.eval)
result = invoke_cmd(:eval, giac_eval("2+3"))  # Returns 5

See also

source

Conflicting Commands

Commands that conflict with Julia keywords, builtins, or standard library functions are NOT exported from this module. Use invoke_cmd to call them:

# These conflict with Julia and are NOT exported:
# eval, sin, cos, det, inv, sum, prod, etc.

# Use invoke_cmd instead:
invoke_cmd(:eval, expr)
invoke_cmd(:sin, giac_eval("pi/6"))
invoke_cmd(:det, matrix)

See JULIA_CONFLICTS for the complete list of conflicting commands.

Available Commands

Use exportable_commands() to get a list of all commands available in this module:

cmds = exportable_commands()
length(cmds)  # ~2000+