diff --git a/docs/src/getting_started.md b/docs/src/getting_started.md index abf529875..ccf08e6e4 100644 --- a/docs/src/getting_started.md +++ b/docs/src/getting_started.md @@ -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 diff --git a/docs/src/manual/faq.md b/docs/src/manual/faq.md index 93901151e..72ccdbd2c 100644 --- a/docs/src/manual/faq.md +++ b/docs/src/manual/faq.md @@ -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`. \ No newline at end of file