Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
43bab68
refactor: remove trivial usages of `Symbolic{T}`
AayushSabharwal Sep 15, 2025
ee53f72
refactor: remove `ComplexTerm`
AayushSabharwal Sep 15, 2025
493d76f
refactor: remove `CallWithMetadata`
AayushSabharwal Sep 15, 2025
7b59796
refactor: remove array variants
AayushSabharwal Sep 15, 2025
16c6f6c
refactor: remove redundant `symbolic_type` methods
AayushSabharwal Sep 15, 2025
fdb8a83
refactor: remove usages of `Polyform`
AayushSabharwal Sep 15, 2025
679da87
feat: make `vartype` of variables a preference
AayushSabharwal Sep 16, 2025
55a3d1a
refactor: use `@syms` parsing for `@variables`
AayushSabharwal Sep 16, 2025
7697007
refactor: update `@wrapped` macro
AayushSabharwal Sep 16, 2025
a42f31d
refactor: update `@register_symbolic`
AayushSabharwal Sep 16, 2025
4752ecc
refactor: update `@register_array_symbolic`
AayushSabharwal Sep 16, 2025
7355dac
fix: use `SymbolicUtils.unwrap`
AayushSabharwal Sep 16, 2025
c6e45de
fix: validate default size in `setdefaultval`
AayushSabharwal Sep 16, 2025
f408e94
refactor: remove old `_getname`, implement `SII.getname` properly
AayushSabharwal Sep 16, 2025
88de7b7
fix: handle indexed symbolics in `getdefaultval`
AayushSabharwal Sep 16, 2025
f950abb
fix: fix `Symbolics.variable`
AayushSabharwal Sep 16, 2025
9e1af5a
refactor: remove `get_variables!` implementations
AayushSabharwal Sep 16, 2025
5fe7a2d
feat: implement `SymbolicUtils.search_variables!`
AayushSabharwal Sep 16, 2025
f734cb2
refactor: make `Arr` store `BasicSymbolic{T}`
AayushSabharwal Sep 18, 2025
28d6502
fix: fix `build_function` codegen for arrayop
AayushSabharwal Sep 18, 2025
d56d6a3
fix: fix `scalarize` for `Equation`
AayushSabharwal Sep 18, 2025
7081b9a
fix: fix `scalarize` for `Inequality`
AayushSabharwal Sep 18, 2025
1a3a87e
fix: store `BasicSymbolic{T}` in `Num`
AayushSabharwal Sep 18, 2025
5225e14
refactor: do not pirate `Base.Symbol(::BasicSymbolic)`
AayushSabharwal Sep 18, 2025
d77490f
fix: remove use of deprecated `children`
AayushSabharwal Sep 18, 2025
7c66795
refactor: remove `Symbolics.Unknown`
AayushSabharwal Sep 18, 2025
61ad7e4
refactor: move `Operator` to `SymbolicUtils`
AayushSabharwal Sep 18, 2025
5c464c2
refactor: fix `scalarize` for `Num`, `Complex{Num}`
AayushSabharwal Sep 18, 2025
f064342
fix: fix `eltype` and `ndims` implementations for `Arr`
AayushSabharwal Sep 18, 2025
885e3dc
fix: implement `is_wrapper_type` for `Complex{Num}`
AayushSabharwal Sep 18, 2025
95014d0
fix: fix `unwrap` and `show` for `Complex{Num}`
AayushSabharwal Sep 18, 2025
83fa17d
fix: handle non-concrete `::Complex` annotation in `@variables`
AayushSabharwal Sep 18, 2025
3589bf0
refactor: greatly simplify semipoly implementation
AayushSabharwal Sep 18, 2025
7254057
fix: properly support `ssqrt` and `scbrt`
AayushSabharwal Sep 19, 2025
d8b5fff
fix: fix `recursive_hasoperator`
AayushSabharwal Sep 19, 2025
0453ff2
fix: remove redundant methods
AayushSabharwal Sep 19, 2025
e382a65
fix: fix `hessian_sparsity`
AayushSabharwal Sep 19, 2025
a23699f
feat: implement `search_variables!` for `Inequality`
AayushSabharwal Sep 19, 2025
10d908a
fix: remove type-piracy
AayushSabharwal Sep 19, 2025
6c820eb
fix: remove outdated promotion rule
AayushSabharwal Sep 19, 2025
391337c
fix: update `@register_symbolic`
AayushSabharwal Sep 19, 2025
980e8f6
refactor: implement `get_variables` using `search_variables`
AayushSabharwal Sep 19, 2025
958d77e
refactor: remove `fast_substitute`
AayushSabharwal Sep 19, 2025
cdbae19
refactor: remove `Difference` operator
AayushSabharwal Sep 19, 2025
5183ef9
fix: fix `degree`
AayushSabharwal Sep 19, 2025
19d4e4b
fix: fix `coeff`
AayushSabharwal Sep 19, 2025
7347a8c
fix: fix `parse_expr_to_symbolic`
AayushSabharwal Sep 19, 2025
5e50850
fix: update `linear_expansion`
AayushSabharwal Sep 19, 2025
550b5e4
refactor: repurpose `value`
AayushSabharwal Sep 19, 2025
832aa9b
fix: fallback `IndexStyle` to `BasicSymbolic`
AayushSabharwal Sep 19, 2025
f194d76
fix: add more `\` overloads for `Arr`
AayushSabharwal Sep 19, 2025
0277e8e
refactor: move some registrations to SymbolicUtils
AayushSabharwal Sep 19, 2025
e2b0b68
refactor: move extra function registrations to SymbolicUtils
AayushSabharwal Sep 22, 2025
f5b828e
refactor: fix ambiguities in array `*`, `+`
AayushSabharwal Sep 22, 2025
b4dba29
refactor: move `binomial` registration to SymbolicUtils
AayushSabharwal Sep 22, 2025
8ef8de0
fix: fix `Num(::AbstractIrrational)`
AayushSabharwal Sep 22, 2025
6f97907
refactor: wrap result of array operations
AayushSabharwal Sep 22, 2025
f105e42
fix: fix `inplace_expr` for `ArrayOp`
AayushSabharwal Sep 22, 2025
dc68e86
fix: fix `hasnode` method
AayushSabharwal Sep 22, 2025
02794f6
fix: handle edge cases in codegen
AayushSabharwal Sep 22, 2025
23016d3
refactor: use new syntax in `Integral`
AayushSabharwal Sep 22, 2025
ed38f7c
refactor: update latexify recipes
AayushSabharwal Sep 22, 2025
e827196
feat: add `CallAndWrap`
AayushSabharwal Sep 22, 2025
3dd930a
feat: automatically wrap variables in `CallAndWrap`
AayushSabharwal Sep 22, 2025
90ea827
fix: fix autodiff of `Integral`
AayushSabharwal Sep 22, 2025
b3d5bdb
refactor: remove Connection, state machine semantics
AayushSabharwal Sep 22, 2025
2482ee3
refactor: remove dead code
AayushSabharwal Sep 22, 2025
2e0493f
fix: make symbolic solvers work
AayushSabharwal Sep 23, 2025
75e5cfe
fix: fix `Num` hash
AayushSabharwal Sep 23, 2025
6e1a7a9
fix: fix dispatch in GroebnerExt
AayushSabharwal Sep 24, 2025
e7048b4
refactor: update LuxExt
AayushSabharwal Sep 24, 2025
1fcd67f
feat: add `substitute_in_deriv`
AayushSabharwal Sep 24, 2025
cc10ae7
refactor: update symbolic ODE solvers
AayushSabharwal Sep 24, 2025
ee3025e
refactor: update taylor series code
AayushSabharwal Sep 24, 2025
c5c32c9
fix: fix `fixpoint_sub` filterer
AayushSabharwal Sep 24, 2025
9897c6a
refactor: remove old symbolic struct
AayushSabharwal Sep 24, 2025
d5f9bdc
fix: fix minor bug in semipoly
AayushSabharwal Sep 24, 2025
9820472
fix: fix `binomial` method overloads
AayushSabharwal Sep 24, 2025
fa44594
fix: implement `Substituter` for `Differential`
AayushSabharwal Sep 24, 2025
d8ed4f3
fix: fix arrayop codegen
AayushSabharwal Sep 24, 2025
b36c5a1
fix: fix `getindex` method ambiguities
AayushSabharwal Sep 24, 2025
f43a2cf
test: update tests
AayushSabharwal Sep 24, 2025
eda2afc
refactor: update `executediff`
AayushSabharwal Sep 26, 2025
74b77a1
build: bump SymbolicUtils compat
AayushSabharwal Sep 26, 2025
7a87100
fix: retain rationals in `taylor`
AayushSabharwal Sep 26, 2025
a5a790c
build: remove `SymPyPythonCall` test dep
AayushSabharwal Sep 26, 2025
9283b37
build: remove SciMLBase dependency
AayushSabharwal Sep 26, 2025
2d0d63a
refactor: remove dead code
AayushSabharwal Sep 26, 2025
d032c07
fix: fix incorrect arithmetic in ODE solver
AayushSabharwal Sep 29, 2025
28bce04
fix: make `Equation`, `Inequality` type-stable
AayushSabharwal Sep 29, 2025
28015a4
fix: fix complex arithmetic when `Num` wraps a complex
AayushSabharwal Sep 29, 2025
1ba0dc4
fix: fix inference of `Num` arithmetic
AayushSabharwal Sep 29, 2025
937cdb8
feat: implement `isapprox(::Num, ::Num)`
AayushSabharwal Sep 29, 2025
2db019d
refactor: update to new `substitute` syntax
AayushSabharwal Sep 29, 2025
e4405f7
refactor: remove OffsetArrays dependency
AayushSabharwal Sep 29, 2025
eb87007
refactor: remove invalidations from `TermCombination`
AayushSabharwal Sep 29, 2025
75a51b4
refactor: reduce invalidations from registration macros
AayushSabharwal Sep 29, 2025
d257ede
refactor: remove several sources of invalidations
AayushSabharwal Sep 29, 2025
c6debcd
fix: make array operations type-stable and unambiguous
AayushSabharwal Sep 30, 2025
f8ee83d
fix: remove ambiguities in `Num` arithmetic
AayushSabharwal Sep 30, 2025
7990666
feat: add global `SymbolicT`
AayushSabharwal Sep 30, 2025
4ed3315
refactor: account for absence of constant-folding by default
AayushSabharwal Sep 30, 2025
c8a5dd8
fix: fix `cse_inside_expr`
AayushSabharwal Oct 8, 2025
f6fe5d1
refactor: improve `is_derivative` performance
AayushSabharwal Oct 8, 2025
70a8255
refactor: improve `recursive_hasoperator` performance, inference
AayushSabharwal Oct 8, 2025
f928bfd
refactor: improve `derivative_idx` inference
AayushSabharwal Oct 8, 2025
4cdc308
refactor: improve `linear_solver` type stability
AayushSabharwal Oct 8, 2025
6e2d86f
refactor: improve `diff2term` type-stability
AayushSabharwal Oct 8, 2025
ca418cd
refactor: remove deprecated `occursin`
AayushSabharwal Oct 8, 2025
11cd11e
fix: fix `Symbolics.evaluate`
AayushSabharwal Oct 8, 2025
04d87b7
fix: use `transform` in `parse_vars`
AayushSabharwal Oct 8, 2025
78f6887
refactor: improve precompilation
AayushSabharwal Oct 8, 2025
574df02
refactor: remove error message to avoid massive invalidations
AayushSabharwal Oct 8, 2025
f4409a7
feat: add metadata handling functions for `Arr`
AayushSabharwal Oct 14, 2025
279cd07
fix: propagate `wrap_code` in array `build_function` fallback
AayushSabharwal Oct 14, 2025
3a32423
fix: properly handle `is_atomic` in `get_variables`
AayushSabharwal Oct 14, 2025
1c715a1
fix: handle `nothing` defaults in `setdefaultval`
AayushSabharwal Oct 14, 2025
7891458
fix: fix wrapping in `Arr` getindex
AayushSabharwal Oct 15, 2025
ea0fffb
refactor: improve `norm` implementation
AayushSabharwal Oct 17, 2025
7b99e36
fix: fix 3-arg `get_variables!`
AayushSabharwal Oct 17, 2025
b180a9d
feat: allow `missing` default for array variables
AayushSabharwal Oct 21, 2025
42553e5
fix: fold in `SII.symbolic_evaluate`
AayushSabharwal Oct 21, 2025
71ae321
feat: add `getmetadata_maybe_indexed`
AayushSabharwal Oct 21, 2025
70f627a
fix: fix `promote_symtype` for registered lux function
AayushSabharwal Oct 21, 2025
41fe8be
refactor: store derivative order in `Differential` operator
AayushSabharwal Oct 22, 2025
01b975e
refactor: update to new `Differential` structure
AayushSabharwal Oct 22, 2025
3704fba
test: update tests to new `Differential` structure
AayushSabharwal Oct 22, 2025
7b11528
refactor: move Latexify to extension
AayushSabharwal Oct 24, 2025
3055460
refactor: update `cse_inside_expr`
AayushSabharwal Oct 24, 2025
777e662
refactor: warn in print methods inside Pluto
AayushSabharwal Oct 24, 2025
326576a
BREAKING: build: bump major version
AayushSabharwal Oct 24, 2025
d6a35fc
docs: bump docs compats
AayushSabharwal Oct 24, 2025
8b190e3
fix: update LuxExt to new semantics
AayushSabharwal Oct 27, 2025
a49e67c
test: fold in Lux tests
AayushSabharwal Oct 27, 2025
69be1e5
fix: add missing `symbolic_type` methods
AayushSabharwal Oct 27, 2025
a82677d
refactor: update SymPy/SymPyPythonCall extensions
AayushSabharwal Oct 27, 2025
6c43af0
refactor: improve type-stability of `jacobian`
AayushSabharwal Nov 3, 2025
98c38be
refactor: improve type-stability of `symbolic_linear_solve`
AayushSabharwal Nov 3, 2025
0278cc0
docs: temporarily remove OrdinaryDiffEq docs dependency
AayushSabharwal Nov 3, 2025
9d0c52f
refactor: avoid bad `//` in symbolic diffeq code
AayushSabharwal Nov 3, 2025
bda71ae
test: update reference tests
AayushSabharwal Nov 3, 2025
07ccefa
feat: add new derivative rule syntax
AayushSabharwal Nov 4, 2025
431dc91
refactor: update to new derivative rule syntax
AayushSabharwal Nov 4, 2025
171aedc
docs: update derivative registration docs
AayushSabharwal Nov 4, 2025
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
31 changes: 20 additions & 11 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Symbolics"
uuid = "0c5d862f-8b57-4792-8d23-62f2024744c7"
authors = ["Shashi Gowda <gowda@mit.edu>"]
version = "6.57.0"
version = "7.0.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand All @@ -11,25 +11,24 @@ CommonWorldInvalidations = "f70d9fcc-98c5-4d4a-abd7-e4cdeebd8ca8"
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
DiffRules = "b552c78f-8df3-52c6-915a-8e097449b14b"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
DynamicPolynomials = "7c1d4256-1411-5781-91ec-d7bc3513ac07"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LogExpFunctions = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Moshi = "2e0e35c7-a2e4-4343-998d-7ef72827ed2d"
MultivariatePolynomials = "102ac46a-7ee4-5c85-9060-abc95bfdeaa3"
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Primes = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
RuntimeGeneratedFunctions = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SciMLPublic = "431bcebd-1456-4ced-9d72-93c2757fff0b"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Expand All @@ -42,20 +41,27 @@ TermInterface = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c"

