constant = 0.0000001149241# The value of G(m1* m2) print("This program will compute the root of radius using bisection method.") # input the value of the graviational force Force = input() #initial guess ; initial funtions...m = f(xL)....n = f(xRO ) xL=1 xU= 5 xRO = (xL + xU ) / 2 #old value # m = f(r) = F(r^2) - G(m1* m2) m = Force * xL * xL m = float(m) - float(constant) n = float(Force) * xRO * xRO n = float(n) - float(constant) # n = f(r) = f(xrRO) #n = (Force*xRO*xRO) - constant; prod = n * m #condition when f(xL) * f(xR) is > , < and = if prod > 0: xL= float(xRO) # new value xRO = (xL + xU ) / 2 err = (xRO - xL ) / xRO #percent error while err >= 0.05: #repeat the process m = float(Force) * float(xL) * float(xL) m = float(m) - float(constant) n = float(Force) * xRO * xRO n = float(n) - float(constant) xL= float(xRO) xRO = (xL + xU ) / 2 err = (xRO - xL ) / xRO print("Root of Radius =", xRO) elif prod < 0: xU = xRO elif prod == 0: print(xRO)