Now, I feel like I more or less have the set-up down, e.g. take the sum of the two perimeters and solve for the radius of the circle, substitute this new found value of r into the sum of the areas followed by a load of algebra and a few derivatives, yadda yadda, ect ect (Math for this part below.) I played around with these numbers for a while until I came to what I thought was the solution. It wasn't. I ran the math a few more times and with each attempt I came to a different result. At this point I'm not sure if the set-up is wrong or if I'm making a mistake somewhere in the minutiae of the algebra. A little bit of help would be much appreciated.

4x+2πr = 100 (x equals one side of the square.)r = 100∕(4x+2π)

A = x²+πr² ("A" equals the sum of the areas of the square and circle.)

A=x²+π(100/(4x+2π))².....