Expression rewriting and simplification
SymbolicUtils.jl provides various utilities for symbolic computing.
Symbols in SymbolicUtils carry type information. Operations on them propagate this information. A rule-based rewriting language can be used to find subexpressions that satisfy arbitrary conditions and apply arbitrary transformations on the matches. The library also contains a set of useful simplification rules for expressions of numeric symbols and numbers. These can be remixed and extended for special purposes.
If you are a Julia package develper in need of a rule rewriting system for your own types, have a look at the interfacing guide.
SymbolicUtils.jl is on the general registry and can be added the usual way:
julia pkg> add SymbolicUtilsor
julia julia> using Pkg; Pkg.add("SymbolicUtils")
julia> using SymbolicUtilsjulia> SymbolicUtils.show_simplified[] = true
julia> @syms x::Real y::Real z::Complex f(::Number)::Real (x, y, z, f(::Number)::Real)
julia> 2x^2 - y + x^2 (3 * (x ^ 2)) + (-1 * y)
julia> f(sin(x)^2 + cos(x)^2) + z f(1) + z
julia> r = @rule sinh(im *
x) => sin(x) sinh(im *x) => sin(x)julia> r(sinh(im * y)) sin(y)
julia> simplify(cos(y)^2 + sinh(im*y)^2, RuleSet([r])) 1