### How to compose two functions

Suppose I have a function f(x)=x^2+1

What is the command to compose it with itself twice or thrice?

I was using:

f= (x^2+1)

g= lambda t: (t^2+1)

f(*g)

or

sage: g = lambda t: (t^2+1)
sage: f = lambda x: (x^+1)
sage: f(*g(t))

or

sage: x = var('x')
sage: f=x^2+1
sage: compose(f, 3, x)

Nothing works! Also, I don't know how to use the Dynamical system code in this case here.

Also, it would be of great help if you can give me one example command for the composition of two different functions
e.g f(x)=x^2+1 and g(x)=x^3+2 if it is not obvious from the answer of the composition of the same function twice.