dual_variable_n: Create a dual seeded for n-th order differentiation

View source: R/dual-higher.R

dual_variable_nR Documentation

Create a dual seeded for n-th order differentiation

Description

Recursively nests dual numbers to enable exact computation of derivatives up to order n. The variable is seeded so that after evaluating a function f, the k-th derivative can be extracted with deriv_n(result, k).

Usage

dual_variable_n(x, order)

Arguments

x

A numeric value at which to differentiate.

order

A positive integer specifying the derivative order.

Value

A (possibly nested) dual number.

Examples

x <- dual_variable_n(2, order = 3)
r <- x^4
deriv_n(r, 3)

nabla documentation built on Feb. 11, 2026, 1:06 a.m.