# Is there a shortcut command to iterate an endomorphism?

Suppose $f$ is a function from some set to itself. Is there a shortcut command in sage to compute an iterated composition of $f$, such as $f^3(x)=f(f(f(x)))$ where I could type something like `f^3(x)`

into the console, and more generally for computing $f^n(x)$ for a given $n$?

Welcome to Ask Sage!

Thank you for your question.

Ideally, provide an explicit

`f`

,`x`

,`n`

to get others started on your question.Two previous related questions:

Ask Sage question 35989: Apply functions iteratively

Ask Sage question 36159: Apply functions iteratively (modified re-post)

One keyword: dynamical systems.