4.472135954999579*R is the Max perimeter
0.8944272*R is the value for x
note: the downside of this method is there is no easy way to see that the answer is 2*sqrt(5)*R, as noted in the previous solutions.
def y(a):
""" enter x value and return the y value for a circle of radius 1
centered at the origin """
return (1a**2)**(1/2)
def perim(a):
""" enter the x value and return the perimeter of a rectangle
inscribed in a half circle of radius 1 """
return (4*a + 2*(y(a)))
n = 10000000
x=0
maxPerim = 0
for i in range(1,n):
newPerim = perim(i/n)
if newPerim > maxPerim:
maxPerim=newPerim
x = i/n
print(x, maxPerim)

Posted by Larry
on 20191118 16:30:22 