punt on publish.yml; return another day

This commit is contained in:
jverzani committed 2022-08-26 15:24:51 -04:00
1 parent 642e579f12
commit 97f5d09ff6
675 files changed
+1 -572479

No files matched your search

@@ -1,11 +0,0 @@
{
"hash": "a14790e03a1c5ab753ca9cdf016f7980",
"result": {
"markdown": "# Symbolics.jl\n\n\n\n\nThere are a few options in `Julia` for symbolic math, for example, the `SymPy` package which wraps a Python library. This section describes a collection of native `Julia` packages providing many features of symbolic math.\n\n\n## About\n\n\nThe `Symbolics` package bills itself as a \"fast and modern Computer Algebra System (CAS) for a fast and modern programming language.\" This package relies on the `SymbolicUtils` package and is built upon by the `ModelingToolkit` package, which we don't describe here.\n\n\nWe begin by loading the `Symbolics` package which when loaded re-exports the `SymbolicUtils` package.\n\n``` {.julia .cell-code}\nusing Symbolics\n```\n\n\n## Symbolic variables\n\n\nSymbolic math at its core involves symbolic variables, which essentially defer evaluation until requested. The creation of symbolic variables differs between the two packages discussed here.\n\n\n`SymbolicUtils` creates variables which carry `Julia` type information (e.g. `Int`, `Float64`, ...). This type information carries through operations involving these variables. Symbolic variables can be created with the `@syms` macro. For example\n\n::: {.cell execution_count=2}\n``` {.julia .cell-code}\n@syms x y::Int f(x::Real)::Real\n```\n\n::: {.cell-output .cell-output-display execution_count=3}\n```\n(x, y, f)\n```\n:::\n:::\n\n\nThis creates `x` a symbolic value with symbolic type `Number`, `y` a symbolic variable holding integer values, and `f` a symbolic function of a single real variable outputting a real variable.\n\n\nThe non-exported `symtype` function reveals the underlying type:\n\n::: {.cell execution_count=3}\n``` {.julia .cell-code}\nimport Symbolics.SymbolicUtils: symtype\n\nsymtype(x), symtype(y)\n```\n\n::: {.cell-output .cell-output-display execution_count=4}\n```\n(Number, Int64)\n```\n:::\n:::\n\n\nFor `y`, the symbolic type being real does not imply the type of `y` is a subtype of `Real`:\n\n::: {.cell execution_count=4}\n``` {.julia .cell-code}\nisa(y, Real)\n```\n\n::: {.cell-output .cell-output-display execution_count=5}\n```\nfalse\n```\n:::\n:::\n\n\nWe see that the function `f` when called with `y` would return a value of (symbolic) type `Real`:\n\n::: {.cell execution_count=5}\n``` {.julia .cell-code}\nf(y) |> symtype\n```\n\n::: {.cell-output .cell-output-display execution_count=6}\n```\nReal\n```\n:::\n:::\n\n\nAs the symbolic type of `x` is `Number` – which is not a subtype of `Real` – the following will error:\n\n::: {.cell execution_count=6}\n``` {.julia .cell-code}\nf(x)\n```\n\n::: {.cell-output .cell-output-error}\n```\nLoadError: Tuple{Number} is not a subtype of Tuple{Real}.\n```\n:::\n:::\n\n\n:::{.callout-note}\n## Note\nThe `SymPy` package also has an `@syms` macro to create variables. Though their names agree, they do different things. Using both packages together would require qualifying many shared method names. For `SymbolicUtils`, the `@syms` macro uses `Julia` types to parameterize the variables. In `SymPy` it is possible to specify *assumptions* on the variables, but that is different and not useful for dispatch without some extra effort.\n\n:::\n\nFor `Symbolics`, symbolic variables are created using a wrapper around an underlying `SymbolicUtils` object. This wrapper, `Num`, is a subtype of `Real` (the underlying `SymbolicUtils` object may have symbolic type `Real`, but it won't be a subtype of `Real`.)\n\n\nSymbolic values are created with the `@variables` macro. For example:\n\n::: {.cell execution_count=7}\n``` {.julia .cell-code}\n@variables x y::Int z[1:3]::Int f(..)::Int\n```\n\n::: {.cell-output .cell-output-display execution_count=8}\n```\n4-element Vector{Any}:\n x\n y\n z[1:3]\n f⋆\n```\n:::\n:::\n\n\nThis creates\n\n\n * a symbolic value `x` of `symtype` `Real`\n * a symbolic value `y` of `symtype` `Int`\n * a vector of symbolic values each of `symtype` `Int`\n * a symbolic function `f` returning an object of `symtype` `Int`\n\n\nThe symbolic type reflects that of the underlying object behind the `Num` wrapper:\n\n::: {.cell execution_count=8}\n``` {.julia .cell-code}\ntypeof(x), symtype(x), typeof(Symbolics.value(x))\n```\n\n::: {.cell-output .cell-output-display execution_count=9}\n```\n(Num, Real, SymbolicUtils.Sym{Real, Base.ImmutableDict{DataType, Any}})\n```\n:::\n:::\n\n\n(The `value` method unwraps the `Num` wrapper.)\n\n\n## Symbolic expressions\n\n\nSymbolic expressions are built up from symbolic variables through natural `Julia` idioms. `SymbolicUtils` privileges a few key operations: `Add`, `Mul`, `Pow`, and `Div`. For examples:\n\n::: {.cell execution_count=9}\n``` {.julia .cell-code}\n@syms x y\ntypeof(x + y) # `Add`\n```\n\n::: {.cell-output .cell-output-display execution_count=10}\n```\nSymbolicUtils.Add{Number, Int64, Dict{Any, Number}, Nothing}\n```\n:::\n:::\n\n\n::: {.cell execution_count=10}\n``` {.julia .cell-code}\ntypeof(x * y) # `Mul`\n```\n\n::: {.cell-output .cell-output-display executioLine truncated
"supporting": [
"symbolics_files/figure-html"
],
"filters": [],
"includes": {}
}
}