simpleAutoDiff
fun <T : Any, F : Field<T>> F.simpleAutoDiff(bindings: Map<Symbol, T>, body: SimpleAutoDiffField<T, F>.() -> AutoDiffValue<T>): DerivationResult<T>(source)
Runs differentiation and establishes SimpleAutoDiffField context inside the block of code.
The partial derivatives are placed in argument d
variable
Example:
val x by symbol // define variable(s) and their values
val y = DoubleField.withAutoDiff() { sqr(x) + 5 * x + 3 } // write formulate in deriv context
assertEquals(17.0, y.x) // the value of result (y)
assertEquals(9.0, x.d) // dy/dx
Content copied to clipboard
Return
the result of differentiation.
Parameters
body
the action in SimpleAutoDiffField context returning AutoDiffValue to differentiate with respect to.
fun <T : Any, F : Field<T>> F.simpleAutoDiff(vararg bindings: Pair<Symbol, T>, body: SimpleAutoDiffField<T, F>.() -> AutoDiffValue<T>): DerivationResult<T>(source)
fun <T : Any, F : Field<T>> simpleAutoDiff(field: F): AutoDiffProcessor<T, AutoDiffValue<T>, SimpleAutoDiffField<T, F>>(source)
Generate AutoDiffProcessor for SimpleAutoDiffExpression