### Thread: Calculating x with equation ...problem

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
May 2013
Posts
5
Rep Power
0

#### Calculating x with equation ...problem

y = random.randrange(100,300)
#(x-200)**2 + (x-200)**2 = 1000...this is common circle equation
# so in my code i want to put x on one side of equation and all except x to other side
#if a do a little math...x**2 -400x + 40000= 1000-(y-200)**2
#x**2= 1000-(y-200)**2 + 400x - 40000

#there is problem...x just cant stand alone...whatever i would make, x can not be alone....theres always second x which calls for error when i start program because that second x isnt yet defined
#THANKS FOR ANY ADVICE HOW TO CALCULATE X IN THIS EQUATION SO PYTHON WOULDNT CALL FOR ERROR
2. Code:
```(x-x0)**2 + (y-y0)**2 == r**2      # equation of circle

(x-x0)**2  == r**2 - (y-y0)**2     # subtract (y-y0)**2 from each side

(x-x0)  == +sqrt(r**2 - (y-y0)**2)    # taking the square root of each side

(x-x0)  == -sqrt(r**2 - (y-y0)**2)    # gives two solutions at each value of y

# next add x0 to each side

# Therefor, given r and y, x0 and y0,

x  == x0+sqrt(r**2 - (y-y0)**2)
x  == x0-sqrt(r**2 - (y-y0)**2)```