Symbolics.jl - fast and flexible symbolic programming
2021-07-30 , Red

Symbolics.jl is a fast, yet flexible symbolic manipulation package. It can generate serial or multi-threaded Julia code; or even C, Stan or MATLAB code from symbolic expressions. This talk is an overview of the features and the organization of the Symbolics.jl package, and the design decisions that make it fast and extendable.


Symbolic systems either excel in flexibility or performance. For example, SymPy is highly flexible and has a good set of term rewriting functionality, but is slow. On the other hand, projects like OSCAR are specialized tools for computational algebra -- problems are hard to set up but computations are highly efficient. Further, neither of these types of tools actually help you turn symbolic expressions into executable code.

In this talk, we introduce the Symbolics.jl and the underlying SymbolicUtils.jl packages. We also talk about the term-rewriting system and ways to write passes that transform symbolic expressions with user-defined custom rules.

Outline:

  • Why is Symbolics.jl useful
  • Example of symbolic basic manipulation
  • Benchmark vs SymPy
  • Code generation example
  • Differentiation syntax (comparison with other systems and possibilities, and AD)
  • Fast sparsity detection
  • Under the hood
    • Wrapper to make symbolic expression: Num <: Number
    • Syms and Terms
    • Fast canonical form
    • Term interface
    • Expression rewriting
    • Rule syntax
    • Chaining and pipelining rules
    • Simplification
    • Polynomial form from AbstractAlgebra
    • ModelingToolkit
    • How ModelingToolkit builds a simulation system on top of Symbolics
    • Use of build_function in ODE solver
    • Structural simplification example with a bit of all the clever ideas (Attend Chris’s talk and workshop)

Shashi is a grad student at MIT. Yingbo is an undergrad at UMBC and works at Julia Computing. We like coding in Julia.