DerivativeNumber implements forward automatic differentiation.
It follows Jerzy Karczmarczuk 1998, "Functional differentiation of computer programs".
In order to find the derivative of a function, there are three approaches:
Calling operations on derivatives apply the chain rule and keep track of resulting reals and derivatives:
This is valid for Arrays:
It is also valid for UGens:
Return a new instance.
real |
The real part of the number, which may be any number class or a UGen. |
derivative |
The derivative part of the number, which may be any number class or a UGen. |
Approximate a derivative numerically where no automatic method is implemented yet. Numerical approximation may fail to converge well in some cases, so you can't rely on it.
Return the real part of the number, which carries the result of any past operations.
Return the derivative part of the number, which carries the derivative that follows from all past operations.
Returns true if the real part of the receiver is smaller than the real part of the argument.
A delta that can be used for approximating a derivative numerically where no automatic method is implemented yet. It can be adjusted to improve this approximation.
Convert receiver to a DerivativeNumber
. In this case, it is already one, so return this
. For other classes, it returns DerivativeNumber(receiver, 0)
Returns a Complex with the real part as the receiver, and the imaginary part as DerivativeNumber(0, 0)
.
Returns a Complex with rho
(radius) as the receiver and theta
as DerivativeNumber(0, 0)
.
Returns a Point with the x coordinate as the receiver and the y coordinate as DerivativeNumber(0, 0)
.
You need the UnitTest class to run these.