Is differentiating on both sides of an equation allowed? [duplicate]

Let's say we have $x^2=25$ So we have two real roots ie $+5$ and $-5$.

But if we were to differentiate on both sides with respect to $x$ we'll have the equation $2x=0$ which gives us the only root as $x=0$.

So does differentiating on both sides of an equation alter it? If it does, then how do we conveniently do it in Integration by substitutions?
If not then what exactly is going on here ?


The problem is that $x^2=25$ is not an equality of functions; rather, equality holds only for a few values of $x$. If, on the other hand, we had some equality of the form $f(x)=g(x)$ that held for all real $x$, then we could differentiate both sides.


If we take $x^2 = 25$ as given, then it is indeed true that

$$ 2x \, \mathrm{d}x = 0 $$

your mistake is the supposition that this implies $2x = 0$; among the alternatives is that it is $\mathrm{d}x$ that vanishes, and consequently it does not make sense to take the "derivative with respect to $x$", for similar reasons that it doesn't make sense to divide by zero.

You're used to doing calculus in settings where the variables actually have room to vary, but that is not the case here: the entire domain over which $x$ is allowed to vary is the zero-dimensional set consisting of the two points $\pm 5$.

Zero dimensional calculus is degenerate and rather boring; variables don't have any room to vary continuously, and thus everything is (locally) constant and $\mathrm{d}u = 0$ no matter what $u$ is.


This kind of reasoning is more useful in higher dimension; e.g. two variables related by one equation (as you have when doing an integral substitution) is nondegenerate; in fact, it fits nicely into the single-variable calculus framework.

You can do more than $u$ substitutions too; there are other sorts of algebraic and geometric things you can do. e.g. to work in the unit circle, we can take as a given that the two dependent variables $x$ and $y$ satisfy

$$ x^2 + y^2 = 1 $$

from which we infer that

$$ 2x \, \mathrm{d}x + 2y \, \mathrm{d}y = 0 $$

which has various algebraic and geometric content. e.g. we can solve for

$$ \frac{\mathrm{d}y}{\mathrm{d}x} = -\frac{x}{y} $$

or we can quickly determine the tangent line at a point; e.g. the tangent line to $(0.6, 0.8)$ satisfies $1.2 \mathrm{d}x + 1.6 \mathrm{d}y = 0$. Since the tangent line varies in the same way the circle does at a point, the tangent line must have the form $1.2 x + 1.6 y = c$ for some constant $c$. Plugging in the given point gives $1.2 x + 1.6 y = 2$.

plot of circle and tangent line

(plot generated by this wolfram alpha command)


It depends on what you intend to mean when you write $$ x^2 = 25. $$ If $x$ is a real number, then the assertion "$x^2 = 25$" simply means what most people understand: equality between two real numbers. It is implied that $x$ is a real number too. The notion of differentiating a real number (with respect to ... nothing?) is not commonly defined and should be considered invalid.

If you use "$x^2$" as a shorthand for the function $x \mapsto x^2$, and $25$ as a shorthand for the function $x \mapsto 25$, then the assertion "$x^2 = 25$" would mean that the two functions are equal. (Two functions $f, g: \mathbb R \to \mathbb R$ are equal if and only if $f(x) = g(x)$ for all $x \in \mathbb R$.) Under this assumption, differentiation (with respect to the only variable) seems like a valid concept. Whether it yields a "true" statement or not is a separate matter. In this particular example, the initial assertion is false, so it is not a surprise that the conclusion $x = 0$ (which says that the identity function $x \mapsto x$ is equal to the zero function $x \mapsto 0$) is also nonsensical.

I think you actually can manufacture some context in which $x^2 = 25$ makes sense both before and after differentiation. For example, if $x$ is a name of a function $x: \mathbb R \to \mathbb R$, $25$ stands for the constant function $y \mapsto 25$, and $x^2$ stands for the function $x^2: y \mapsto x(y)^2$, then the statement "$x^2 = 25$" asserts that the function $x^2$ is equal to the function $25$. Differentiating this equation would yield $2x x'= 0$, by which I actually mean the function $y \mapsto 2 x(y) x'(y)$ and the function $y \mapsto 0$ are equal. (This suggests that $x$ should be a constant function if it is differentiable.)


mcb's answer suggests that the equal sign doesn't always have the same meaning. I disagree, the difference is in the role of $x$. When we write $(x-1)(x+1)=x^2-1$, we mean that for all $x$, $(x-1)(x+1)=x^2-1$. When we write $x^2=25$, it means for which $x$ is $x^2=25$ ? (Answer: $x=-5$ and $x=+5$).

In the first case, $x$ is used to denote any value from the function domain, whereas in the second example $x$ denotes a specific value from the function domain which corresponds to a given value in the codomain.

How does this apply to the question? Differentiating means calculating (f(x+dx)-f(x))/dx as dx goes to zero. This means evaluating f(x) at and around x. Now if f(x) and g(x) are only equal at a specific point x, then they're not equal at x+dx. That means f'(x) ≠ g'(x).


$f(x) = 25$ is a statement about one value of the function $f$. We certainly cannot conclude from this that $f'(x) = 0$, since one value tells us nothing about the gradient of $f$ at $x$ or anywhere else.

Similarly, from $x^2 = 25$ alone we can't deduce anything about the gradient of the "squared" function at $x$, and hence we can't use the fact that we know this gradient is $2x$ to deduce anything about the value of $2x$.

On the other hand, if two functions are equal everywhere then we can certainly differentiate both sides and (because of the theorem that says that if a function has a derivative at all then it has one unique derivative) deduce that the resulting functions are equal everywhere. $x^2 = 25$ is not a statement about two functions of $x$ being equal everywhere, so we're not entitled by this logic to differentiate both sides by $x$. If we try to interpret $x^2 = 25$ as a functional equality then we come up with the interpretation, "the function that maps $x$ to $x^2$ is the same function as the function that maps $x$ to $25$". Now, that is a statement of functions being equal everywhere, but it's false.

When we integrate by substitution, the substitution is an equality of two functions everywhere (or at least everywhere in the range of the integration), so we have a lot more to go on than we'd have if all we knew is that two functions agree at a single point (that is to say, intersect).