Learn R Programming

vfunc (version 1.0)

pow: Iterated functions; functional powers

Description

Given a function \(f\colon X\longrightarrow X\), we define

$$f^0 = \mathrm{id_X}$$

$$f^{n+1} = f\circ f^n=f^n\circ f,\qquad n\geqslant 0$$

This gives us \(f^{n+m}=f^n\circ f^m\) and \(\left(f^m\right)^n=f^{mn}\), which motivates the notation. For example, \(\sin^3=\sin\circ\sin\circ\sin\), so \(\sin^3(x)=\sin(\sin(\sin x))\).

The operator is well-defined due to the power associativity of function composition.

Usage

pow(x, n)

Value

Returns an object of class vf

Arguments

x

Object of class vf

n

Non-negative integer

Author

Robin K. S. Hankin

Examples

Run this code

pow(Sin,5)
Sin^5

f <- as.vf(function(x){x^2+1})

pow(f + Sin,4)
pow(f + Sin,4)(2)

Run the code above in your browser using DataLab