[weakdeps]
D3Trees = "e3df1716-f71e-5df9-9e2d-98e193103c45"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Groebner = "0b43b601-686d-58a3-8a1c-6623616c7cd4"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Lux = "b2108857-7c20-44ae-9111-449ecde12c47"
Nemo = "2edaba10-b0f1-5616-af89-8c11ac63239a"
PlutoRunner = "dc6b355a-2368-4481-ae6d-ae0351418d79"
PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
SymPy = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6"
SymPyPythonCall = "bc8888f7-b21e-4b7c-a06a-5d9c9496438c"

[extensions]
SymbolicsD3TreesExt = "D3Trees"
SymbolicsDistributionsExt = "Distributions"
SymbolicsForwardDiffExt = "ForwardDiff"
SymbolicsGroebnerExt = "Groebner"
SymbolicsLatexifyExt = ["Latexify", "LaTeXStrings"]
SymbolicsLuxExt = "Lux"
SymbolicsNemoExt = "Nemo"
SymbolicsPlutoRunnerExt = "PlutoRunner"
SymbolicsPreallocationToolsExt = ["PreallocationTools", "ForwardDiff"]
SymbolicsSymPyExt = "SymPy"
SymbolicsSymPyPythonCallExt = "SymPyPythonCall"
Expand Down Expand Up @@ -84,19 +90,21 @@ Latexify = "0.16"
LogExpFunctions = "0.3"
Lux = "1"
MacroTools = "0.5"
Moshi = "0.3.7"
MultivariatePolynomials = "0.5.12"
MutableArithmetics = "1.6.5"
NaNMath = "1"
Nemo = "0.46, 0.47, 0.48, 0.49, 0.52"
OffsetArrays = "1.15.0"
PkgBenchmark = "0.2"
PreallocationTools = "0.4"
PrecompileTools = "1"
Preferences = "1.5.0"
Primes = "0.5"
RecipesBase = "1.1"
Reexport = "1"
ReferenceTests = "0.10"
RuntimeGeneratedFunctions = "0.5.9"
SafeTestsets = "0.1.0"
SciMLBase = "2"
SciMLPublic = "1.0.0"
Setfield = "1"
SnoopCompile = "3.1"
Expand All @@ -106,7 +114,7 @@ SymPy = "2.2"
SymPyPythonCall = "0.5"
SymbolicIndexingInterface = "0.3.14"
SymbolicLimits = "0.2.2"
SymbolicUtils = "3.24"
SymbolicUtils = "4.3"
TermInterface = "2"
julia = "1.10"

Expand All @@ -117,7 +125,9 @@ D3Trees = "e3df1716-f71e-5df9-9e2d-98e193103c45"
DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Groebner = "0b43b601-686d-58a3-8a1c-6623616c7cd4"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
LambertW = "984bce1d-4616-540c-a9ee-88d1112d94c9"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
Lux = "b2108857-7c20-44ae-9111-449ecde12c47"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
Expand All @@ -126,8 +136,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SnoopCompile = "aa65fe97-06da-5843-b5b1-d5d13cad87d2"
SymPyPythonCall = "bc8888f7-b21e-4b7c-a06a-5d9c9496438c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "SafeTestsets", "Pkg", "PkgBenchmark", "PreallocationTools", "ForwardDiff", "Groebner", "BenchmarkTools", "ReferenceTests", "SymPyPythonCall", "Random", "LambertW", "Lux", "ComponentArrays", "Nemo", "DynamicQuantities", "D3Trees", "SnoopCompile"]
test = ["Test", "SafeTestsets", "Pkg", "PkgBenchmark", "PreallocationTools", "ForwardDiff", "Groebner", "BenchmarkTools", "ReferenceTests", "Random", "LambertW", "Lux", "ComponentArrays", "Nemo", "DynamicQuantities", "D3Trees", "SnoopCompile", "Latexify", "LaTeXStrings"]
8 changes: 4 additions & 4 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Groebner = "0b43b601-686d-58a3-8a1c-6623616c7cd4"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
Nemo = "2edaba10-b0f1-5616-af89-8c11ac63239a"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
# OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
Expand All @@ -16,8 +16,8 @@ Documenter = "1"
Groebner = "0.8.2, 0.9, 0.10"
Latexify = "0.15, 0.16"
Nemo = "0.46, 0.47, 0.48, 0.49, 0.52"
OrdinaryDiffEq = "6.31"
# OrdinaryDiffEq = "6.31"
Plots = "1.36"
StaticArrays = "1.5"
SymbolicUtils = "2.0.2, 3"
Symbolics = "6"
SymbolicUtils = "4.2"
Symbolics = "7"
26 changes: 14 additions & 12 deletions docs/src/manual/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,18 @@ also supplied.

