# Solving for Intersection of a Line and a Circle

I have the equation $$-r + y = ys$$

$s$ and $r$ are both known values and I'm trying to solve for $y$ but have been unsuccessful. How is this equation solved?

I've gotten it to $y = (y - (-r/s)) s$ but just seem to be running in circles.

The context around this question is that I'm trying to find the intersections of a line and a circle. $r$ is radius and $s$ is slope. $y$ is the $y$ position of the intersection. This is the equation for one of the solutions.

So you want to isolate the "y" term. These are the general rules. They should usually work although they may get a bit more intricate.

1) Isolate the y.

1a) Get all the y terms to one side of the equation and all the non- y terms to the other:

$-r + y = ys$

$-r + y - ys = 0$

$y - ys = r$

1b) Continue to isolate a single y term by factoring out the common y from all the y terms.

$y- ys = y*1 - y*s = y(1-s)$

so

$y(1 - s) = r$

1c) Finalize isolating the y by dividing away "everything not y" to the other side. (But always make a note you can not divide by 0).

$y(1-s) = r$

$y = \frac r{1-s}$; if $s \ne 1$.

2) Postscript describe the case where "everything not y" was zero.

If $s = 1$ then $y(1-s) = r \implies y*0 = r \implies r = 0$ and $y$ may be any value whatsoever. So solutions are $y = \frac r{1-s}$; if $s \ne 1$ or $y$ may be any value but $r = 0$ if $s = 1$.

That should always work for linear (single power) equations at least. The principal will be the same for how powered equations but it might require more tricks to isolate the y.

First subtract $y$ on both sides, $$-r=ys-y.$$ Then, factorize the right-hand side, $$-r=y(s-1).$$ Then, you can divide both sides by $(s-1)$ to get $$\frac{-r}{s-1}=y.$$ This works as long as $s\neq 1$.