This is driving me nutty. I'm solving an equation from Diophantus, and I keep ending up with what appears to be wrong, and yet I can't see where. I must be messing up something pretty basic here. Help highly appreciated! Ok, the problem is:

Given a right triangle with area 7 and perimeter 12. Find it's sides.

Let x and y be the sides next to the right angle.

So, the area is

or

and perimeter is

First, I try to get rid of the radical in the second equation by isolating it on one side and squaring both sides of the equation:

I turn the first equation into

and substitute into the other equation:

Multiplying everything by x to get rid of the 336/x, I get:

However, the book (The Story of

) says it's

I must have made an error but I don't see it. I know I need to go to sleep, but I'll probably be having trouble sleeping with that bothering me.

P.S. Answers are complex, FYI.