### Defining Derivatives of Registered Functions

In order for symbolic differentiation to work, an overload of `Symbolics.derivative` is
required. The syntax is `derivative(typeof(f), args::NTuple{i,Any}, ::Val{j})` where
`i` is the number of arguments to the function and `j` is which argument is being
differentiated. So for example:
In order for symbolic differentiation to work, defining [`@register_derivative`](@ref) for
registered functions is required. For example,

```julia
function derivative(::typeof(min), args::NTuple{2,Any}, ::Val{1})
x, y = args
ifelse(x < y, one(x), zero(x))
end
@register_derivative min(x, y) 1 ifelse(x < y, 1, 0)
```

is the partial derivative of the Julia `min(x,y)` function with respect to `x`.
is the partial derivative of the Julia `min(x,y)` function with respect to `x`. Refer to
the documentation of [`@register_derivative`](@ref) for an in-depth explanation of the macro
syntax.

Querying the rules defined using this method requires the use of [`@derivative_rule`](@ref).

!!! note
Downstream symbolic derivative functionality only work if every partial derivative that
Expand Down Expand Up @@ -147,6 +146,8 @@ Note that at this time array derivatives cannot be defined.
```@docs
@register_symbolic
@register_array_symbolic
@register_derivative
@derivative_rule
```

