Why is $\int\left[\frac{\partial}{\partial y} \int M(x,y)dx \right]dy \ne \int M(x,y)dx$?

So, is $$\int\left[\frac{\partial}{\partial y}\int M(x,y)dx \right]dy \ne \int M(x,y)dx\;\;?$$

Let $u(x,y)$ be a function. Then $\left(\dfrac{\partial}{\partial y} u(x,y)\right)_x = N_u(x,y)$. Integrating this with respect to $y$, we get $$\int \dfrac{\partial}{\partial y} \color{red}{u(x,y)} dy = \color{red}{u(x,y)} = \int N_\color\red{u}(x,y) dy + \phi(x) \tag I$$. Considering this to be true( & I know this to be true), if we substitute $\int M(x,y)dx$ for $u(x,y)$ in the above equation, we get $$\int \dfrac{\partial}{\partial y} \color{red}{\int M(x,y)dx} dy = \color{red}{\int M(x,y)dx} = \int N_\color\red{\int M dx}(x,y) dy + \phi(x) \tag{II}$$.

But this seems to be not true. For example, consider $M(x,y) = x^2 -ay$. So, $$\int\left[\frac{\partial}{\partial y}\int M(x,y)dx \right]dy \\ = \int\left[\frac{\partial}{\partial y}\int (x^2 - ay)dx \right]dy \\ = \int\left[\frac{\partial}{\partial y} \left(\dfrac{x^3}{3} - axy\right) \right]dy \\ = \int\left[-ax\right]dy \\ = -axy$$ .

If I use $\int\left[\frac{\partial}{\partial y}\int M(x,y)dx \right]dy = \int M(x,y)dx$, then we get $$\int\left[\frac{\partial}{\partial y}\int (x^2 - ay)dx \right]dy \\= \dfrac{x^3}{3} - axy \ne -axy$$. That means $(I)$ is wrong, but I know that $(I)$ is not wrong. So, does that mean $(II)$ is wrong? Why can't I substitute $\int M(x,y)dx$ for $u(x,y)$ in $(I)$? I know something is not right but can't able to notice the flaw. Can anyone explain why is $\int\left[\frac{\partial}{\partial y}\int M(x,y)dx \right]dy \ne \int M(x,y)dx$?

• why $\int[-ay]dy =0$?? – the_candyman Sep 10 '15 at 18:37
• @the_candyman: Sorry, typo! – user142971 Sep 10 '15 at 18:42
• Note that $\int \frac{\partial}{\partial y} M(x,y) dy = M(x,y) + g(x)$ i.e. in general we have a different integration constant for each $x$. You are neglecting this point. – Winther Sep 10 '15 at 18:43

There is an error: $\frac{\partial}{\partial y} \left(\dfrac{x^3}{3} - axy\right)$ is not $-ay$ but $-ax$. When you antidifferentiate this with respect to $y$, you get $-axy + \phi(x)$ (i.e. the "constant of integration" may depend on $x$ in an arbitrary way), which does equal $\frac{x^3}{3}-axy$ when you take $\phi(x) = \frac{x^3}{3}$.