Turing Machines as Functions
Explore how Turing machines compute functions by manipulating unary and binary numbers on the tape. Understand implementations for modulo calculations, addition, rounding, and division by two. This lesson clarifies Turing machine design, state transitions, and function outputs using various examples.
Turing machines can also act as functions by leaving output on the tape. The following computes . We encode numbers in unary notation, so , etc. The idea is to use two states for evenness vs. oddness and then leave either a or on the tape.
States and change all 's to blanks. The state is the halt state. When a number is even, a blank will eventually appear while in state , so we erase all the ’s and leave a on the tape. From , we end up leaving a . There is no need for an accepting state since the machine produces output.
Adding two numbers
It is easy to add ...