## Direct Registration API (Advanced, Experimental)
Expand Down Expand Up @@ -181,11 +182,12 @@ Additionally a symbolic name is required:
Base.nameof(interp::AbstractInterpolation) = :Interpolation
```

The derivative is defined similarly to the macro case:
With Symbolics.jl v7 we don't expose a direct API for defining derivatives. It
requires using the macro.

```julia
function Symbolics.derivative(interp::AbstractInterpolation, args::NTuple{1, Any}, ::Val{1})
Symbolics.unwrap(derivative(interp, Symbolics.wrap(args[1])))
@register_derivative (interp::AbstractInterpolation)(x) 1 begin
# ...
end
```

Expand Down
4 changes: 2 additions & 2 deletions docs/src/tutorials/auto_parallel.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Now let's set up the parabolic PDE to be solved by DifferentialEquations.jl.
We will set up the vanilla version and the sparse multithreaded
version:

```@example auto_parallel
```julia
using OrdinaryDiffEq
u0 = zeros(N, N, 3)
MyA = zeros(N, N);
Expand All @@ -99,7 +99,7 @@ fastprob = ODEProblem(ODEFunction((du, u, p, t) -> fastf(du, u),

Let's see the timing difference:

```@example auto_parallel
```julia
using BenchmarkTools
#@btime solve(prob, TRBDF2()); # 33.073 s (895404 allocations: 23.87 GiB)
#warning the following solve takes a long time to compile, but afterwards is very fast.
Expand Down
37 changes: 37 additions & 0 deletions ext/SymbolicsDistributionsExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module SymbolicsDistributionsExt

using Symbolics
using Distributions
using Symbolics: Num, Arr, VartypeT, unwrap, BasicSymbolic, shape


for f in [pdf, logpdf, cdf, logcdf, quantile]
@eval function (::$(typeof(f)))(dist::Distributions.Distribution, x::Num)
$f(dist, unwrap(x))
end
@eval function (::$(typeof(f)))(dist::Distributions.Distribution, x::Arr)
$f(dist, unwrap(x))
end
@eval function (::$(typeof(f)))(dist::BasicSymbolic{VartypeT}, x::Num)
$f(dist, unwrap(x))
end
@eval function (::$(typeof(f)))(dist::BasicSymbolic{VartypeT}, x::Arr)
$f(dist, unwrap(x))
end
@eval function (::$(typeof(f)))(dist::BasicSymbolic{VartypeT}, x)
$f(dist, unwrap(x))
end
end

for f in [Distributions.Uniform, Distributions.Normal]
for (T1, T2) in Iterators.product(Iterators.repeated([Real, BasicSymbolic{VartypeT}, Num], 2)...)
if T1 != Num && T2 != Num
continue
end
@eval function (::Type{$f})(a::$T1, b::$T2)
$f(unwrap(a), unwrap(b))
end
end
end

end
Loading
Loading