Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move over MTK low level symbolic doc details to Symbolics #1295

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`.
Loading