minor edits
This commit is contained in:
@@ -104,7 +104,7 @@ function D(::Val{:+}, ::Val{:nary}, args, var)
|
||||
end
|
||||
```
|
||||
|
||||
The `args` are always held in a container, so the unary method must pull out the first one. The binary case should read as: apply `D` to each of the two arguments, and then create a quoted expression containing the sum of the results. The dollar signs interpolate into the quoting. (The "primes" are unicode notation achieved through `\prime[tab]` and not operations.) The *nary* case does something similar, only uses splatting to produce the sum.
|
||||
The `args` are always held in a container, so the unary method must pull out the first one. The binary case should read as: apply `D` to each of the two arguments, and then create a quoted expression containing the sum of the results. The dollar signs interpolate into the quoting. (The "primes" are unicode notation achieved through `\prime[tab]` and not operations.) The *nary* case does something similar, only using splatting to produce the sum.
|
||||
|
||||
|
||||
Subtraction must also be implemented in a similar manner, but not for the *nary* case:
|
||||
@@ -195,7 +195,15 @@ function D(::Val{:cos}, ::Val{:unary}, args, var)
|
||||
end
|
||||
```
|
||||
|
||||
The pattern is similar for each. The `$a′` factor is needed due to the *chain rule*. The above illustrates the simple pattern necessary to add a derivative rule for a function. More could be, but for this example the above will suffice, as now the system is ready to be put to work.
|
||||
The pattern is similar for each. The `$a′` factor is needed due to the *chain rule*. The above illustrates the simple pattern necessary to add a derivative rule for a function.
|
||||
|
||||
:::{.callout-note}
|
||||
Several automatic differentiation packages use a set of rules defined following an interface spelled out in the package `ChainRules.jl`. Leveraging multi-dimensional derivatives, the chain rule is the only rule needed of the sum, product, quotient and chain rules.
|
||||
|
||||
:::
|
||||
|
||||
|
||||
More functions could be included, but for this example the above will suffice, as now the system is ready to be put to work.
|
||||
|
||||
|
||||
```{julia}
|
||||
@@ -223,5 +231,3 @@ D(D(ex₃, :x), :x)
|
||||
```
|
||||
|
||||
The length of the expression should lead to further appreciation for simplification steps taken when doing such a computation by hand.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user