Skip to content

Commit 2dccd21

Browse files
Documentation for canonical form of Symbolic{<:Number}
1 parent 9e85a60 commit 2dccd21

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

page/index.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,20 @@ SymbolicUtils contains [a rule-based rewriting language](/rewrite/#rule-based_re
151151

152152
By default `*` and `+` operations apply the most basic simplification upon construction of the expression.
153153

154-
Commutativity and associativity are assumed over `+` and `*` operations on `Symbolic{<:Number}`.
154+
The rules with which the canonical form of `Symbolic{<:Number}` terms are constructed are the next (where `x isa Symbolic` and `c isa Number`)
155+
156+
- `0 + x` and `1 * x` always gives `x`
157+
- `0 * x` always gives `0`,
158+
- commutativity and associativity over `+` and `*` are assumed. Re-ordering of terms will be done under a [total order](https://github.com/JuliaSymbolics/SymbolicUtils.jl/blob/master/src/ordering.jl)
159+
- sum of `Add`'s are fused
160+
- product of `Mul`'s are fused
161+
- `x + ... + x` will be fused into `n*x` with type `Mul`
162+
- `x * ... * x` will be fused into `x^n` with type `Pow`
163+
- `c * (c₁x₁ + ... + cₙxₙ)` will be converted into `c*c₁*x₁ + ... + c*cₙ*xₙ`
164+
- `(x₁^c₁ + ... + xₙ^cₙ)^c` will be converted into `x₁^(c*c₁) + ... + xₙ^(c*cₙ)`
165+
- any other combinations of expressions will be left the same
166+
167+
Here is an example of this
155168

156169
```julia:simplify1
157170
2 * (w+w+α+β + sin(z)^2 + cos(z)^2 - 1)

0 commit comments

Comments
 (0)