General form for finding tangent that intersects a point not on the curve

Particular cases of this problem have previously been addressed here and here, but I'm interested in the general case of the following problem:

Given a function $f(x)$ and a point $P = (x_0, y_0)$, find all tangents to $f(x)$ that pass through $P$.

I tried to work on this on my own, and using point-slope form of lines I found:

$$f(x) - y_0 = f'(x)(x - x_0)$$

Replacing $f(x)$ with $y$ and $f'(x)$ with $y'$:

$$y - y_0 = y' (x - x_0)$$

$$y' = \frac{y - y_0}{x - x_0}$$

Trying to get it into the friendly form of a first-order linear differential equation:

$$y' - \frac{y}{x - x_0} = -\frac{y_0}{x - x_0}$$

$$y' + \frac{y}{x_0 - x} = \frac{y_0}{x_0 - x}$$

But when I worked this out, I found $y = y_0$, which doesn't seem right, but my differential equation skills are admittedly very rusty.

How do I find the tangents through $P$? What properties of $f(x)$ and $P$ make a solution unique or nonexistent? Where could I learn more about this problem?

The question has not a formula as an answer, rather a line of thoughts. In principle, you could have from zero to $n$ possible tangent lines from a given point to a given curve.

Example of zero tangents: given the parabola $y=x^2$ and the point $P=(0,1)$, you don't have any tangents from $P$ to the parabola.

Example of $n$ tangents: given $y=\sin(x)$ and the point $P=(0,2)$ you can have as many tangents as you like.

Restating the question, you want the following: Given a differentiable function $f:\mathbb{R}\rightarrow\mathbb{R}$ and a point $P=(x_0,y_0)$ in the plane, find a line $r$ tangent to $f$ passing through $P$.

The way you set up the problem leads to a bit of a confusion. The equation for a line passing through $P$ is given by $y=y_0+m(x-x_0)$, and you got it right, but it's not true that you must solve a differential equation to explicit it. In fact, you need to find a point of tangency $Q=(x_Q,y_Q)$, and the equation for the line is really $$y=y_0+f'(x_Q)(x-x_0)$$ The real difficulty of the question is finding such points: since the line passes through $P$ and $Q$, you have $$y_Q=y_0+f'(x_Q)(x_Q-x_0)$$ and since $Q$ lies on the graph of the function, $y_Q=f(x_Q)$, so $$f(x_Q)=y_0+f'(x_Q)(x_Q-x_0)$$ The equation looks like yours, but it is not a differential equation because you need not find a suitable function $f$, you want to find a point $(x_Q,y_Q)$ - in this case, just knowing the coordinate $x_Q$ is enough.

The complexity of the calculations depends on the function $f$.

You can see the problem also from a broader perspective: given a curve $\gamma$ in the plane, i.e. a differentiable function $\gamma:\mathbb{R}\rightarrow\mathbb{R^2}$, find a line tangent to $\gamma$ which passes through a given point $P=(x_0,y_0)$. A possible approach goes like this: consider the point $\gamma(t)=(x(t),y(t))$ and the vector $v=(x(t)-x_0,y(t)-y_0)$. This vector is a function of $t$ and is parallel to the line which passes through both $\gamma(t)$ and $P$. This line is tangent to $\gamma$ if the vector $v$ is parallel to $\gamma'$, i.e. if you can find a value $t^*$ and a nonzero real number $k$ such that $$\gamma'(t^*)=kv(t^*)$$ Note that this is not a differential equation! You need to find two numbers $t^*$ and $k$.

Bad idea. Your $y$ is a known function $f(x)$. The unknown is $x$.