You can solve this problem using fsolve,
from scipy.optimize import fsolve
def f1(x, y, h, k, r):
return (x - h)**2 + (y - k)**2 - r**2
def f2(x, y, x1, y1, m):
return y - y1 - m * (x - x1)
# Combine the functions in a form that can be consumed by fsolve
def f(x, x1, y1, m, h, k, r):
return (f1(x[0], x[1], h, k, r), f2(x[0], x[1], x1, y1, m))
h = 1
k = 2
r = 4
x1 = 0
y1 = 1
m = 3
# Using a made up initial starting point of (1,1)
x, y = fsolve(f, (1,1), (x1, y1, m, h, k, r))
# Verify that the solution results in zeros
print(f1(x, y, h, k, r))
print(f2(x, y, x1, y1, m))
One thing to watch for is that the f() function returns the output from f1 and f2 as a tuple because it is required to match the dimension of the input.
The result of fsolve will be one of the solutions to the equations (assuming success). The solution found will depend upon the initial condition used.