Rectangles and Right Triangles

Can you find a rectangle whose perimeter equals its area?

I’ll explain one way to solve this puzzle below.

Allergy warning: this product contains algebra. May contain traces of number theory.

Let’s begin. If the sides of the rectangle are A and B, let’s call the area and perimeter S. This gives two equations:

  • The area equals S. That means AB=S.
  • The perimeter is also S. That means 2A+2B=S.

Now, I’m going to change this pair of equations into a single equation, by substituting B away.

  • The equation for the perimeter can be rearranged to give B = S/2 – A
  • If I substitute this into the equation for the area, I get A(S/2-A) = S.
  • This equation can be rearranged into a quadratic equation for A, namely 2A2 – SA + 2S = 0.

There’s no obvious way to factorise this, so I’ll fall back on the quadratic formula. There will be two solutions for A. Whichever one I pick, the other one will be B. This is the bit where I wish I could type math easily into my blog posts.

  • So, A = (S + sqrt(S2 -16S))/4
  • In other words, A = S/4 + sqrt(S2 -16S)/4

It would be nice if A was a whole number, or at least a fraction. Unfortunately, just picking random values for S rarely makes this happen. So, our rectangle puzzle has become a square number puzzle – how can we find values of S that make S2 -16S a square number?

So, let’s let S2 -16S be N2. Add 64 to both sides of this, and the left hand side factorizes:

  • If S2 -16S = N2, then
  • S2 -16S+64 = N2+82, so
  • N2+82 = (S -8)2.

Hmm. Two square numbers, adding up to give a third square number. Where have I seen that before? Hey, that’s Pythagoras’s theorem about right angled triangles! Suppose I have a right-angled triangle, with sides P, Q and R. Then,

  • P2+Q2 = R2. If I divide this all by Q2, I’ll get
  • (P/Q)2+12 = (R/Q)2. Now, I’ll multiply this by 82., to get
  • (8P/Q)2+82 = (8R/Q)2. Now, I’ll rename 8P/Q and 8R/Q. I’ll let 8P/Q be N, and 8R/Q will be S-8. Then,
  • N2+82 = (S -8)2, which is just the equation I need to solve my rectangle puzzle.

So, any pythagorean triplet – any at all – gives me a solution to my rectangle puzzle.

  • The pythagorean triplet P, Q, R gives N=8P/Q and S-8=8R/Q.
  • Then, A = (S + N)/4 and B = (S – N)/4.
  • In short, A = (8R/Q + 8 + 8P/Q)/4 and  B = (8R/Q + 8 – 8P/Q)/4.
  • These can be simplified: A = 2(R + Q – P)/Q and B = 2(R + Q – R)/Q

Let’s try this! If P=3, Q=4 and R=5, I get A = 2(5 + 4 + 3)/4 and B = 2(5 + 4 – 3)/4, that is A=6, B=3. If a rectangle has sides 6 and 3, sure enough, the area and perimeter are both 18.

I’ll try it again, with P=12, Q=5 and R=13 this time. Then, I get A=2(13 + 5 + 12)/5 and B=2(13+5-12)/5, so A=12 and B=2.4. Then, the area and perimeter are both 28.8.

You try it now, again with the 3-4-5 right triangle, but this time use P=4, Q=3 and R=5. You should get a rectangle with area (and perimeter) equal to 64/3. Then try it with a few other pythagorean triangles.

This little bit of algebra has given us a puzzle solution factory: given a pythagorean triangle, I can find a rectangle whose area and perimeter are equal.

In my opinion, that’s already a nice bit of math magic. It gets even nicer, though, but that’s a story for next time.