## Join us for conversations that inspire, recognize, and encourage innovation and best practices in the education profession.

**Available on Apple Podcasts, Spotify, Google Podcasts, and more.**

- About Function Machines
- Running a Function Machine
- Function Machines and Undoing

When thinking about inputs and outputs, you are thinking about algorithms as *functions: *You *input* a number into the algorithm, follow the prescribed steps, and get an *output.* To be a function, there are two requirements. First, the algorithm must be consistent — that is, every time you give it the same input, you get the same output. Second, each input must produce exactly one possible output.

**Note 4**

Some people picture the steps in an algorithm or function as little machines. An addition machine would look like this:

If you put a 5 in the left hopper and a 4 in the right hopper, what would come out of the bottom? Take a few minutes to practice drawing your own machines.

Sometimes we want our machine to add the same thing each time. If we wanted our machine to add 3 each time, we could represent it with the 3 locked in position, like this:

We can also connect two different machines together to make a network, so that that the output hopper from one machine goes right into the input hopper on the next machine. Consider this network of function machines:

Try running a few numbers through this network. Remember to perform each step in order. For example, if you start with zero, you will get 3 as an output from the first machine. After running 3 though the second machine, your output will be 6, which is the output of the network.

Now try pulling a number back up through the machine in the reverse order — that is, begin with the output and work backward to the input.

Take a look at this algorithm (let’s call it *Algorithm C*):

- Pick a number (that’s the input)
- Multiply it by 2
- Add 3 to the answer
- Multiply that answer by 10
- Add 6
- Finally, divide by 2

Draw a function machine network or print out a copy of the function machine network below to help you answer Problems C1 – C5.

If the input to Algorithm C is 3, what is the output?

If the output to Algorithm C is 88, can you determine what the input was? How did you do it?

Use the Interactive Activity to build Algorithm D, which undoes Algorithm C. How would this help with Problem C2?

Imagine that Algorithm C and Algorithm D are connected to form one large network. What would happen to a number used as an input in this network? Think about it for a few minutes, and try a few numbers if you need to.

Connecting the two networks gets you back to your original number. Going through all these steps turns out to be a complicated way of doing nothing to a number!

See if you can use the function machines network to produce the following outputs: 59, 216, 15625, 7280, 0.12345. As an additional challenge, use the fewest possible machines to do so.

Think back for a minute to Algorithm A, which we worked with in Part B. Take a look at the following picture of Algorithm A and answer Problems C6-C10 below.

**Problem C6**

Imagine dropping a 7 into this network. What comes out the bottom?

**Problem C7**

Imagine that an 8 came out the bottom. Pull it back through the network and figure out what had to go in the top.

*Tip: Try to think of an efficient way of solving this problem. *

**Problem C8**

Imagine that a 100 came out the bottom. Pull it back through the network and figure out what had to go in the top.

**Problem C9**

Draw a picture using machines to show Algorithm B, the algorithm that “undoes” Algorithm A.

**Problem C10**

Imagine connecting the output spout of Algorithm A to the input hopper of Algorithm B. Now you have a huge network. What does it do to a number?

*Tip: Problem C10 is a lot like Problem C4.*

Video Segment
In this segment, Deanna and Lolita present the combined network built by connecting Algorithms A and B. Watch the segment after you have completed Problem C10. If you get stuck on the problem, you can watch the video segment to help you. Do you think every network built by function machines can be “undone”? You can find this segment on the session video, approximately 13 minutes and 1 second after the Annenberg Media logo. |

**Problem C11: Write and Reflect**

Suppose someone hands you an algorithm. Describe a general process that will allow you to construct a new algorithm that undoes the one you are given. Can you imagine an algorithm for which your method doesn’t work?

**Note 4**

We mentioned earlier that moving from arithmetic to algebra involves a focus on operations rather than numbers. Think about an operation like addition. What do you see when you think about addition? Don’t think of an addition problem like 4 + 5, but just plain addition with no numbers — focus on the operation rather than on the numbers themselves.

Next, go through the descriptions of input/output machines. After looking at the first example, be creative in coming up with drawings of machines.

**Groups:** Share drawings with the whole group.

Some machines add the same thing each time. Machines like this can be connected together, so that the output hopper from one machine goes right into the input hopper on the next machine. The two connected machines are really a single function that takes an input, runs it through the network inside, and produces an output. Read through the next written description of an algorithm and go through the exercises.

The two connected machines are really a single function that takes an input, runs it through the network inside, and produces an output.

Read through the next written description of an algorithm and go through the exercises.

**Groups:** Answer Problems C1-C11 in pairs or small groups.

**Problem C1**

The number 48 will come out at the bottom.

**Problem C2**

Try to undo the steps. The original number was 7.

**Problem C3**

The order of operations is: multiply by 2, subtract 6, divide by 10, subtract3, divide by 2. Algorithm D is the inverse of Algorithm C, so using 88 as the input for Algorithm D would answer Problem C2.

**Problem C4**

The huge Algorithm CD doesn’t do anything; its output numbers will equal its input numbers.

**Problem C5**

All of them are possible in multiple ways.

- 59 = 10 x 5 + 9
- 216 = 6 x 6 x 6
- 15625 = 5 x 5 x 5 x 5 x 5 x 5
- 7280 = 9 x 9 x 9 x 10 – 10
- 0.12345 = [(1 / 9) / 9] x 10

**Problem C6**

The output will be 4

**Problem C7**

Use Algorithm B, which undoes Algorithm A. The input was 8.

**Problem C8**

Using Algorithm B, the input was 31.

**Problem C9**

**Problem C10**

It will leave the number unchanged, since A and B undo each other.

**Problem C11**

If you can list the algorithm as a series of steps involving unchanging numerical operations (like “add 6”), then they can be undone by an algorithm which performs the inverse operation, and where the steps are performed in reverse order. Unfortunately, some operations do not have inverses, like squaring or throwing a water balloon. Think of Mr. Lewis’s rule from Session 2 — this is a rule that cannot be undone.