Skip to content

Commit f0b337b

Browse files
committed
Update docs
1 parent fa2eda4 commit f0b337b

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

docs/src/IR.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
ModelingToolkit IR mirrors the Julia AST but allows for easy mathematical
44
manipulation by itself following mathematical semantics. The base of the IR is
55
the `Sym` type, which defines a symbolic variable. Registered (mathematical)
6-
functions on `Sym`s (or `Term`s) return `Term`s. For example, `op1 = x+y` is
7-
one `Term` and `op2 = 2z` is another, and so `op1*op2` is another `Term`. Then,
8-
at the top, an `Equation`, normally written as `op1 ~ op2`, defines the
9-
symbolic equality between two operations.
6+
functions on `Sym`s (or `istree` objects) return an expression that `istree`.
7+
For example, `op1 = x+y` is one symbolic object and `op2 = 2z` is another, and
8+
so `op1*op2` is another tree object. Then, at the top, an `Equation`, normally
9+
written as `op1 ~ op2`, defines the symbolic equality between two operations.
1010

1111
### Types
1212
`Sym`, `Term`, and `FnType` are from [SymbolicUtils.jl](https://juliasymbolics.github.io/SymbolicUtils.jl/api/). Note that in
1313
ModelingToolkit, we always use `Sym{Real}`, `Term{Real}`, and
14-
`FnType{Tuple{Any}, Real}`. To get the arguments of a `Term` use
15-
`arguments(t::Term)`, and to get the operation of a `Term` use
16-
`operation(t::Term)`.
14+
`FnType{Tuple{Any}, Real}`. To get the arguments of a `istree` object use
15+
`arguments(t::Term)`, and to get the operation, use `operation(t::Term)`.
16+
However, note that one should never dispatch on `Term` or test `isa Term`.
17+
Instead, one needs to use `SymbolicUtils.istree` to check if `arguments` and
18+
`operation` is defined.
1719

1820
```@docs
1921
Equation

docs/src/tutorials/symbolic_functions.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ The way to define symbolic variables is via the `@variables` macro:
77
@variables x y
88
```
99

10-
After defining variables as symbolic, symbolic expressions, which we
11-
call a `Term`, can be generated by utilizing Julia expressions.
12-
For example:
10+
After defining variables as symbolic, symbolic expressions, which we call a
11+
`istree` object, can be generated by utilizing Julia expressions. For example:
1312

1413
```julia
1514
z = x^2 + y
1615
```
1716

18-
Here, `z` is the `Term` for "square `x` and add `y`". To
19-
make an array of symbolic expressions, simply make an array of
20-
symbolic expressions:
17+
Here, `z` is an expression tree for "square `x` and add `y`". To make an array
18+
of symbolic expressions, simply make an array of symbolic expressions:
2119

2220
```julia
2321
A = [x^2+y 0 2x
@@ -30,7 +28,10 @@ A = [x^2+y 0 2x
3028
y ^ 2 + x 0 0
3129
```
3230

33-
Note that by default, `@variables` returns `Sym` or `Term` objects wrapped in `Num` in order to make them behave like subtypes of `Real`. Any operation on these `Num` objects will return a new `Num` object, wrapping the result of computing symbolically on the underlying values.
31+
Note that by default, `@variables` returns `Sym` or `istree` objects wrapped in
32+
`Num` in order to make them behave like subtypes of `Real`. Any operation on
33+
these `Num` objects will return a new `Num` object, wrapping the result of
34+
computing symbolically on the underlying values.
3435

3536
To better view the results, we can use [Latexify.jl](https://github.com/korsbo/Latexify.jl).
3637
ModelingToolkit.jl comes with Latexify recipes so it works automatically:

0 commit comments

Comments
 (0)