Is differentiating on both sides of an equation allowed? 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 ?
 A: 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.)
A: 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.
A: $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).
A: Differentiating both sides is not generally an equality preserving operation for the following reason:
Every term can be interpreted as a function of any variable. There is a special case in which the variable in question is not present in the term (or has a 0 as coefficient), this is what's called a constant function with respect to the variable (which can be plotted as a horizontal line). So, an interpretation of $x^2=25$ is that you look for the intersection set of two curves, a horizontal line and a parabola. If you take the derivative of both sides you get different curves and thus a different intersection set, so the truth value of the equation is not preserved with the same variable assignment.

Differentiating both sides only works if the intersection points of the derivatives happen to fall on the same coordinates (e.g. $\sin x=\cos x$, $\sin' x=\cos' x$, $\cos x=\sin x$, or more trivially if both sides are equal for all variable assignments; that implication doesn’t always work the other way around though: if $f(x)≠g(x)$, then it could be that $f'(x)=g'(x)$, e.g. with $f(x) = 1$ and $g(x) = 2$).
If you want to learn about the exact mechanics behind this, what exactly function terms and variable assignments are, the keyword to search for is first order logic. This is the most commonly used axiom system that tells you exactly how we usually manipulate logical sentences and formulas and based on which we formulate the Zermelo–Fraenkel set theory, most commonly used for everything that involves sets.
A: 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).
A: 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 generated by this wolfram alpha command)
A: Like algebraic addition or multiplication on both sides of an equation you cannot differentiate if there is no functional dependence between quantities on either side of a given equation. 
Differentiation is performed mostly when rates of change have to be found, for example in finding a derivative, to find extrema or to find relationship with other variables. Also constants will disappear on differentiation.
A: Normally doing the same operation on both sides of an equation would result in an implication. That is if $L = R$ then it would imply that $\phi(L)=\phi(R)$.
The problem here is that the differentiation is a operation that works on a neighborhood of the point and the solutions to the first equation is isolated points. What happens is the first equation does not imply a function that would be differentiable, because it's solution is two isolated points.
A: When you are given two functions $f(x)$ and $g(x)$;
and you make an equation: $$f(x)=g(x)$$
and try to solve the equation wrt. $x$;
then you are essentially asking 'where (for what $x$ values) have the two function same value?'.
Suppose both functions are continuous and you can interpret them as positions of two bodies changing in time. Then the equation is a question 'when the two bodies meet?'
When you differentiate both sides, then the sides become a slope ('steepness') of the given functions, so requiring them equal is essentialy a question 'where the two functions rise (or fall) at the same rate?'.
For the kinematic analogy it would be 'when the two bodies move with the same velocity?'
Hope it's obvious now, that the two equations may have unrelated solutions.
The two functions (square and constant one) have same value where their graphs intersect, which is at $x=\pm 5$, but they have the same rate of change where their graphs have same direction of a tangent line, which is at $x=0$.
