If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Intro to composing functions

Learn why we'd want to compose two functions together by looking at a farming example.

Cam is a farmer. Each year he plants seeds that turn into corn. The function below gives the amount of corn, C, in kilograms (kg), that he expects to produce if he plants corn on a acres of land.
C, left parenthesis, a, right parenthesis, equals, 7500, a, minus, 1500
For example, if Cam plants two, he expects to produce C, left parenthesis, 2, right parenthesis, equals, 7500, left parenthesis, 2, right parenthesis, minus, 1500, equals, 13, comma, 500 start text, k, g, end text of corn.
What Cam really wants to know is how much money he will make from selling this corn. So he uses the following function to predict the amount of money, M, in dollars, that he will earn from selling c kilograms of corn.
M, left parenthesis, c, right parenthesis, equals, 0, point, 9, c, minus, 50
So if Cam produces 13, comma, 500, start text, space, k, g, end text of corn, he can expect to make M, left parenthesis, 13, comma, 500, right parenthesis, equals, 0, point, 9, left parenthesis, 13, comma, 500, right parenthesis, minus, 50, equals, dollar sign, 12, comma, 100.
Notice that Cam has to use two separate functions to get from acres planted to expected earnings. The first function, C, takes acres to corn, while the second function, M, takes corn to money.
Wouldn't it be great if Cam could write a function that turned planted acres directly into expected earnings?

Creating a new function

We can indeed find the function that takes acres planted directly to expected earnings! To find this new function, let's think about the most general question: how much money does Cam expect to make if he plants corn seed on a acres of land?
Well, if Cam plants corn on a acres, he expects to produce C, left parenthesis, a, right parenthesis kilograms of corn. And if he produces C, left parenthesis, a, right parenthesis kilograms of corn, he expects to make M, left parenthesis, C, left parenthesis, a, right parenthesis, right parenthesis dollars.
So, to find a general rule that converts a acres directly into expected earnings, we can find the expression M, left parenthesis, C, left parenthesis, a, right parenthesis, right parenthesis.
But just how do we do this? Well, notice that in the expression M, left parenthesis, start color #1fab54, C, left parenthesis, a, right parenthesis, end color #1fab54, right parenthesis, the input of function M is start color #1fab54, C, left parenthesis, a, right parenthesis, end color #1fab54. So, to find this expression, we can substitute start color #1fab54, C, left parenthesis, a, right parenthesis, end color #1fab54 in for start color #e07d10, c, end color #e07d10 in function M.
M(c)=0.9c50M(C(a))=0.9(C(a))50=0.9(7500a1500)50          Since C(a)=7500a1500=6750a135050=6750a1400\begin{aligned} M(\goldD c)&=0.9\goldD c-50\\\\ M({\greenD{C(a)}})&=0.9(\greenD{C(a)})-50\\ \\ &= 0.9(\greenD{7500a-1500})-50~~~~~~~~~~\small{\gray{\text{Since }}}\small{\gray{C(a)=7500a-1500} }\\\\ &= 6750a-1350-50\\\\ &=6750a-1400 \end{aligned}
So the function M, left parenthesis, C, left parenthesis, a, right parenthesis, right parenthesis, equals, 6750, a, minus, 1400 converts acres planted directly into expected earnings. Let's use this new function to predict the amount of money that Cam would make from planting corn on two acres.
M, left parenthesis, C, left parenthesis, 2, right parenthesis, right parenthesis, equals, 6750, left parenthesis, 2, right parenthesis, minus, 1400, equals, dollar sign, 12, comma, 100
Cam can expect to make dollar sign, 12, comma, 100 from planting corn on two acres of land, which is consistent with our previous work!

Defining composite functions

We just found what is called a composite function. Instead of substituting acres planted into the corn function, and then substituting the amount of corn produced into the money function, we found a function that takes the acres planted directly to the expected earnings.
We did this by substituting C, left parenthesis, a, right parenthesis into function M, or by finding M, left parenthesis, C, left parenthesis, a, right parenthesis, right parenthesis. Let's call this new function M, circle, C, which is read as "M composed with C".
We now know that left parenthesis, M, circle, C, right parenthesis, left parenthesis, a, right parenthesis, equals, M, left parenthesis, C, left parenthesis, a, right parenthesis, right parenthesis. This, in fact, is the formal definition of function composition!

Visualizing the two methods

Here's a visual to help interpret the above definition.
Using both functions C and M, function C—the corn function—takes two to 13,500. Then, function M—the money function—takes 13,500 to dollar sign12,100.
Using the composite function, we see that function M, circle, C takes two directly to dollar sign12,100.
The two are equivalent!

Now let's practice some problems.

Problem 1

Using the functions presented in the example, how much can Cam expect to earn if he sells all the corn produced on 1.5 acres?
For reference: C, left parenthesis, a, right parenthesis, equals, 7500, a, minus, 1500, M, left parenthesis, c, right parenthesis, equals, 0, point, 9, c, minus, 50 and M, left parenthesis, C, left parenthesis, a, right parenthesis, right parenthesis, equals, 6750, a, minus, 1400
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text
dollars

Problem 2

