Implements round and signif for dual numbers. These are piecewise constant functions, so the derivative is zero almost everywhere.

# S4 method for class 'dualr'
Math2(x, digits)

Arguments

x

A dual number.

digits

Integer; number of digits for rounding.

Value

A dual with the rounded value and zero derivative.

Examples

x <- dual_variable(3.14159)
value(round(x, 2))  # 3.14
#> [1] 3.14
deriv(round(x, 2))  # 0 (piecewise constant)
#> [1] 0