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