Ben is a potato farmer. The function P, left parenthesis, a, right parenthesis, equals, 25, comma, 000, a, minus, 1000 gives the amount of potatoes, P, in kilograms, that he expects to produce from planting potatoes on a acres of land. The function M, left parenthesis, p, right parenthesis, equals, 0, point, 2, p, minus, 200 gives the amount of money, M, in dollars, that Ben expects to make if he produces p kilograms of potatoes.
How much money can Ben expect to make if he sells all of the potatoes produced on the 3 acres?
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text

Problem 3

Which of the following expressions gives the amount of money that Ben expects to make if he plants potatoes on a acres of land?
Choose 1 answer:
Choose 1 answer:

Want to join the conversation?

  • aqualine sapling style avatar for user ashley santana
    where did the 1500 come from?
    (24 votes)
    Default Khan Academy avatar avatar for user
  • leaf blue style avatar for user Liah C.
    Could someone please explain where 6750a came from in Problem One? How was that number found?
    (15 votes)
    Default Khan Academy avatar avatar for user
    • stelly blue style avatar for user Kim Seidel
      The problem gave you: M(C(a))=6750a−1400
      This was created by combining the 2 functions C(a) and M(c) by making C(a) as the input to M(c). Here's how that was done...
      We were also given:
      C(a)=7500a−1500
      M(c) = 0.9c - 50
      Insert C(a) as the input into M(c) and here's what M(C(a)) looks like before simplifying:
      M(C(a))=0.9(7500a−1500)−50
      After you simplify, you get M(C(a)) = 6750a−1400

      Hope this helps.
      (1 vote)
  • duskpin seedling style avatar for user Shalaya
    How would you find the value of the function if like you had f(g(-1)) how would you put that into in equation to solve?
    (4 votes)
    Default Khan Academy avatar avatar for user
  • leaf red style avatar for user Jason Reed
    can i get some help with this its kinda getting confusing?
    (5 votes)
    Default Khan Academy avatar avatar for user
  • piceratops ultimate style avatar for user Liam Heraty
    In defining composite functions paragraph 3 it says (M*C)(a) = M(C(a)). Isn't that just multiplying functions? If it says (M*C)(a) why can't I just multiply the two functions?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • aqualine tree style avatar for user Silverleaf.yen
    How do you find the domain of a composite function?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • leaf grey style avatar for user Alex
      The domain of a composite function f(g(x)) is all x in the domain of g such that g(x) is in the domain of f.

      Let's break this down. First off, the x has to be in the domain of g; if g(x) were say 1/x, then x = 0 could not be in the composite domain. Second of all, even if g(x) is defined, it has to be in the domain of f. Say f(x) equals 1 / (x - 1). Then if you choose an x such that g(x) = 1, making f(g(x)) = 1 / 0, that x cannot be in the domain of the composite function. Hope that I helped.
      (3 votes)
  • duskpin seedling style avatar for user Alex Cail
    Problem 1
    Shouldn't you solve for C(1.5), then input that value into M(C(a)) rather than just use M(1.5)??

    For example, here's my work:
    1.5 acres
    C(1.5) = 7500(1.5) - 1500
    11250-1500 = 9750
    M(9750) = 6750(9750) - 1400
    65812500-1400 = 65811100

    I realize that the solution I came up with is unrealistic, but my method of solving seems to me to follow the method taught. So, my question is: why don't you solve it the way I did?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • orange juice squid orange style avatar for user Ace Matei
    What do I do if I have to find f(x)h(x)?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • piceratops ultimate style avatar for user Helen
    I don't understand problem 3 can anyone explain?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user programminglegend1029
      This is using the same logic as Cam and his carrot planting where with Ben for example how you would of solved problem 2 is solving how much carrots he would of planted on 3 acres of land with P(a) = 25,000a - 1000 But here we have P(3) = 25,000(3) - 1000 and we have 75,000 - 1000 which gives us 74,000 potatoes. Now we want to see how much money he can make with all those potatoes so we put that into the second equation/function M(p) -notice that the p is the amount of potatoes from P(a)
      M(p) = 0.2p - 200 But here we have M(74,000) = 0.2(74,000) - 200 which gives us
      14,800 - 200 and we finally have 14,600 or in this case $14,600

      But instead if switching the answer of one function into another we can compose or combine the two like since we want to find the amount of money from 3 acres of land we can start with M(p) but we can use the potatoes function as the input like M( p(a) ) but note that this is still basically going back and forth with the both of them but now we can input it into the function M to get M( p(a) ) = 0.2 ( p(a) - 200 and p(a) is 25,000a - 1000 right? So now we can use that and get M ( p(a) ) = 0.2 ( 25,000a - 1000 ) - 200

      Now we can expand the parenthesis and finally get M ( p(a) ) = 5000a - 200 - 200 which we can combine the like terms to get M ( p(a) ) = 5000a - 400

      When you put 3 into that you have 15,000 - 400 which is 14,600 or also $14,600

      -Note you could put the function P equation in the M domain slot but it easier to write it as P(a) and easier to read and understand what it is.

      --Hope this helps :)
      (2 votes)
  • duskpin ultimate style avatar for user Jonathan
    Just to clarify one thing: if (f o g) (x) is equal to f(g(x)), then would (f o g o h) (x) be equal to f(g(h(x)))? Thanks!
    (1 vote)
    Default Khan Academy avatar avatar for user