@@
-- iterate a functionf@@n
represents the n
-fold iterate x
-> f(f(...(f(x))...))
of the function f
.
f @@
n _fnest(f, n)
f |
- | a function |
n |
- | an integer |
a function
@
, fp::fixargs
, fp::nest
, fp::nestvals
, fp::fold
f@@n
is equivalent to the call
_fnest(f, n)
.n
, f@@n
is also equivalent
to _fconcat(f $
n)
.f@@0
returns the identity map id
.f
is a function
environment with the slot "inverse"
set,
n
can also be negative. Cf. example 2.fp::fixargs
is a handy tool for
converting functions with parameters to univariate functions which may
be suitable for iteration. Cf. example 3.For a nonnegative integer n
,
f@@n
is equivalent to an _fconcat
call:
>> f@@4, (f@@4)(x)
f@f@f@f, f(f(f(f(x))))
@@
simplifies the composition of symbolic
iterates:
>> (f@@n)@@m
f@@(m n)
The iterate may be called like any other MuPAD
function. If f
evaluates to a procedure and n
to an integer, a corresponding value is computed:
>> f := x -> x^2: (f@@n)(x) $ n = 0..10
2 4 8 16 32 64 128 256 512 1024 x, x , x , x , x , x , x , x , x , x , x
>> delete f:
For functions with a known inverse function,
n
may be negative. The function f
must have
been declared as a function environment
with the "inverse"
slot. Examples of such functions
include the trigonometric functions which are implemented as function
environments in MuPAD:
>> sin::"inverse", sin@@-3, (sin@@(-3))(x)
"arcsin", arcsin@arcsin@arcsin, arcsin(arcsin(arcsin(x)))
@@
can only be used for functions that
accept their own output domain as an input, i.e., f:M M for
some set M. If you want to use @@
with a
function which needs additional parameters, fp::fixargs
is a handy tool to generate
a corresponding univariate function. In the following call, the
function f: x -> g(x, p)
is iterated:
>> g := (x, y) -> x^2 + y: f := fp::fixargs(g, 1, p): (f@@4)(x)
2 2 2 2 p + (p + (p + (p + x ) ) )
>> delete g, f:
repcom
"inverse"
is now used.