Skip to content

Commit

Permalink
Merge pull request #1295 from ArnoStrouwen/docs
Browse files Browse the repository at this point in the history
move over MTK low level symbolic doc details to Symbolics
  • Loading branch information
ChrisRackauckas authored Oct 5, 2024
2 parents 73cb6fa + 0278237 commit 5cf6341
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/src/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,17 @@ convert the output to an `Expr`:
Symbolics.toexpr(x + y^2)
```

The other way around is also possible, parsing Julia expressions into symbolic expressions

```@example symbolic_basics
ex = [:(v ~ w)
:(w ~ -v)]
eqs = parse_expr_to_symbolic.(ex, (Main,))
eqs_lhs = [eq.lhs for eq in eqs]
eqs_rhs = [eq.rhs for eq in eqs]
Symbolics.jacobian(eqs_rhs, eqs_lhs)
```

## `Sym`s and callable `Sym`s

In the definition
Expand Down
28 changes: 28 additions & 0 deletions docs/src/manual/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,31 @@ be selected (since `x == y` is unknown for arbitrary symbolic values!). This is
required, since this is a non-lazy check of whether the symbol `x` is always equal to the symbol `y`, rather than
an expression of whether `x` and `y` currently have the same value.

## Understanding the Difference Between the Julia Variable and the Symbolic Variable

In the most basic usage of Symbolics, the name of the Julia variable
and the symbolic variable are the same. For example, when we do:

```@example faq
@variables a
```

the name of the symbolic variable is `a` and same with the Julia variable. However, we can
de-couple these by setting `a` to a new symbolic variable, for example:

```@example faq
b = only(@variables(a))
```

Now the Julia variable `b` refers to the variable named `a`. However, the downside of this current
approach is that it requires that the user writing the script knows the name `a` that they want to
place to the variable. But what if for example we needed to get the variable's name from a file?

To do this, one can interpolate a symbol into the `@variables` macro using `$`. For example:

```@example faq
a = :c
b = only(@variables($a))
```

In this example, `@variables($a)` created a variable named `c`, and set this variable to `b`.

0 comments on commit 5cf6341

Please sign in to comment.