Why $f(x) = x^2$ has variable derivative but its tangent has constant slope?
I'm taking Brilliant.org's calculus course, and I'm on the section called The Derivative.
My (mis)understanding:
A tangent line is a linear function that grazes a point, $a$, on the graph of a different function. The slope of that tangent line is the instantaneous rate of change at $a$. The way you find this is by taking the difference ratio, giving you the slope, and plugging in equal values for the input points. So, for the function $f(x) = x^2$, the slope would be:
$$\require{cancel} \frac{b^2 - a^2}{b-a} = \frac{\cancel{(b-a)}(b+a)}{\cancel{b-a}} = b+a$$
Now, considering the case as the difference between $b$ and $a$ gets smaller, or equivalently, as the secant line's two points become one and the same point, thus turning it to a tangent line:
$$\lim_{b \rightarrow a} b +a = 2b = 2a$$
Thus, the derivative of the square function is found, $f'(x) = 2x$. The slope of the tangent is $2x$, but apparently, the derivative isn't the slope of the tangent, it is only so the other way around (see this Math.SE answer). I could define any number of functions of the form $g(x) = ax$, which would be tangent to or intersect the function $f(x)=x^2$, when $x=a$. For any of these functions, $g'(x) = a$, as per the difference ratio. The slopes of these functions would be any arbitrary number $a$, not $2x$. So, it seems we're dealing with the slope of one particular tangent. However, I can't see how this tangent line is linear. If it is linear, its slope is a constant, but $2x$ contains a variable.
All of this leads me to think that we're talking about the tangent line in a very different sense than the one of "a linear line that grazes the function's graph". But I've only been made familiar with the latter sense, and this mysterious sense is very ill-defined in my head. What is it and what does it have to do with tangent lines? The trick with morphing a secant line into a tangent line doesn't really explain this, because one can do that anywhere on the graph and wind up with tangent lines that have differing slopes, none of which are equal to $2x$.
I agree that $f(x) = x^2$ has a lot of tangent lines. In fact, for each point on its graph, there is a tangent line. Let's plot a few of them and then pick one out. The one that is picked out is "the tangent to $f(x) = x^2$ at $x = 3/2$".
There are several ways to express an equation of a line. One way is point-slope form, $$ y - y_0 = m(x - x_0) \text{,} $$ where $(x_0,y_0)$ is a point on the line and $m$ is the slope of the line. Point-slope form is convenient for tangent lines because we can use the function to get a point on the graph and the derivative to get the slope of the line tangent to that point of the graph.
For the one tangent line picked out above, $x = 3/2$. We can quickly compute \begin{align*} f(3/2) &= (3/2)^2 = 9/4 \\ f'(3/2) &= 2(3/2) = 3 \text{.} \end{align*} So an equation of that line is $$ y - 9/4 = 3(x - 3/2) \text{.} $$ (Rearranging to slope-intercept form, which may be more familiar, we have $y = 3x - 9/4$. The slope is $3$ any way we write it, but it is easy to see that the line meets the $y$-axis in the lower half-plane.)
So, what can we do? For any choice of $x$, we can use the function to get a point on the graph and use the derivative of that function to get the slope of the tangent line to the graph at that point. The first graph (reproduced here) has the graph of $y = f(x)$ in blue. Pick one of the green lines: it meets the blue curve at one point and is parallel to the curve at that point. Each green line is a line, none of these are not lines. Two things change as we pick different points on the graph: the coordinates of the point and the slope of the line through that point. This means that the derivative has to be a function: for each point on the graph, we need a slope of the line tangent to that point. The function you obtained was $f'(x) = 2x$. And we can see this: for the green lines tangent to the left half of the curve, the slopes are negative because when $x$ is negative, so is $2x$. On the right half, the slopes are positive. Near $x =0$, $x$ is small, $2x$ is small, and the slopes are near zero (meaning close to horizontal). As we run off to the left or right (allowing $x$ to have large magnitude) the slopes become steeper in both directions.
So, yes, the derivative is a function -- it has to be able to tell you about different slopes of lines at different points on the graph of the function. If you draw all the tangent lines, you get a lot of tangent lines.
It is a coincidence that each tangent line in the above graphs meet the graph of $f$ exactly once. (Blah blah, convex region, blah blah... not what we're here to talk about.) A more general example is this: \begin{align*} f(x) &= x^3 - x \\ f'(x) &= 3x^2 - 1 \end{align*} picking $x = 1/2$, \begin{align*} f(1/2) &= (1/2)^3 - (1/2) = -3/8 \\ f'(1/2) &= 3(1/2)^2 - 1 = -1/4 \end{align*} So we expect to see a line through $(1/2,-3/8)$ with slope $-1/4$ that is tangent to the curve at that point.
It also happens that the line meets the curve somewhere else. This is not "important". The required properties are "intersects the graph at the point with the $x$-coordinate we picked, $1/2$" and "is tangent to the graph at that point". That this line also meets the graph again somewhere else is just what happens when you graph the line having those two properties.
$f'(x)$ represents the slope of a tangent line of a function $f(x)$ at a particular point $x$. Regarded as its own function of $x$, $f'(x)$ need not be constant or linear, i.e. the slope of the tangent line can vary nonlinearly in $x$.
It looks like you're misinterpreting what the derivative is. I'll explain this the way I would have if I was teaching calculus this year.
When we have functions, we may sometimes wish to see how the dependent variable changes. This change can be approximated by secant lines, but we may want to know how quickly a quantity changes at a single point. Think about looking at a speedometer at one moment in time.
Suppose $f(x)$ is a function we wish to look at. We can examine small changes in $f$ by taking a point nearby, say $x_0$. You've done this above for the particular function $f(x) = x^2.$ The slope of the line joining $(x, x^2)$ and $(x_0, {x_0}^2)$ is
$$ m = \frac{x^2-{x_0}^2}{x - x_0}$$
which approaches $2x_0$ as $x \to x_0$. This is limit, a fundamental concept you must examine before beginning differentiation.
The derivative is the slope of the tangent line, and itself may not be a linear function. Consider the classic example - let $g(x) = e^x,$ and so $g'(x) = e^x$. Certainly the slope function is nonlinear, but that doesn't matter. The derivative $g'$ gives us how quickly the function changes at a specific point.
I commonly refer to the derivative as the "slope function," since it tells us slope at a particular point. The tangent line is a line, yes, but its slope is determined by the derivative at a point.