Ask Your Question
0

How to compose two functions

asked 2020-02-29 04:21:11 +0100

Arnab gravatar image

updated 2020-02-29 04:30:07 +0100

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-02-29 05:59:33 +0100

dsejas gravatar image

updated 2020-02-29 17:13:08 +0100

Hello, @Arnab! I suppose the following is the answer you're looking for. First define $f$:

f(x) = x^2 + 1

Now compose simply by writing:

f2(x) = f(f(x))
f3(x) = f(f(f(x)))

As you might guess, $f2$ is the composition $f\circ f$ ($f$ with itself), while $f3$ is the composition $f\circ f\circ f$ (three times $f$).

The same mechanism works for different functions. Let's define

f(x) = x^2 + 1
g(t) = t^3

Then you can write

fg(t) = f(g(t))
gf(x) = g(f(x))

The first one will give you $t^6+1$, while the second will give you $(x^2+1)^3$.

I hope this helps!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-02-29 04:21:11 +0100

Seen: 1,646 times

Last updated: Feb 29 '20