show that area of rectangle with fixed perimeter is greatest when rectangle is square

Hi

I have a question which asks you to show that, if the perimeter of a rectangle is fixed in length, the area of the rectangle is greatest when it is square. There is no answer to this in my book so I was hoping you could see if I have done it right....

A rectangle has 4 sides, 2 of length a and 2 of length b
The perimeter, P = 2a + 2b
a = P/2 - b
b = P/2 - a

The area of a rectangle, A, is a*b. Substituting b for P/2 -a:
A = a(P/2 - a)
A = Pa/2 - a^2

dA/da = P/2 - 2a

This function has a stationary point (maximum) when Da/da = 0
P/2 - 2a = 0
a = P/4

In other words the function for the area has a maximum when a = P/4, or when the length of the side is a quarter of the perimeter, or the rectangle has 4 sides of equal length (a square)

The second derivative of dA/da = P/2 - 2a
d^2A/da^2 = -2. If this is negative then the stationary point is going from positive to negative so it's a maximum point (and not a minimum or point of inflection)

And you can plot this: A = Pa/2 - a^2 for P = 4 or 8