Interactivate


Multi-Step Functions


Shodor > Interactivate > Discussions > Multi-Step Functions

Student: So now I know all about building functions with variables! This isn't so bad!

Mentor: Well, what you have actually learned so far is what a simple, one-step function is like. This is just a small part of a bigger picture. The next type of function we should look at is a multi-step function. Do you think you can give me an example of a multi-step function?

Student: Let me think. What about taking a number, adding 1 to it and then multiplying by 3?

Mentor: That's right! Now how would you write that using the variables x and y?

Student:

        x + 1 * 3 = y ?
      

Mentor: Sort of. We need to be a little careful here, so that the person using the function knows to add first and then multiply. Mathematicians realized a long time ago (in the fifteenth century as algebra was being used more and more) that there needed to be rules about how to write anything with more than one operation so there would be no ambiguity. A standard evolved for the order of operations, which we still follow today:

  1. Do all parentheses first
  2. All exponents next
  3. Then comes multiplication and division from left to right
  4. Save all additions and subtractions for last and compute those left to right

Student: So for clarity I need to write it as

          y = (x + 1) * 3
        

Mentor: Yes. You can also write the same equation these other ways:

            y = 3 * (x + 1)
          

            y = 3(x + 1)
          

            y = 3 * x + 3
          

            y = 3x + 3
          

Student: Well, each one gives the same output using 3 as an input.

Mentor: That's true, but we have seen functions that are different for some numbers and the same for others. For example, y = x + 6 and y = 3 * x both give 9 as an output when 3 is the input. Can you explain it another way?

Student: Well, for the functions you just named, the output is only the same for the input 3, where the functions you gave earlier are the same for any input.

Mentor: Good observation. So they are all the same because they are rearrangements that follow arithmetic properties. These properties say:

  • We can multiply or add two numbers in any order. This is the commutative property.
  • We can distribute multiplication across addition. This is the distributive property.

Student: So the same function can have different forms?

Mentor: Exactly - and when we allow more complicated things, like many more than just one or two operations, and include exponentiation in the list, checking that two functions are equivalent becomes more challenging.


a resource from CSERD, a pathway portal of NSDL NSDL CSERD