Let us take a and b on a line.
We have to find out the square so let us make a square like this:
Let us now mark the points a and b on this square:
Connecting the dots we get this:
Now we can find out the area of squares and rectangles:
Now what we have got finally is this: