@@ -95,19 +95,18 @@ also supplied.
9595
9696### Defining Derivatives of Registered Functions
9797
98- In order for symbolic differentiation to work, an overload of ` Symbolics.derivative ` is
99- required. The syntax is ` derivative(typeof(f), args::NTuple{i,Any}, ::Val{j}) ` where
100- ` i ` is the number of arguments to the function and ` j ` is which argument is being
101- differentiated. So for example:
98+ In order for symbolic differentiation to work, defining [ ` @register_derivative ` ] ( @ref ) for
99+ registered functions is required. For example,
102100
103101``` julia
104- function derivative (:: typeof (min), args:: NTuple{2,Any} , :: Val{1} )
105- x, y = args
106- ifelse (x < y, one (x), zero (x))
107- end
102+ @register_derivative min (x, y) 1 ifelse (x < y, 1 , 0 )
108103```
109104
110- is the partial derivative of the Julia ` min(x,y) ` function with respect to ` x ` .
105+ is the partial derivative of the Julia ` min(x,y) ` function with respect to ` x ` . Refer to
106+ the documentation of [ ` @register_derivative ` ] ( @ref ) for an in-depth explanation of the macro
107+ syntax.
108+
109+ Querying the rules defined using this method requires the use of [ ` @derivative_rule ` ] ( @ref ) .
111110
112111!!! note
113112 Downstream symbolic derivative functionality only work if every partial derivative that
@@ -147,6 +146,8 @@ Note that at this time array derivatives cannot be defined.
147146``` @docs
148147@register_symbolic
149148@register_array_symbolic
149+ @register_derivative
150+ @derivative_rule
150151```
151152
152153## Direct Registration API (Advanced, Experimental)
@@ -181,11 +182,12 @@ Additionally a symbolic name is required:
181182Base. nameof (interp:: AbstractInterpolation ) = :Interpolation
182183```
183184
184- The derivative is defined similarly to the macro case:
185+ With Symbolics.jl v7 we don't expose a direct API for defining derivatives. It
186+ requires using the macro.
185187
186188``` julia
187- function Symbolics . derivative (interp:: AbstractInterpolation , args :: NTuple{1, Any} , :: Val{1} )
188- Symbolics . unwrap ( derivative (interp, Symbolics . wrap (args[ 1 ])))
189+ @register_derivative (interp:: AbstractInterpolation )(x) 1 begin
190+ # ...
189191end
190192```
191193
0 commit comments