Exact differential equation proof - with indefinite integrals instead of definite integrals?

Consider two functions $$P,Q : \mathbb{R}^2 \to \mathbb{R}$$ related by

$$\frac{\partial P}{\partial y} = \frac{\partial Q}{\partial x}$$

We ask the question, are $$P,Q$$ derivable from some other function $$f$$ where

$$P = \frac{\partial f}{\partial x}\;\;\;\; \\ Q = \frac{\partial f}{\partial y}\;\; ?$$

The answer is yes and the proof with (definite) integrals is the following. If the last two equations are true statements, then taking the single integral with respect to $$y$$ gives

$$f = \int_{y_0}^y Q(x,t) dt + R(x)$$

And finally to fit in the last requirement $$P = \partial f/\partial x$$, we require that $$\frac{\partial f}{\partial x} = \frac{\partial }{\partial x}\int_{y_0}^y Q(x,t)dt + \frac{dR}{dx} = P(x,y)$$

Using Leibniz's integral rule to interchange operations, we get

$$\int_{y_0}^y \frac{\partial Q}{\partial x}(x,t)dt + \frac{dR}{dx} = P(x,y)$$

$$\int_{y_0}^y \frac{\partial P}{\partial y}(x,t)dt + \frac{dR}{dx} = P(x,y)$$

$$P(x,y) - P(x,y_0) + R'(x) = P(x,y)$$

$$R'(x) = P(x,y_0)$$ $$R = \int_{x_0}^x P(t,y_0) dx + C$$

In total, $$f$$ is of the form

$$f(x,y) = \int_{x_0}^x P(t,y_0) dt + \int_{y_0}^y Q(x,t) dt + C$$

How do I get to this result with indefinite integrals? Is it possible? I start out the proof the same way:

$$f = \int Q \; dy + R(x)$$

Then

$$\frac{\partial f}{\partial x} = \frac{\partial }{\partial x}\int Q \; dy + R'(x) = P$$

Assuming I can still use Leibniz's integral rule?

$$\int \frac{\partial Q}{\partial x} \; dy + R'(x) = P$$

$$\int \frac{\partial P}{\partial y} \; dy + R'(x) = P$$

Giving

$$P + S(x) + R'(x) = P ?$$ $$R'(x) = S(x)?$$

$$R = \int S(x)\; dx + C$$

So $$f$$ must take the form $$f(x,y) = \int Q \; dy + \int S(x) \; dx + C$$

However I don't see how this result is the same as the previous one. Or rather, it does seem to be the same if

$$\int S(x)\;dx = \int_{x_0}^x P(t,y_0)dt$$

Did I go wrong when using indefinite integrals? How do you prove the form of $$f$$ using indefinite integrals? Thank you in advance for any help

The error seems to be that I applied Leibniz's integral rule when I shouldn't have. The difference between $$\int f$$ and $$\int_a^x f$$ is that the first is an arbitrary antiderivative while the second is a particular antiderivative. Because of this, I assumed that I could use Leibniz's integral rule on an arbitrary antiderivative (I assumed "they are both antiderivatives so why not?")
• It may have something to do with the fact that $f$ is a function of 2 variables. If $f$ were a single variable function, then I think $d/dx \int f = \int d/dx f$. However Leibniz's integral rule, as stated, requires a full derivative outside the integral sign (after integration the 2 variable function becomes a 1 variable function). However If I just do $\int f(x,y) dy$, this is still a 2 variable function, requiring a partial derivative Oct 7, 2018 at 12:49