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(a)=7500a1500
For example, if Cam plants two acres, he expects to produce C(2)=7500(2)1500=13,500 kg 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(c)=0.9c50
So if Cam produces 13,500 kg of corn, he can expect to make M(13,500)=0.9(13,500)50=$12,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(a) kilograms of corn. And if he produces C(a) kilograms of corn, he expects to make M(C(a)) dollars.
So, to find a general rule that converts a acres directly into expected earnings, we can find the expression M(C(a)).
But just how do we do this? Well, notice that in the expression M(C(a)), the input of function M is C(a). So, to find this expression, we can substitute C(a) in for c in function M.
M(c)=0.9c50M(C(a))=0.9(C(a))50=0.9(7500a1500)50          Since C(a)=7500a1500=6750a135050=6750a1400
So the function M(C(a))=6750a1400 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(C(2))=6750(2)1400=$12,100
Cam can expect to make $12,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(a) into function M, or by finding M(C(a)). Let's call this new function MC, which is read as "M composed with C".
We now know that (MC)(a)=M(C(a)). 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 $12,100.
Using the composite function, we see that function MC takes two directly to $12,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(a)=7500a1500, M(c)=0.9c50 and M(C(a))=6750a1400
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3/5
  • a simplified improper fraction, like 7/4
  • a mixed number, like 1 3/4
  • an exact decimal, like 0.75
  • a multiple of pi, like 12 pi or 2/3 pi
dollars

Problem 2

Ben is a potato farmer. The function P(a)=25,000a1000 gives the amount of potatoes, P, in kilograms, that he expects to produce from planting potatoes on a acres of land. The function M(p)=0.2p200 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/5
  • a simplified improper fraction, like 7/4
  • a mixed number, like 1 3/4
  • an exact decimal, like 0.75
  • a multiple of pi, like 12 pi or 2/3 pi

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:

Want to join the conversation?

  • aqualine sapling style avatar for user ashley santana
    where did the 1500 come from?
    (30 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?
    (16 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.
      (52 votes)
  • blobby green style avatar for user avs68325
    Why create and use composite functions when you can just break it down to simpler and smaller equations which still give you the correct answer?
    (12 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user KayleeS415
    im lost how it became 5000a-400...
    (8 votes)
    Default Khan Academy avatar avatar for user
    • starky sapling style avatar for user mail4kissy
      the function was M(p)=0.2p-200 to start with. In order to make the function relate acres(a) to money(M), we must put the two relevent equations together. To do this, we multiply the function for Money(M) by the function for acres. So we get this: M(p(a))=o.2(25,000a-1000)-200. (we replaced the (p) on both sides of the equation with the function (p(a)).) Then from there all we need to do is just multiply 25000a and -1000 by o.2. When we do this we get M(p(a))=5000a-200-200. Then we just add -200 to -200, and that gives us M(p(a))=5000a-400.
      Hope this helps! :)
      (25 votes)
  • male robot hal style avatar for user Kobe M
    I noticed that the first problem with the corn has the function 6750a-1400 where the 1400 came from subtracting 50 from 1350. If I'm not mistaken, subtracting 50 from 1350 is actually 1300
    (1 vote)
    Default Khan Academy avatar avatar for user
    • stelly blue style avatar for user Kim Seidel
      The 1350 is "-1350", you are treating it as "+1350".
      -1350-50 = -1400
      When the 2 numbers have the same sign, we add them and keep the common sign. Or, consider a number line. If you are at -1350 and need to subtrct 50, you move further left to -1400.

      Hope this helps.
      (23 votes)
  • aqualine ultimate style avatar for user Claire Jung
    For the example equation on the top, does the lowercase "c" refer to "C(a)"? Does c = C(a)? If so, is it a rule to make it lowercase and why :(
    (6 votes)
    Default Khan Academy avatar avatar for user
    • stelly blue style avatar for user Kim Seidel
      Capital C is the name of the function that calculates kg of corn from planting "a" acres of corn.

      lowercase "c" is the variable used in the next function: M(c). It represents the input into function M. It happens to also represent kg of corn. This was done to help you see linkage opportunities between the functions. But, they do mean different things. "C" is name of a function, and "c" is the input to a different function.
      (10 votes)
  • 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?
    (5 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?
    (6 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.
      (8 votes)
  • leafers ultimate style avatar for user Lambert,Blaze
    My question is why do we have to cram everything into one function when even though it might take longer, we could do the separate functions and solve it like that? I wish there was an article about that too because it would make more sense to me.
    (6 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user Hudjefa
      A good question. Different strokes for different folks. The received wisdom seems to be that reducing the number of steps in arriving at a solution to a problem is better.
      Imagine if f(x) = 4x^2 and g(x) = sqrt(x)
      g(f(x)) = g(4x^2) = sqrt(4x^2) = 2x
      The composite function g(x) = 2x is many orders of magnitude simpler than doing f(x) first and then g(x), especially if x is very large or, as I saw in in article on Khan Academy, x is not a "nice" number (e.g. x could be pi or 2.3727).

      However, if f(x) = 2(sqrt x) and g(x) = 9x^3, there's no harm in not composing the two into one composite function. g(f(x)) = g(2*sqrt x) = 9(2*sqrt x)^3, that's a lot of keystrokes on a calculator and easy to make (silly) mistakes.
      (7 votes)
  • leaf red style avatar for user Jason Reed
    can i get some help with this its kinda getting confusing?
    (7 votes)
    Default Khan Academy avatar avatar for user