# document.write (document.title)

 Math Help > Trigonometry > Trig Equivalences > Broken Calculator Puzzle

Suppose you had a calculator that is broken so that the only keys that still work are the sin, cos, tan, sin-1, cos-1, and tan-1 buttons.  The display initially shows 0.  Given any positive rational number q, show that pressing some finite sequence of buttons will yield q.  Assume that the calculator does real number calculations with infinite precision.

This was the puzzle posed on the "nrich.maths.org" message board by a user I'll call "T".

Naturally, I got out my "calculator" (an Excel spreadsheet) and started "banging away" at these trig functions.  I found a few rational numbers, but no recognizable pattern.  Then another person I'll call "D" suggested using the following pairs of keys: tan-1 sin, and tan-1 cos.  He pointed out that

cos(tan-1(cos(tan-1(sin(tan-1(sin(tan-1(cos(tan-1(sin(tan-1(cos(0))))))))))))) = 3/4

As shorthand, D suggested starting by pressing the cos key to make the display read "1", and then he used the notation

cTcTsTsTcTsT(1) = 3/4

Using that notation, I refined my efforts, and found a few dozen rational numbers, the first few of which are

sTsTsT(1) = 1/2
sTcTsTsTsT(1) = 2/3
cTcTsTsTcTsT(1) = 3/4
sTcTcTsTsTcTsT(1) = 3/5
cTcTcTsTsTcTsT(1) = 4/5
sTsTsTsTsTsTsTsT(1) = 1/3
cTsTcTsTsTcTcTsT(1) = 5/6
sTsTsTsTsTcTsTsTsT(1) = 2/5
sTcTcTcTsTsTcTcTsT(1) = 5/8

Finding so many rational numbers, I began to believe the implication of the question, namely that any rational number between 0 and 1 could be made this way.

. . . . . .     a diagram of the triangle should be put here, with sides labeled sqrt(a+b) (hypotenuse), sqrt(a) (vertical side), and sqrt(b) horizontal side.

D, you're right. It's much clearer now. If I label the three sides of a right triangle with the lengths sqrt(a), sqrt(b) and sqrt(a+b), then I see right away that

sin(arctan(sqrt(a/b))) = sqrt(a/(a+b))

and

cos(arctan(sqrt(a/b))) = sqrt(b/(a+b))

sT(sqrt(a/b)) = sqrt(a/(a+b))

and

cT(sqrt(a/b)) = sqrt(b/(a+b))

I feel I'm almost there (are you with me, T?) so don't give any more hints until Monday at the earliest, not even in white -- I'm very weak-willed. I'm still struggling with getting the display to show rational numbers larger than 1. Shhhh.

OK, I got it.

tan(arccos(sqrt(b/(a+b))) = sqrt(a/b)

In fact, tan(arccos(sin(arctan(a/b)))) = b/a

For that matter, tan(arcsin(cos(arctan(a/b)))) = b/a

. . . . . .    The material above needs to be made much more clear, and then a description of the reverse process needs to be made, perhaps with reference to a triangle with sides sqrt(b) (hypotenuse), sqrt(a) (horizontal leg) and sqrt(b-a) vertical leg.

### Recipe for displaying a rational number

To follow this recipe, it's easiest to imagine running the whole thing backwards.  That is, start with the desired rational number displayed on the calculator.  Then, following a series of key presses, end with 0 displayed on the calculator.  Then, after you have imagined that, play the whole thing back in reverse order, using the inverse keys.

For example, to find the recipe for 4/3, express 4/3 as sqrt(16/9) and imagine this number displayed on the calculator's screen.

Then, if you pressed arctan, sin, the display would show sqrt(16/25)
Then, if you pressed arccos, tan, the display would show sqrt(9/16)
Then, if you pressed arccos, tan, the display would show sqrt(7/9)
Then, if you pressed arccos, tan, the display would show sqrt(2/7)
Then, if you pressed arcsin, tan, the display would show sqrt(2/5)
Then, if you pressed arcsin, tan, the display would show sqrt(2/3)
Then, if you pressed arccos, tan, the display would show sqrt(1/2)
Then, if you pressed arcsin, tan, the display would show sqrt(1/1)
Then, if you pressed arccos, the display would show 0.

To show this method works for 4/3, observe that if you play it backwards using the inverse functions each time, the calculator starts with 0, and ends showing 4/3 on its display.  Starting with the display showing 0,

Press cos -- sqrt(1/1)
Press arctan sin -- sqrt(1/2)
Press arctan cos -- sqrt(2/3)
Press arctan sin -- sqrt(2/5)
Press arctan sin -- sqrt(2/7)
Press arctan cos -- sqrt(7/9)
Press arctan cos -- sqrt(9/16)
Press arctan cos -- sqrt(16/25)
Press arcsin tan -- sqrt(16/9), or 4/3

Since all function keys have corresponding inverse functions, it is clear that finding a method that gets us from any rational number to 0 lets us find the corresponding inverse method that gets us from 0 to that rational number.  We showed in the previous section that given any number that can be expressed as sqrt(a/b), a,b nonnegative integers, we can press two keys to get sqrt(a'/b'), with a' <= b'.  Then, given sqrt(a/b), with a <= b, we can always press two keys to get sqrt(a/b) with a' <= b' < b.  So, after a finite number of key presses, we will have a' = 0.  Then, since any rational number can be expressed as sqrt(a/b), it's just a matter of playing it backwards.

The rules, starting with sqrt(a/b) on the display

These rules allow us to go backwards from a number expressed as sqrt(a/b) to similarly expressed numbers with successively smaller denominators, finally ending in zero.  (We will assume a and b are coprime -- that is, a/b is in lowest terms.)

If b < a then press arctan, sin to get a' = a, and b' = a+b

If a = b then press arccos to get a' = 0

If b/2 < a < b then press arccos, tan to get a' = b-a, and b' = a

If 0 < a <= b/2 then press arcsin, tan to get a' = a, and b' = b-a

The first rule might need to be applied just once, at the beginning.  The second rule will need to be applied just once, at the end.  The last two rules are applied repetitively, each time reducing the denominator, b', so that it will eventually be 1.  And since a' <= b', we will have a' = 1 as well, allowing the process to end with the second rule.

Then, as the rules are reversible, given a sequence of key-presses that take us from any given number to 0, that sequence can be reversed (using the inverse functions) to start from 0 to get that given number.

### Related Pages in this website

Trig Identities

Special Angles

Puzzle: A set of rational numbers

The webmaster and author of this Math Help site is Graeme McRae.