# Why can't we simply substitute the input variable into the output of a function?

Sorry if this question has been asked before. I'm not sure how to phrase this question properly (hence I couldn't find any fruitful results on Google).

We know that the following holds true for $|x| < 1$,

$$\frac{1}{1-x} = \sum_{i=0}^\infty x^i = 1 + x + x^2 + \ldots$$

If we substitute $x^2$ as the variable into both sides of the equation, we obtain:

$$\frac{1}{1-x^2} = \sum_{i=0}^\infty x^i = 1 + x^2 + x^4 + \ldots$$

which is also true.

However, if we try the same with integration, we will get a different outcome.

The following holds true by basic law of integration:

$$\int x dx = \frac{x^2}{2} + C$$ where C is an arbitrary constant.

If we substitute $x^2$ as the variable into both sides of the equation, we obtain:

$$\int x^2 dx = \frac{x^4}{2} + C$$

which is clearly wrong.

My question is, $x$ is meant to be an arbitrary input for a function. Hence, (I think) we could substitute $x$ with anything and simply plug the new variable into the output as well. Although this is evidently false in the integration example, it works for the example using geometric series. Why does this claim hold true sometimes and fail in other situations (just like in the 2 examples given above)?

You can substitute $x^2$ as the variable, but you need to substitute it everywhere it appears. In the OP's example, you did not substitute it into the $dx$. $$\int x^2 d(x^2)=\int 2x^3dx=\frac{x^4}{2}+C$$
Hence your example... (you've substituted $y=g(x)$, where $g(x)=x^2$ into an integral, and $g'(x)=2x\not =1$, so this throws a wrench in the works)