views:

221

answers:

1

I'm working on a project for a Turning machine but having problems conceptualizing the steps.

f(x) = x^3, where x is a single digit between 0 - 9 inclusive.

Based on my understanding I am to convert the number to binary but how do I find the cube of a number in binary.

Also, how do I write the cube on the tape.

So far I'm thinking I should create a state diagram that accepts the binary versions of 0-9 but what next?

+1  A: 

I would do it like this:

  • Write a copy of the number to the left of your current number
  • Write another copy to the left of that
  • Multiply the original number with the first copy, erasing the copy
  • Multiply the result by the second copy, erasing that

You will need to write a copy and a multiply "subroutine" (using states) and jump into those by setting the right states. But I think this should be doable (if a lot of work). But probably less work than encoding all cubes from 0 to 9.

Robert Kosara
How do I go about writing a copy? As far as I know the transition for a turing machine is usually in the form {0, 1 -> R} {where you read in a digit, replace it with something else and move on.} Can I write two digits, e.g. {0, 11 -> R}?
Julian
No. I think you would need to read the digit, remember it in the state, find the end of the copy, and append it.
Robert Kosara