Is the definition of a tangent line flawed? A commonly-accepted definition of a tangent line is the following.

A tangent line is a straight line that touches a function at only one point.

However, there are clearly cases where a tangent at a point touches the function at another point. The example that comes to mind right now is $f(x) = x\sin(x),$ where the derivative at $x=0$ is $0$ and the line with zero slope with $y=0$ intersects the function at numerous (an infinite number of) places, including $(\pi, 0)$ for instance.
Is the above definition of a tangent line sufficient, and how so? If not, what is a better definition for a tangent line?
 A: Here is my answer
from an earlier question
(How is the derivative truly, literally the "best linear approximation" near a point?),
which shows that
the tangent is the best
local linear approximation to the function
at a point:
I'll first give a intuitive answer,
then an analytic answer.
Intuitively,
the tangent goes
in the same direction
as the function,
following it as
closely as possible
for a line.
Any other line
immediately starts to diverge
from the function.
Analytically:
Consider the Taylor aproximation
at $x$:
$f(x+h)
=f(x)+hf'(x)+h^2f''(x)/2+...
$.
This means that,
for small $h$
$f(x+h)
\approx f(x)+hf'(x)+h^2f''(x)/2
$
so that
the error
$E(x, h)
=f(x+h)- (f(x)+hf'(x))
$
is about
$ h^2f''(x)/2
$.
Now consider any other line
through $(x, f(x))$
with slope $s$,
with $s \ne f'(x)$.
At $x+h$,
its value is
$f(x)+sh$,
so its error,
$e(x, h)$ is
$e(x, h, s)
=f(x+h)-(f(x)+sh)
$.
Since
$f(x+h)-f(x)
\approx hf'(x)+h^2f''(x)/2
$,
$\begin{array}\\
e(x, h, s)
&=f(x+h)-(f(x)+sh)\\
&\approx hf'(x)+h^2f''(x)/2-sh\\
&= h(f'(x)-s)+h^2f''(x)/2\\
\end{array}
$
so that
$\dfrac{E(x, h)}{e(x, h, s)}
\approx \dfrac{h^2f''(x)/2}{h(f'(x)-s)+h^2f''(x)/2}
= \dfrac{hf''(x)/2}{f'(x)-s+hf''(x)/2}
$.
Since $s \ne f'(x)$,
as $h \to 0$,
the numerator of thie
ratio of errors
goes to zero,
while the denominator
stays bounded away from zero.
Therefore
the error of the tangent
goes to zero faster than
the error in any other line
through the point.
That is why the tangent
is the best linear approximation
to the curve.
A: There are two common alternatives to this definition:


*

*A tangent line is a linear function that locally (such that there exists a neighbourhood) touches $f$ at one point.

*A tangent line of $f$ at $x$ is a linear function $g$ with $g(x) = f(x)$ and $g'(x) = f'(x)$.
The definition (1) fails if $f$ a linear function or linear in a neighbourhood, in which case a linear approximation of $f$ at $x$ touches $f$ at infinitely many points. Definition (2) is much better: it coincides with the Taylor polynomial of order $1$ of $f$.
(2) can also be expressed in this form: $g$ is a tangent line of $f$ at $x$ if $g$ is linear and
$$ f(y) = g(y) + \mathrm O(y^2), \qquad (y \to x)
$$
in which case the existence of $g$ implies the differentiability of $f$.
A: Yes, the above definition is incorrect.  More accurately, I would think you'd need to use the following definition instead:

A tangent line is a straight line that touches a function once, locally, at a point.

However, this fails horribly for many functions, hence my second definition:

To me, it fits better in my mind if I think about it as two points, infinitely close, touching the function twice:


As a side note, my second definition transcends into a much better definition of tangent lines for polynomials degree greater than 1 (not linear).  If $P(x)$ is a polynomial and $f(x)$ a line, then $f(x)$ is the tangent line of $P(x)$ at $x=a$ if $Q(x)=P(x)-f(x)$ has a root of multiplicity greater than or equal to 2 at $x=a$.  (the idea of roots with multiplicities greater than or equal to 2 comes about from the concept "a line that crosses two points infinitely close")
A nice example: Take $P(x)=x^2$ and $f(x)=2x-1$.  We see that
$Q(x)=P(x)-f(x)=x^2-2x+1=(x-1)^2$
It has a root of multiplicity two at $x=1$, thus, $f(x)$ is the tangent of $P(x)$ at $x=1$.
A: yeah that definition is imprecise. A better definition is that a tangent line at a point $x_0$ is equal to 
$$y-f(x_0) = f'(x_0)(x-x_0)$$
i.e. it is the line constructed but taking a point and drawing a line going through that point which has the same slope as the function at that point.
A: Let $f$ be a function, let $p = (x, f(x))$ be a point on the graph of the function.  
Better definition: a tangent line to $f$ at $p$ is a line $\ell$ which passes through $p$, such that there exists a neighborhood $V$ of $p$ such that $\ell$ does not pass through any other points of the graph of the function in $V$.  This allows you to avoid mistakes like the example you pointed out.
Best definition: a tangent line to $f$ at $p$ is a line $\ell$ passing through $p$ whose slope is $\lim\limits_{h \to 0} \frac{f(x+h)-f(x)}{h}$, provided this limit exists.
