Differentiating both sides of an equation I'm going through the MIT lecture on implicit differentiation, and the first two steps are shown below, taking the derivative of both sides:
$$x^2 + y^2 = 1$$
$$\frac{d}{dx} x^2 + \frac{d}{dx} y^2 = \frac{d}{dx} 1$$
$$2x + \frac{d}{dx}y^2 = 0$$
That makes some sense, but what about this example:
$$x = 5$$
$$\frac{d}{dx} x = \frac{d}{dx} 5$$
$$1 = 0$$
Why is the first example correct, while the second is obviously wrong?
 A: $x=5$ implies that $x$ doesn't change so it's meaningless to try to take the derivative of it with respect to $x$
A: The problem isn't with the calculus. It's that you're subtly asking it to divide by zero. 
Here's why. Remember that calculus is just a method for calculating the gradient of a curve at every point. Recall that, for a straight line, the answer is easy. The gradient is simply:  $$\frac{\text{change in vertical height}}{\text{change in horizontal distance}}$$
Now suppose that $x$ represents a constant. Then there is no change in $x$. So the gradient must be equal to:$$\frac{\text{change in }x}{\text{change in horizontal distance}}=\frac{0}{\text{change in horizontal distance}} = 0$$
So far so good. But what happens when we try to take the derivative of $x$ with respect to itself? That's the same as asking how $x$ changes as $x$ changes, which is like labeling our graph so that both the vertical and horizontal axes represent $x$. So now it is not only the change in vertical height that equals 0, but also the change in horizontal height. Hence the gradient must equal 0/0, which is undefined. 
More generally, the change in $x$ with respect to any constant c is undefined. Since the constant does not change, the change in c equals 0. Hence the tangent at each point of the curve equals: $$\frac{\text{change in } x}{\text{change in } c} \; \; \; =\; \; \; \frac{\text{change in } x}{0}\; \; \; = \; \; \;undefined$$ Because this is true of the tangent at each and every point of the curve, we can intuitively see how $\frac{dx}{dc}$ as a whole must be undefined.  
The take-home rule is that though you can take the derivative of a constant, you cannot take the derivative with respect to a constant. As a corollary, you cannot take the derivative of a constant with respect to itself, which is what explains the problem case in the question above. 

Thinking just in terms of linear gradients, without worrying about infinitesimal limits and such, you can see in intuitive terms how you get the mistaken equality 1 = 0.
Let's again imagine we are dealing with straight lines, so that we can let $\delta x$ represent the change in $x$ without having to imagine that we have taken anything to the limit. Then the mathematics that gets us the left hand side of the mistaken equality corresponds to the intuitive rule that, since the numerator and denominator of $\frac{\delta x}{\delta x}$ are the same, $\frac{\delta x}{\delta x}$ must equal 1. 
The mathematics that gets us the right hand side of the mistaken equality corresponds to the intuitive rule that, since $x$ is a constant, $\delta x = 0$, hence the numerator of $\frac{\delta x}{\delta x}$ is 0 and so $\frac{\delta x}{\delta x}$ must itself equal 0. 
The mistake, in both cases, is in failing to notice that when $x$ is constant $\frac{\delta x}{\delta x} = \frac{0}{0}$, which is an exception to both of these rules. 
A: The first of your identities makes some implicit assumptions: it should be read as
$$
x^2+f(x)^2=1
$$
where $f$ is some (as yet undetermined) function. If we assume $f$ to be differentiable, then we can differentiate both sides:
$$
2x+2f(x)f'(x)=0
$$
because the assumption is that the function $g$ defined by $g(x)=x^2+f(x)^2$ is constant.
From this we can derive
$$
f'(x)=-\frac{x}{f(x)}
$$
at least in the points where $f(x)\ne0$, which excludes $x=1$ and $x=-1$ from the domain where $f$ is differentiable.
Thus what you get is that assuming $f$ exists and is differentiable, then, for $x\ne1$ and $x\ne 1$, $f'$ satisfies the above relation.
Why is the relation written in that way? The answer is that often we're given a locus defined by some equation in two variables: it's the set of points $(x,y)$ such that $h(x,y)=0$ and we try finding an explicit form for the locus, that is a relation $y=f(x)$ or $x=g(y)$ , so that
$$
h(x,f(x))=0\qquad\text{ or }\qquad h(g(y),y)=0
$$
holds for $x$ in a suitable neighborhood of $x_0$ or $y$ in a suitable neighborhood of $y_0$ where $(x_0,y_0)$ belongs to the locus.
Take for example the folium Cartesii $x^3+y^3-3xy=0$.

If we differentiate with respect to $x$, we get
$$
3x^2+3y^2y'-3y-3xy'=0
$$
which gives
$$
y'=\frac{y-x^2}{y^2-x}
$$
We're able to find where the derivative is zero by setting $y=x^2$ and plugging in the original equation
$$
x^3+x^6-3x^3=0
$$
that is $x=0$ (which can't be used) or $x^3=2$, without even knowing the “explicit form“ $y=f(x)$.
A: You wrote "$x = 5$"; what does that tell us about $x$? Just that, $x$ equals 5. So in differentiating both sides you must keep that in mind. In other words, $x$ is constant and 5 is constant.
Also, then you can't do
$${d \over dx} x = {d \over dx} 5, \tag{1}$$
since that's equivalent to
$${d \over dx} x = {d \over d5} 5, \tag{2}$$
which already has been pointed out is meaningless.
Though you can do
$${d \over dy} x = {d \over dy} 5 \Leftrightarrow 0 =0;\tag{3}$$
here $y$ is an independent variable over the real numbers.
A: $$2x + \frac{d}{dx}y^2 = constant $$
$$ x + y \frac{dy}{dx} = 0$$
That makes sense to seek variation between $x$ and $y$  in terms of differentials  for a certain curve, the circle.
Now attacking a constant.
$$x = 5$$
There is no variation it is so clearly known and stated and understood, knowing fully well that fact, we want still to press on to seek a variation between $x$ and $y$ !, just to see what will happen... That makes no sense with such a process... expectedly leading us nowhere,
$$ 1= 0. $$ 
